forked from extern/django-helpdesk
Write a FollowUp when opening a ticket, which contains the user-submitted body of the ticket.
This commit is contained in:
parent
ab77356cd7
commit
7ccda25867
14
forms.py
14
forms.py
@ -47,7 +47,7 @@ class TicketForm(forms.Form):
|
|||||||
assigned_to = forms.ChoiceField(choices=(), required=False,
|
assigned_to = forms.ChoiceField(choices=(), required=False,
|
||||||
label=u'Case owner')
|
label=u'Case owner')
|
||||||
|
|
||||||
def save(self):
|
def save(self, user):
|
||||||
"""
|
"""
|
||||||
Writes and returns a Ticket() object
|
Writes and returns a Ticket() object
|
||||||
|
|
||||||
@ -64,4 +64,16 @@ class TicketForm(forms.Form):
|
|||||||
t.assigned_to = self.cleaned_data['assigned_to']
|
t.assigned_to = self.cleaned_data['assigned_to']
|
||||||
t.save()
|
t.save()
|
||||||
|
|
||||||
|
f = FollowUp( ticket=t,
|
||||||
|
title='Ticket Opened',
|
||||||
|
date=datetime.now(),
|
||||||
|
public=True,
|
||||||
|
comment=self.cleaned_data['body'],
|
||||||
|
user=user,
|
||||||
|
)
|
||||||
|
if self.cleaned_data['assigned_to']:
|
||||||
|
f.title = 'Ticket Opened & Assigned to %s' % self.cleaned_data['assigned_to']
|
||||||
|
|
||||||
|
f.save()
|
||||||
|
|
||||||
return t
|
return t
|
||||||
|
2
views.py
2
views.py
@ -171,7 +171,7 @@ def create_ticket(request):
|
|||||||
form.fields['queue'].choices = [('', '--------')] + [[q.id, q.title] for q in Queue.objects.all()]
|
form.fields['queue'].choices = [('', '--------')] + [[q.id, q.title] for q in Queue.objects.all()]
|
||||||
form.fields['assigned_to'].choices = [('', '--------')] + [[u.id, u.username] for u in User.objects.filter(is_active=True)]
|
form.fields['assigned_to'].choices = [('', '--------')] + [[u.id, u.username] for u in User.objects.filter(is_active=True)]
|
||||||
if form.is_valid():
|
if form.is_valid():
|
||||||
ticket = form.save()
|
ticket = form.save(user=request.user)
|
||||||
return HttpResponseRedirect(ticket.get_absolute_url())
|
return HttpResponseRedirect(ticket.get_absolute_url())
|
||||||
else:
|
else:
|
||||||
form = TicketForm()
|
form = TicketForm()
|
||||||
|
Loading…
Reference in New Issue
Block a user