diff --git a/helpdesk/query.py b/helpdesk/query.py index 81fe4082..a2263326 100644 --- a/helpdesk/query.py +++ b/helpdesk/query.py @@ -96,7 +96,7 @@ def get_query(query, huser): tickets = huser.get_tickets_in_queues().select_related() query_params = query_from_base64(query) ticket_qs = apply_query(tickets, query_params) - cache.set(huser.user.email + query, ticket_qs, timeout=60*60) + cache.set(huser.user.email + query, ticket_qs, timeout=3600) return ticket_qs diff --git a/helpdesk/user.py b/helpdesk/user.py index e2492a41..32091d8e 100644 --- a/helpdesk/user.py +++ b/helpdesk/user.py @@ -5,6 +5,7 @@ from helpdesk.models import ( from helpdesk import settings as helpdesk_settings + class HelpdeskUser: def __init__(self, user): self.user = user @@ -32,7 +33,6 @@ class HelpdeskUser: def get_tickets_in_queues(self): return Ticket.objects.filter(queue__in=self.get_queues()) - def can_access_queue(self, queue): """Check if a certain user can access a certain queue. @@ -46,7 +46,6 @@ class HelpdeskUser: else: return user.has_perm(queue.permission_name) - def can_access_ticket(self, ticket): """Check to see if the user has permission to access a ticket. If not then deny access.""" @@ -54,7 +53,7 @@ class HelpdeskUser: if self.can_access_queue(ticket.queue): return True elif user.is_superuser or user.is_staff or \ - (ticket.assigned_to and user.id == ticket.assigned_to.id): + (ticket.assigned_to and user.id == ticket.assigned_to.id): return True else: return False diff --git a/helpdesk/views/staff.py b/helpdesk/views/staff.py index 14b6be86..cb84108f 100644 --- a/helpdesk/views/staff.py +++ b/helpdesk/views/staff.py @@ -178,6 +178,7 @@ def dashboard(request): dashboard = staff_member_required(dashboard) + def ticket_perm_check(request, ticket): huser = HelpdeskUser(request.user) if not huser.can_access_queue(ticket.queue): @@ -185,6 +186,7 @@ def ticket_perm_check(request, ticket): if not huser.can_access_ticket(ticket): raise PermissionDenied() + @helpdesk_staff_member_required def delete_ticket(request, ticket_id): ticket = get_object_or_404(Ticket, id=ticket_id) @@ -909,7 +911,7 @@ def ticket_list(request): tickets_base = get_query(urlsafe_query, huser) user_saved_queries = SavedSearch.objects.filter(Q(user=request.user) | Q(shared__exact=True)) - + ticket_qs = None try: ticket_qs = apply_query(tickets_base, query_params) @@ -931,7 +933,6 @@ def ticket_list(request): '' 'Django Documentation on string matching in SQLite.') - return render(request, 'helpdesk/ticket_list.html', dict( context, tickets=ticket_qs,