Skip to content

Commit

Permalink
Rm unused get() method logic
Browse files Browse the repository at this point in the history
  • Loading branch information
alukach authored Oct 19, 2023
1 parent 686f1aa commit d701527
Showing 1 changed file with 1 addition and 23 deletions.
24 changes: 1 addition & 23 deletions app/admin_ui/views/v2.py
Original file line number Diff line number Diff line change
Expand Up @@ -219,29 +219,6 @@ class CanonicalDraftEdit(NotificationSidebar, mixins.ChangeModelFormMixin, Updat
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 +227,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 d701527

Please sign in to comment.