Write a FollowUp when opening a ticket, which contains the user-submitted body of the ticket.

This commit is contained in:
Ross Poulton 2007-12-28 03:29:45 +00:00
parent ab77356cd7
commit 7ccda25867
2 changed files with 14 additions and 2 deletions

View File

@ -47,7 +47,7 @@ class TicketForm(forms.Form):
assigned_to = forms.ChoiceField(choices=(), required=False,
label=u'Case owner')
def save(self):
def save(self, user):
"""
Writes and returns a Ticket() object
@ -64,4 +64,16 @@ class TicketForm(forms.Form):
t.assigned_to = self.cleaned_data['assigned_to']
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

View File

@ -171,7 +171,7 @@ def create_ticket(request):
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)]
if form.is_valid():
ticket = form.save()
ticket = form.save(user=request.user)
return HttpResponseRedirect(ticket.get_absolute_url())
else:
form = TicketForm()