Initial general clean-up of stuff

This commit is contained in:
Alex Barcelo
2016-10-21 17:14:12 +02:00
parent 5e340338b4
commit 24d88be8d9
27 changed files with 827 additions and 710 deletions

View File

@@ -56,7 +56,7 @@ class Command(BaseCommand):
queue_set = queue_slugs.split(',')
for queue in queue_set:
try:
q = Queue.objects.get(slug__exact=queue)
Queue.objects.get(slug__exact=queue)
except Queue.DoesNotExist:
raise CommandError("Queue %s does not exist." % queue)
queues.append(queue)
@@ -82,24 +82,23 @@ def escalate_tickets(queues, verbose):
days += 1
workdate = workdate + timedelta(days=1)
req_last_escl_date = date.today() - timedelta(days=days)
if verbose:
print("Processing: %s" % q)
for t in q.ticket_set.filter(
Q(status=Ticket.OPEN_STATUS)
| Q(status=Ticket.REOPENED_STATUS)
).exclude(
priority=1
).filter(
Q(on_hold__isnull=True)
| Q(on_hold=False)
).filter(
Q(last_escalation__lte=req_last_escl_date)
| Q(last_escalation__isnull=True, created__lte=req_last_escl_date)
):
Q(status=Ticket.OPEN_STATUS)
| Q(status=Ticket.REOPENED_STATUS)
).exclude(
priority=1
).filter(
Q(on_hold__isnull=True)
| Q(on_hold=False)
).filter(
Q(last_escalation__lte=req_last_escl_date)
| Q(last_escalation__isnull=True, created__lte=req_last_escl_date)
):
t.last_escalation = timezone.now()
t.priority -= 1
@@ -143,8 +142,8 @@ def escalate_tickets(queues, verbose):
)
f = FollowUp(
ticket = t,
title = 'Ticket Escalated',
ticket=t,
title='Ticket Escalated',
date=timezone.now(),
public=True,
comment=_('Ticket escalated after %s days' % q.escalate_days),
@@ -152,10 +151,10 @@ def escalate_tickets(queues, verbose):
f.save()
tc = TicketChange(
followup = f,
field = _('Priority'),
old_value = t.priority + 1,
new_value = t.priority,
followup=f,
field=_('Priority'),
old_value=t.priority + 1,
new_value=t.priority,
)
tc.save()