mirror of
https://github.com/bugsink/bugsink.git
synced 2026-01-29 17:09:55 -06:00
_get_events helper: clarify edge-cases
In b76e474ef1, the event-navigation was changed into the next/prev idiom (I
think completely, i.e. also from the .html files, but did not check) but the
elif structure and error message did not fully reflect that (it still talked
about digest_order/id, but nav is now one of the primary methods)
I briefly considered removing the lookup-by-digest-order-only, but I figure it
may come in handy at some point (if only for users to directly edit the url)
and did not check whether this is actually unused.
This commit is contained in:
@@ -344,6 +344,9 @@ def _get_event(issue, event_pk, digest_order, nav):
|
||||
return Event.objects.filter(issue=issue).order_by("digest_order").last()
|
||||
|
||||
if nav in ["prev", "next"]:
|
||||
if digest_order is None:
|
||||
raise Http404("Cannot look up with '%s' without digest_order" % nav)
|
||||
|
||||
if nav == "prev":
|
||||
result = Event.objects.filter(
|
||||
issue=issue, digest_order__lt=digest_order).order_by("-digest_order").first()
|
||||
@@ -356,7 +359,7 @@ def _get_event(issue, event_pk, digest_order, nav):
|
||||
|
||||
raise Http404("Cannot look up with '%s'" % nav)
|
||||
|
||||
if event_pk is not None:
|
||||
elif event_pk is not None:
|
||||
# we match on both internal and external id, trying internal first
|
||||
try:
|
||||
return Event.objects.get(pk=event_pk)
|
||||
@@ -366,7 +369,7 @@ def _get_event(issue, event_pk, digest_order, nav):
|
||||
elif digest_order is not None:
|
||||
return Event.objects.get(issue=issue, digest_order=digest_order)
|
||||
else:
|
||||
raise ValueError("either event_pk or digest_order must be provided")
|
||||
raise Http404("Either event_pk, nav, or digest_order must be provided")
|
||||
|
||||
|
||||
@atomic_for_request_method
|
||||
|
||||
Reference in New Issue
Block a user