UPDATED: Better validation before creating a duplicated TicketCC

This commit is contained in:
Bruno Tikami 2016-02-19 13:01:39 -02:00
parent 6d890509a3
commit 32ee4de50b
2 changed files with 5 additions and 3 deletions

View File

@ -198,7 +198,9 @@ def create_object_from_email_message(message, ticket_id, payload, files, quiet):
if in_reply_to is not None: if in_reply_to is not None:
try: try:
previous_followup = FollowUp.objects.get(message_id=in_reply_to) queryset = FollowUp.objects.filter(message_id=in_reply_to).order_by('-date')
if queryset.count() > 0:
previous_followup = queryset.first()
ticket = previous_followup.ticket ticket = previous_followup.ticket
except FollowUp.DoesNotExist: except FollowUp.DoesNotExist:
pass #play along. The header may be wrong pass #play along. The header may be wrong

View File

@ -348,7 +348,7 @@ def subscribe_to_ticket_updates(ticket, user=None, email=None, can_view=True, ca
} }
ticket_cc_form = TicketCCForm(data) ticket_cc_form = TicketCCForm(data)
if ticket_cc_form.is_valid(): if ticket is not None and ticket_cc_form.is_valid():
queryset = TicketCC.objects.filter(ticket=ticket, user=user, email=email) queryset = TicketCC.objects.filter(ticket=ticket, user=user, email=email)