mirror of
https://gitea.mueller.network/extern/django-helpdesk.git
synced 2024-11-29 03:13:15 +01:00
Add get_report_queryset_or_redirect
helper
Gets required objects or redirects
This commit is contained in:
parent
50bd72ac7a
commit
b1bf2cab46
@ -1539,12 +1539,18 @@ def report_index(request):
|
|||||||
report_index = staff_member_required(report_index)
|
report_index = staff_member_required(report_index)
|
||||||
|
|
||||||
|
|
||||||
@helpdesk_staff_member_required
|
def get_report_queryset_or_redirect(request, report):
|
||||||
def run_report(request, report):
|
|
||||||
if Ticket.objects.all().count() == 0 or report not in (
|
if Ticket.objects.all().count() == 0 or report not in (
|
||||||
'queuemonth', 'usermonth', 'queuestatus', 'queuepriority', 'userstatus',
|
"queuemonth",
|
||||||
'userpriority', 'userqueue', 'daysuntilticketclosedbymonth'):
|
"usermonth",
|
||||||
return HttpResponseRedirect(reverse("helpdesk:report_index"))
|
"queuestatus",
|
||||||
|
"queuepriority",
|
||||||
|
"userstatus",
|
||||||
|
"userpriority",
|
||||||
|
"userqueue",
|
||||||
|
"daysuntilticketclosedbymonth"
|
||||||
|
):
|
||||||
|
return None, None, HttpResponseRedirect(reverse("helpdesk:report_index"))
|
||||||
|
|
||||||
report_queryset = Ticket.objects.all().select_related().filter(
|
report_queryset = Ticket.objects.all().select_related().filter(
|
||||||
queue__in=HelpdeskUser(request.user).get_queues()
|
queue__in=HelpdeskUser(request.user).get_queues()
|
||||||
@ -1553,8 +1559,18 @@ def run_report(request, report):
|
|||||||
try:
|
try:
|
||||||
saved_query, query_params = load_saved_query(request)
|
saved_query, query_params = load_saved_query(request)
|
||||||
except QueryLoadError:
|
except QueryLoadError:
|
||||||
return HttpResponseRedirect(reverse('helpdesk:report_index'))
|
return None, HttpResponseRedirect(reverse('helpdesk:report_index'))
|
||||||
|
return report_queryset, query_params, saved_query, None
|
||||||
|
|
||||||
|
|
||||||
|
@helpdesk_staff_member_required
|
||||||
|
def run_report(request, report):
|
||||||
|
|
||||||
|
report_queryset, query_params, saved_query, redirect = get_report_queryset_or_redirect(
|
||||||
|
request, report
|
||||||
|
)
|
||||||
|
if redirect:
|
||||||
|
return redirect
|
||||||
if request.GET.get('saved_query', None):
|
if request.GET.get('saved_query', None):
|
||||||
Query(report_queryset, query_to_base64(query_params))
|
Query(report_queryset, query_to_base64(query_params))
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user