Merge pull request #406 from mrkiwi-nz/master

Fix Issue #404: Refactor converting query string into queue:id
This commit is contained in:
Ross Poulton 2016-06-26 19:28:48 +10:00 committed by GitHub
commit d65c32487c
3 changed files with 10 additions and 5 deletions

View File

@ -562,6 +562,14 @@ class Ticket(models.Model):
super(Ticket, self).save(*args, **kwargs)
@classmethod
def queue_and_id_from_query(klass, query):
# Apply the opposite logic here compared to self._get_ticket_for_url
# Ensure that queues with '-' in them will work
parts = query.split('-')
queue = '-'.join(parts[0:-1])
return queue, parts[-1]
class FollowUpManager(models.Manager):
def private_followups(self):

View File

@ -78,10 +78,7 @@ def view_ticket(request):
error_message = ''
if ticket_req and email:
parts = ticket_req.split('-')
queue = '-'.join(parts[0:-1])
ticket_id = parts[-1]
queue, ticket_id = Ticket.queue_and_id_from_query(ticket_req)
try:
ticket = Ticket.objects.get(id=ticket_id, submitter_email__iexact=email)
except:

View File

@ -739,7 +739,7 @@ def ticket_list(request):
filter = None
if query.find('-') > 0:
try:
queue, id = query.split('-')
queue, id = Ticket.queue_and_id_from_query(query)
id = int(id)
except ValueError:
id = None