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')
|
label=u'Summary of the problem')
|
||||||
|
|
||||||
submitter_email = forms.EmailField(required=False,
|
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(),
|
body = forms.CharField(widget=forms.Textarea(),
|
||||||
label=u'Description of Issue', required=True)
|
label=u'Description of Issue', required=True)
|
||||||
|
|
||||||
assigned_to = forms.ChoiceField(choices=(), required=False,
|
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,
|
priority = forms.ChoiceField(choices=Ticket.PRIORITY_CHOICES,
|
||||||
required=False,
|
required=False,
|
||||||
initial='3',
|
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):
|
def save(self, user):
|
||||||
"""
|
"""
|
||||||
@ -59,14 +62,16 @@ class TicketForm(forms.Form):
|
|||||||
|
|
||||||
"""
|
"""
|
||||||
q = Queue.objects.get(id=int(self.cleaned_data['queue']))
|
q = Queue.objects.get(id=int(self.cleaned_data['queue']))
|
||||||
t = Ticket( title=self.cleaned_data['title'],
|
|
||||||
submitter_email=self.cleaned_data['submitter_email'],
|
t = Ticket( title = self.cleaned_data['title'],
|
||||||
created=datetime.now(),
|
submitter_email = self.cleaned_data['submitter_email'],
|
||||||
|
created = datetime.now(),
|
||||||
status = Ticket.OPEN_STATUS,
|
status = Ticket.OPEN_STATUS,
|
||||||
queue = q,
|
queue = q,
|
||||||
description = self.cleaned_data['body'],
|
description = self.cleaned_data['body'],
|
||||||
priority = self.cleaned_data['priority'],
|
priority = self.cleaned_data['priority'],
|
||||||
)
|
)
|
||||||
|
|
||||||
if self.cleaned_data['assigned_to']:
|
if self.cleaned_data['assigned_to']:
|
||||||
try:
|
try:
|
||||||
u = User.objects.get(id=self.cleaned_data['assigned_to'])
|
u = User.objects.get(id=self.cleaned_data['assigned_to'])
|
||||||
@ -75,16 +80,25 @@ class TicketForm(forms.Form):
|
|||||||
t.assigned_to = None
|
t.assigned_to = None
|
||||||
t.save()
|
t.save()
|
||||||
|
|
||||||
f = FollowUp( ticket=t,
|
f = FollowUp( ticket = t,
|
||||||
title='Ticket Opened',
|
title = 'Ticket Opened',
|
||||||
date=datetime.now(),
|
date = datetime.now(),
|
||||||
public=True,
|
public = True,
|
||||||
comment=self.cleaned_data['body'],
|
comment = self.cleaned_data['body'],
|
||||||
user=user,
|
user = user,
|
||||||
)
|
)
|
||||||
if self.cleaned_data['assigned_to']:
|
if self.cleaned_data['assigned_to']:
|
||||||
f.title = 'Ticket Opened & Assigned to %s' % t.get_assigned_to
|
f.title = 'Ticket Opened & Assigned to %s' % t.get_assigned_to
|
||||||
|
|
||||||
f.save()
|
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
|
return t
|
||||||
|
@ -37,6 +37,16 @@ label {
|
|||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
span.form_optional {
|
||||||
|
color: #666;
|
||||||
|
font-size: 95%;
|
||||||
|
}
|
||||||
|
|
||||||
|
dd.form_help_text {
|
||||||
|
color: #666;
|
||||||
|
font-size: 95%;
|
||||||
|
}
|
||||||
|
|
||||||
.row_tablehead {
|
.row_tablehead {
|
||||||
background-color: #6593C0;
|
background-color: #6593C0;
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
|
@ -4,6 +4,8 @@
|
|||||||
{% block helpdesk_body %}
|
{% block helpdesk_body %}
|
||||||
<h2>Submit a Ticket</h2>
|
<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='./'>
|
<form method='post' action='./'>
|
||||||
<fieldset>
|
<fieldset>
|
||||||
<dl>
|
<dl>
|
||||||
@ -17,29 +19,32 @@
|
|||||||
{% if form.title.errors %}
|
{% if form.title.errors %}
|
||||||
<dd class='error'>{{ form.title.errors }}</dd>{% endif %}
|
<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>
|
<dd>{{ form.submitter_email }}</dd>
|
||||||
{% if form.submitter_email.errors %}
|
{% if form.submitter_email.errors %}
|
||||||
<dd class='error'>{{ form.submitter_email.errors }}</dd>{% endif %}
|
<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>
|
<dt><label for='id_body'>{{ form.body.label }}</label></dt>
|
||||||
<dd>{{ form.body }}</dd>
|
<dd>{{ form.body }}</dd>
|
||||||
{% if form.body.errors %}
|
{% if form.body.errors %}
|
||||||
<dd class='error'>{{ form.body.errors }}</dd>{% endif %}
|
<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>
|
<dd>{{ form.assigned_to }}</dd>
|
||||||
{% if form.assigned_to.errors %}
|
{% if form.assigned_to.errors %}
|
||||||
<dd class='error'>{{ form.assigned_to.errors }}</dd>{% endif %}
|
<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>
|
<dt><label for='id_priority'>{{ form.priority.label }}</label></dt>
|
||||||
<dd>{{ form.priority }}</dd>
|
<dd>{{ form.priority }}</dd>
|
||||||
{% if form.priority.errors %}
|
{% if form.priority.errors %}
|
||||||
<dd class='error'>{{ form.priority.errors }}</dd>{% endif %}
|
<dd class='error'>{{ form.priority.errors }}</dd>{% endif %}
|
||||||
|
<dd class='form_help_text'>{{ form.priority.help_text }}</dd>
|
||||||
</dl>
|
</dl>
|
||||||
|
|
||||||
<div class='buttons'>
|
<div class='buttons'>
|
||||||
<input type='submit' value='Submit' />
|
<input type='submit' value='Submit Ticket' />
|
||||||
</div>
|
</div>
|
||||||
</fieldset>
|
</fieldset>
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user