Skip to content

Commit

Permalink
Merge pull request #589 from NASA-IMPACT/fixup/rm-unused-method
Browse files Browse the repository at this point in the history
Rm unused get() method logic
  • Loading branch information
edkeeble authored Oct 20, 2023
2 parents 686f1aa + d9dc48a commit a975b70
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 27 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ jobs:
- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: 3.11.5
python-version: 3.11.6
# cache: pip # Unable to use caching, https://github.com/actions/setup-python/issues/719

- name: Set user-site-path
Expand Down
27 changes: 1 addition & 26 deletions app/admin_ui/views/v2.py
Original file line number Diff line number Diff line change
Expand Up @@ -216,32 +216,6 @@ class CanonicalDraftEdit(NotificationSidebar, mixins.ChangeModelFormMixin, Updat
pk_url_kwarg = 'canonical_uuid'
queryset = Change.objects.all().exclude(status=Change.Statuses.PUBLISHED)

def get_queryset(self):
return Change.objects.all()

def get(self, request, *args, **kwargs):
self.object = self.get_object()
in_progress_drafts = Change.objects.related_in_progress_drafts(
self.kwargs["canonical_uuid"]
)

published_drafts = Change.objects.related_drafts(self.kwargs["canonical_uuid"]).filter(
status=Change.Statuses.PUBLISHED
)

if not in_progress_drafts.exists() and published_drafts.exists():
return redirect(
reverse(
"canonical-published-detail",
kwargs={
"canonical_uuid": self.kwargs[self.pk_url_kwarg],
"draft_uuid": self.object.pk,
"model": self.kwargs["model"],
},
)
)
return super().get(request, *args, **kwargs)

def get_object(self, queryset=None):
if not queryset:
queryset = self.queryset
Expand All @@ -250,6 +224,7 @@ def get_object(self, queryset=None):

if obj := queryset.related_drafts(canonical_uuid).order_by('status').first():
return obj

raise Http404(f'No in progress draft with Canonical UUID {canonical_uuid!r}')

def get_success_url(self, **kwargs):
Expand Down

0 comments on commit a975b70

Please sign in to comment.