forked from extern/django-helpdesk
PEP-8 codestyle improvements to pass tests
This commit is contained in:
parent
182d553356
commit
0573bc37f8
@ -96,7 +96,7 @@ def get_query(query, huser):
|
|||||||
tickets = huser.get_tickets_in_queues().select_related()
|
tickets = huser.get_tickets_in_queues().select_related()
|
||||||
query_params = query_from_base64(query)
|
query_params = query_from_base64(query)
|
||||||
ticket_qs = apply_query(tickets, query_params)
|
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
|
return ticket_qs
|
||||||
|
|
||||||
|
|
||||||
|
@ -5,6 +5,7 @@ from helpdesk.models import (
|
|||||||
|
|
||||||
from helpdesk import settings as helpdesk_settings
|
from helpdesk import settings as helpdesk_settings
|
||||||
|
|
||||||
|
|
||||||
class HelpdeskUser:
|
class HelpdeskUser:
|
||||||
def __init__(self, user):
|
def __init__(self, user):
|
||||||
self.user = user
|
self.user = user
|
||||||
@ -32,7 +33,6 @@ class HelpdeskUser:
|
|||||||
def get_tickets_in_queues(self):
|
def get_tickets_in_queues(self):
|
||||||
return Ticket.objects.filter(queue__in=self.get_queues())
|
return Ticket.objects.filter(queue__in=self.get_queues())
|
||||||
|
|
||||||
|
|
||||||
def can_access_queue(self, queue):
|
def can_access_queue(self, queue):
|
||||||
"""Check if a certain user can access a certain queue.
|
"""Check if a certain user can access a certain queue.
|
||||||
|
|
||||||
@ -46,7 +46,6 @@ class HelpdeskUser:
|
|||||||
else:
|
else:
|
||||||
return user.has_perm(queue.permission_name)
|
return user.has_perm(queue.permission_name)
|
||||||
|
|
||||||
|
|
||||||
def can_access_ticket(self, ticket):
|
def can_access_ticket(self, ticket):
|
||||||
"""Check to see if the user has permission to access
|
"""Check to see if the user has permission to access
|
||||||
a ticket. If not then deny access."""
|
a ticket. If not then deny access."""
|
||||||
@ -54,7 +53,7 @@ class HelpdeskUser:
|
|||||||
if self.can_access_queue(ticket.queue):
|
if self.can_access_queue(ticket.queue):
|
||||||
return True
|
return True
|
||||||
elif user.is_superuser or user.is_staff or \
|
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
|
return True
|
||||||
else:
|
else:
|
||||||
return False
|
return False
|
||||||
|
@ -178,6 +178,7 @@ def dashboard(request):
|
|||||||
|
|
||||||
dashboard = staff_member_required(dashboard)
|
dashboard = staff_member_required(dashboard)
|
||||||
|
|
||||||
|
|
||||||
def ticket_perm_check(request, ticket):
|
def ticket_perm_check(request, ticket):
|
||||||
huser = HelpdeskUser(request.user)
|
huser = HelpdeskUser(request.user)
|
||||||
if not huser.can_access_queue(ticket.queue):
|
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):
|
if not huser.can_access_ticket(ticket):
|
||||||
raise PermissionDenied()
|
raise PermissionDenied()
|
||||||
|
|
||||||
|
|
||||||
@helpdesk_staff_member_required
|
@helpdesk_staff_member_required
|
||||||
def delete_ticket(request, ticket_id):
|
def delete_ticket(request, ticket_id):
|
||||||
ticket = get_object_or_404(Ticket, id=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)
|
tickets_base = get_query(urlsafe_query, huser)
|
||||||
|
|
||||||
user_saved_queries = SavedSearch.objects.filter(Q(user=request.user) | Q(shared__exact=True))
|
user_saved_queries = SavedSearch.objects.filter(Q(user=request.user) | Q(shared__exact=True))
|
||||||
|
|
||||||
ticket_qs = None
|
ticket_qs = None
|
||||||
try:
|
try:
|
||||||
ticket_qs = apply_query(tickets_base, query_params)
|
ticket_qs = apply_query(tickets_base, query_params)
|
||||||
@ -931,7 +933,6 @@ def ticket_list(request):
|
|||||||
'<a href="http://docs.djangoproject.com/en/dev/ref/databases/#sqlite-string-matching">'
|
'<a href="http://docs.djangoproject.com/en/dev/ref/databases/#sqlite-string-matching">'
|
||||||
'Django Documentation on string matching in SQLite</a>.')
|
'Django Documentation on string matching in SQLite</a>.')
|
||||||
|
|
||||||
|
|
||||||
return render(request, 'helpdesk/ticket_list.html', dict(
|
return render(request, 'helpdesk/ticket_list.html', dict(
|
||||||
context,
|
context,
|
||||||
tickets=ticket_qs,
|
tickets=ticket_qs,
|
||||||
|
Loading…
Reference in New Issue
Block a user