forked from extern/django-helpdesk
* Improve ticket submission form by adding help text and flagging optional fields as such
* When submitting an e-mail, if a submitters e-mail is provided send them an e-mail
This commit is contained in:
parent
423b455fc1
commit
7932ace133
38
forms.py
38
forms.py
@ -40,18 +40,21 @@ class TicketForm(forms.Form):
|
||||
label=u'Summary of the problem')
|
||||
|
||||
submitter_email = forms.EmailField(required=False,
|
||||
label=u'Submitter E-Mail Address')
|
||||
label=u'Submitter E-Mail Address',
|
||||
help_text=u'This e-mail address will receive copies of all public updates to this ticket.')
|
||||
|
||||
body = forms.CharField(widget=forms.Textarea(),
|
||||
label=u'Description of Issue', required=True)
|
||||
|
||||
assigned_to = forms.ChoiceField(choices=(), required=False,
|
||||
label=u'Case owner')
|
||||
label=u'Case owner',
|
||||
help_text=u'If you select an owner other than yourself, they\'ll be e-mailed details of this ticket immediately.')
|
||||
|
||||
priority = forms.ChoiceField(choices=Ticket.PRIORITY_CHOICES,
|
||||
required=False,
|
||||
initial='3',
|
||||
label=u'Priority')
|
||||
label=u'Priority',
|
||||
help_text=u'Please select a priority carefully. If unsure, leave it as \'3\'.')
|
||||
|
||||
def save(self, user):
|
||||
"""
|
||||
@ -59,14 +62,16 @@ class TicketForm(forms.Form):
|
||||
|
||||
"""
|
||||
q = Queue.objects.get(id=int(self.cleaned_data['queue']))
|
||||
t = Ticket( title=self.cleaned_data['title'],
|
||||
submitter_email=self.cleaned_data['submitter_email'],
|
||||
created=datetime.now(),
|
||||
|
||||
t = Ticket( title = self.cleaned_data['title'],
|
||||
submitter_email = self.cleaned_data['submitter_email'],
|
||||
created = datetime.now(),
|
||||
status = Ticket.OPEN_STATUS,
|
||||
queue = q,
|
||||
description = self.cleaned_data['body'],
|
||||
priority = self.cleaned_data['priority'],
|
||||
)
|
||||
|
||||
if self.cleaned_data['assigned_to']:
|
||||
try:
|
||||
u = User.objects.get(id=self.cleaned_data['assigned_to'])
|
||||
@ -75,16 +80,25 @@ class TicketForm(forms.Form):
|
||||
t.assigned_to = None
|
||||
t.save()
|
||||
|
||||
f = FollowUp( ticket=t,
|
||||
title='Ticket Opened',
|
||||
date=datetime.now(),
|
||||
public=True,
|
||||
comment=self.cleaned_data['body'],
|
||||
user=user,
|
||||
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' % t.get_assigned_to
|
||||
|
||||
f.save()
|
||||
|
||||
context = {
|
||||
'ticket': t,
|
||||
'queue': q,
|
||||
}
|
||||
|
||||
if t.submitter_email:
|
||||
from helpdesk.lib import send_multipart_mail
|
||||
send_multipart_mail('helpdesk/emails/submitter_newticket', context, '%s %s' % (t.ticket, t.title), t.submitter_email,, q.from_address)
|
||||
|
||||
return t
|
||||
|
@ -37,6 +37,16 @@ label {
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
span.form_optional {
|
||||
color: #666;
|
||||
font-size: 95%;
|
||||
}
|
||||
|
||||
dd.form_help_text {
|
||||
color: #666;
|
||||
font-size: 95%;
|
||||
}
|
||||
|
||||
.row_tablehead {
|
||||
background-color: #6593C0;
|
||||
font-weight: bold;
|
||||
|
@ -4,6 +4,8 @@
|
||||
{% block helpdesk_body %}
|
||||
<h2>Submit a Ticket</h2>
|
||||
|
||||
<p>Unless otherwise stated, all fields are required. Please provide as descriptive a title and description as possible.</p>
|
||||
|
||||
<form method='post' action='./'>
|
||||
<fieldset>
|
||||
<dl>
|
||||
@ -17,29 +19,32 @@
|
||||
{% if form.title.errors %}
|
||||
<dd class='error'>{{ form.title.errors }}</dd>{% endif %}
|
||||
|
||||
<dt><label for='id_submitter_email'>{{ form.submitter_email.label }}</label></dt>
|
||||
<dt><label for='id_submitter_email'>{{ form.submitter_email.label }}</label> <span class='form_optional'>(Optional)</span></dt>
|
||||
<dd>{{ form.submitter_email }}</dd>
|
||||
{% if form.submitter_email.errors %}
|
||||
<dd class='error'>{{ form.submitter_email.errors }}</dd>{% endif %}
|
||||
<dd class='form_help_text'>{{ form.submitter_email.help_text }}</dd>
|
||||
|
||||
<dt><label for='id_body'>{{ form.body.label }}</label></dt>
|
||||
<dd>{{ form.body }}</dd>
|
||||
{% if form.body.errors %}
|
||||
<dd class='error'>{{ form.body.errors }}</dd>{% endif %}
|
||||
|
||||
<dt><label for='id_assigned_to'>{{ form.assigned_to.label }}</label></dt>
|
||||
<dt><label for='id_assigned_to'>{{ form.assigned_to.label }}</label> <span class='form_optional'>(Optional)</span></dt>
|
||||
<dd>{{ form.assigned_to }}</dd>
|
||||
{% if form.assigned_to.errors %}
|
||||
<dd class='error'>{{ form.assigned_to.errors }}</dd>{% endif %}
|
||||
<dd class='form_help_text'>{{ form.assigned_to.help_text }}</dd>
|
||||
|
||||
<dt><label for='id_priority'>{{ form.priority.label }}</label></dt>
|
||||
<dd>{{ form.priority }}</dd>
|
||||
{% if form.priority.errors %}
|
||||
<dd class='error'>{{ form.priority.errors }}</dd>{% endif %}
|
||||
<dd class='form_help_text'>{{ form.priority.help_text }}</dd>
|
||||
</dl>
|
||||
|
||||
<div class='buttons'>
|
||||
<input type='submit' value='Submit' />
|
||||
<input type='submit' value='Submit Ticket' />
|
||||
</div>
|
||||
</fieldset>
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user