mirror of
https://github.com/django-helpdesk/django-helpdesk.git
synced 2024-12-14 10:51:21 +01:00
UPDATED: Use <forms.TicketCCForm> when subscribing to a ticket followups.
This commit is contained in:
parent
e4337cef1d
commit
380723a972
@ -339,29 +339,35 @@ def return_ticketccstring_and_show_subscribe(user, ticket):
|
|||||||
|
|
||||||
return ticketcc_string, SHOW_SUBSCRIBE
|
return ticketcc_string, SHOW_SUBSCRIBE
|
||||||
|
|
||||||
def subscribe_to_ticket_updates(ticket, user=None, email=''):
|
def subscribe_to_ticket_updates(ticket, user=None, email=None, can_view=True, can_update=False):
|
||||||
|
|
||||||
try:
|
try:
|
||||||
EmailValidator()(email)
|
EmailValidator()(email)
|
||||||
except ValidationError:
|
except ValidationError:
|
||||||
email = ''
|
email = None
|
||||||
|
|
||||||
|
data = {
|
||||||
|
'ticket': ticket,
|
||||||
|
'user': user,
|
||||||
|
'email': email,
|
||||||
|
'can_view': can_view,
|
||||||
|
'can_update': can_update
|
||||||
|
}
|
||||||
|
|
||||||
ticketcc = TicketCC()
|
ticket_cc_form = TicketCCForm(data)
|
||||||
ticketcc.ticket = ticket
|
if ticket_cc_form.is_valid():
|
||||||
ticketcc.user = user
|
return ticket_cc_form.save()
|
||||||
ticketcc.email = email
|
else:
|
||||||
ticketcc.can_view = True
|
raise ValidationError(
|
||||||
ticketcc.can_update = True
|
_('Could not create subscribe contact to ticket updated. Errors: {}'.format(ticket_cc_form.errors))
|
||||||
ticketcc.save()
|
)
|
||||||
|
|
||||||
return ticketcc
|
|
||||||
|
|
||||||
def subscribe_staff_member_to_ticket(ticket, user, email=''):
|
def subscribe_staff_member_to_ticket(ticket, user, email=''):
|
||||||
|
|
||||||
''' used in view_ticket() and update_ticket() '''
|
''' used in view_ticket() and update_ticket() '''
|
||||||
|
|
||||||
return subscribe_to_ticket_updates(ticket=ticket, user=user)
|
return subscribe_to_ticket_updates(ticket=ticket, user=user, email=email, can_view=can_view, can_update=can_update)
|
||||||
|
|
||||||
|
|
||||||
def update_ticket(request, ticket_id, public=False):
|
def update_ticket(request, ticket_id, public=False):
|
||||||
|
Loading…
Reference in New Issue
Block a user