forked from extern/django-helpdesk
Merge pull request #884 from alligatorbait/master
update saved_queries imports, filter, and authentication checks, correct created field reference and remove Django version decrement
This commit is contained in:
commit
8e7be70af2
@ -163,7 +163,7 @@ class __Query__:
|
||||
to a Serializer called DatatablesTicketSerializer in serializers.py.
|
||||
"""
|
||||
objects = self.get()
|
||||
order_by = '-date_created'
|
||||
order_by = '-created'
|
||||
draw = int(kwargs.get('draw', [0])[0])
|
||||
length = int(kwargs.get('length', [25])[0])
|
||||
start = int(kwargs.get('start', [0])[0])
|
||||
|
@ -5,15 +5,22 @@ templatetags/saved_queries.py - This template tag returns previously saved
|
||||
queries. Therefore you don't need to modify
|
||||
any views.
|
||||
"""
|
||||
from django.template import Library
|
||||
from django import template
|
||||
from django.db.models import Q
|
||||
|
||||
from helpdesk.models import SavedSearch
|
||||
|
||||
|
||||
register = template.Library()
|
||||
|
||||
|
||||
@register.filter
|
||||
def saved_queries(user):
|
||||
try:
|
||||
user_saved_queries = SavedSearch.objects.filter(Q(user=user) | Q(shared__exact=True))
|
||||
filters = Q(shared__exact=True)
|
||||
if user.is_authenticated:
|
||||
filters |= Q(user=user)
|
||||
user_saved_queries = SavedSearch.objects.filter(filters)
|
||||
return user_saved_queries
|
||||
except Exception as e:
|
||||
import sys
|
||||
@ -21,7 +28,3 @@ def saved_queries(user):
|
||||
file=sys.stderr)
|
||||
print(e, file=sys.stderr)
|
||||
return ''
|
||||
|
||||
|
||||
register = Library()
|
||||
register.filter('saved_queries', saved_queries)
|
||||
|
@ -99,7 +99,10 @@ def dashboard(request):
|
||||
with options for them to 'Take' ownership of said tickets.
|
||||
"""
|
||||
# user settings num tickets per page
|
||||
tickets_per_page = request.user.usersettings_helpdesk.tickets_per_page or 25
|
||||
if request.user.is_authenticated and hasattr(request.user, 'usersettings_helpdesk'):
|
||||
tickets_per_page = request.user.usersettings_helpdesk.tickets_per_page
|
||||
else:
|
||||
tickets_per_page = 25
|
||||
|
||||
# page vars for the three ticket tables
|
||||
user_tickets_page = request.GET.get(_('ut_page'), 1)
|
||||
|
@ -1,4 +1,4 @@
|
||||
Django>=2.2.13,<3
|
||||
Django
|
||||
django-bootstrap4-form
|
||||
celery
|
||||
django-celery-beat
|
||||
|
Loading…
Reference in New Issue
Block a user