mirror of
https://gitea.mueller.network/extern/django-helpdesk.git
synced 2024-11-21 15:33:09 +01:00
Order dependend ticket with NotIn ORM operator instead of itertools
This commit is contained in:
parent
887483a6d6
commit
b52ab69c42
@ -11,3 +11,7 @@ class HelpdeskConfig(AppConfig):
|
|||||||
|
|
||||||
def ready(self):
|
def ready(self):
|
||||||
from . import webhooks # noqa: F401
|
from . import webhooks # noqa: F401
|
||||||
|
|
||||||
|
from django.db.models.fields import Field
|
||||||
|
from helpdesk.orm_operators import NotIn
|
||||||
|
Field.register_lookup(NotIn)
|
||||||
|
7
helpdesk/orm_operators.py
Normal file
7
helpdesk/orm_operators.py
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
from django.db.models.lookups import In
|
||||||
|
|
||||||
|
class NotIn(In):
|
||||||
|
lookup_name = "not_in"
|
||||||
|
|
||||||
|
def get_rhs_op(self, connection, rhs):
|
||||||
|
return "NOT IN %s" % rhs
|
@ -424,11 +424,9 @@ def view_ticket(request, ticket_id):
|
|||||||
|
|
||||||
return redirect('helpdesk:edit_ticket_checklist', ticket.id, checklist.id)
|
return redirect('helpdesk:edit_ticket_checklist', ticket.id, checklist.id)
|
||||||
|
|
||||||
open_dependencies = ticket.ticketdependency.filter(depends_on__status__in=Ticket.OPEN_STATUSES)
|
# Open tickets on top
|
||||||
dependencies = [d for d in itertools.chain(
|
dependencies = list(ticket.ticketdependency.filter(depends_on__status__in=Ticket.OPEN_STATUSES)) \
|
||||||
open_dependencies,
|
+ list(ticket.ticketdependency.filter(depends_on__status__not_in=Ticket.OPEN_STATUSES))
|
||||||
ticket.ticketdependency.all().difference(open_dependencies)
|
|
||||||
)]
|
|
||||||
|
|
||||||
return render(request, 'helpdesk/ticket.html', {
|
return render(request, 'helpdesk/ticket.html', {
|
||||||
'ticket': ticket,
|
'ticket': ticket,
|
||||||
|
Loading…
Reference in New Issue
Block a user