Skip to content

Commit

Permalink
Merge pull request #609 from NASA-IMPACT/bugfix/multi-dependents
Browse files Browse the repository at this point in the history
Bugfix/multiple unpublished dependents
  • Loading branch information
edkeeble authored Feb 8, 2024
2 parents 2267a96 + d918654 commit fa8d415
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
http://cookiecutter-django.readthedocs.io/en/latest/faq.html#why-is-there-a-django-contrib-sites-directory-in-cookiecutter-django
"""

from django.conf import settings
from django.db import migrations

Expand Down
3 changes: 1 addition & 2 deletions app/admin_ui/admin/data_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,7 @@
@admin.register(models.GcmdPhenomenon)
@admin.register(models.WebsiteType)
@admin.register(models.Website)
class BasicAdmin(admin.ModelAdmin, EnforcedPermissionsMixin):
...
class BasicAdmin(admin.ModelAdmin, EnforcedPermissionsMixin): ...

Check failure on line 33 in app/admin_ui/admin/data_models.py

View workflow job for this annotation

GitHub Actions / Flake8

app/admin_ui/admin/data_models.py#L33

Multiple statements on one line (colon) (E701)


@admin.register(models.CollectionPeriod)
Expand Down
4 changes: 2 additions & 2 deletions app/admin_ui/templates/snippets/dependent_drafts.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{% regroup descendents by view_model as grouped_descendents %}
{% regroup descendents by content_type as grouped_descendents %}
<ul class="list-unstyled">
{% for model_type in grouped_descendents %}
<li class="font-weight-bold">{{ model_type.grouper }}</li>
<li class="font-weight-bold">{{ model_type.grouper.model | capfirst }}</li>
<ul>
{% for instance in model_type.list %}
<li>
Expand Down
10 changes: 8 additions & 2 deletions app/admin_ui/views/v2.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
from django.contrib.contenttypes.models import ContentType
from django.views.generic.edit import UpdateView
from django.db.models import OuterRef, Subquery
from django.db.models.functions import Coalesce
from django.views.generic.edit import CreateView
from django_filters.views import FilterView
from django_tables2 import SingleTableView, SingleTableMixin
Expand Down Expand Up @@ -651,8 +652,13 @@ def get_object(self, queryset=None):
def _filter_latest_changes(change_queryset):
"""Returns the single latest Change draft for each model_instance_uuid in the
provided queryset."""
return change_queryset.order_by('model_instance_uuid', '-approvallog__date').distinct(
'model_instance_uuid'
# Using Coalesce to handle the case where model_instance_uuid is None,
# since distinct will treat NULLs as equal.
# Using `cid` rather than `canonical_uuid` to avoid a name conflict on the model
return (
change_queryset.annotate(cid=Coalesce("model_instance_uuid", "uuid"))
.order_by('cid', '-approvallog__date')
.distinct('cid')
)

def get_context_data(self, **kwargs):
Expand Down
2 changes: 1 addition & 1 deletion app/config/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
path("accounts/", include("allauth.urls")),
path("api/", include("api_app.urls")),
path("authenticate/token/", CustomTokenView.as_view(), name="token"),
path("authenticate/", include("oauth2_provider.urls"), name="oauth2_provider")
path("authenticate/", include("oauth2_provider.urls"), name="oauth2_provider"),
# Your stuff: custom urls includes go here
] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)

Expand Down
1 change: 1 addition & 0 deletions app/config/wsgi.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
framework.
"""

import os
import sys

Expand Down

0 comments on commit fa8d415

Please sign in to comment.