2008-08-19 10:50:38 +02:00
"""
2011-01-26 00:08:41 +01:00
django - helpdesk - A Django powered ticket tracker for small enterprise .
2007-12-27 01:29:17 +01:00
2008-02-06 05:36:07 +01:00
( c ) Copyright 2008 Jutda . All Rights Reserved . See LICENSE for details .
2007-12-27 01:29:17 +01:00
2008-08-19 10:50:38 +02:00
forms . py - Definitions of newforms - based forms for creating and maintaining
2008-02-06 05:36:07 +01:00
tickets .
2007-12-27 01:29:17 +01:00
"""
2016-10-21 17:14:12 +02:00
from django . core . exceptions import ObjectDoesNotExist
2015-04-28 01:13:54 +02:00
try :
from StringIO import StringIO
except ImportError :
from io import StringIO
2008-08-19 10:50:38 +02:00
2008-08-12 01:24:18 +02:00
from django import forms
2011-11-19 09:34:07 +01:00
from django . forms import extras
2009-01-22 09:08:22 +01:00
from django . conf import settings
2016-10-18 15:37:57 +02:00
from django . utils . translation import ugettext_lazy as _
2016-10-21 17:14:12 +02:00
from django . contrib . auth import get_user_model
2013-01-23 01:35:18 +01:00
try :
from django . utils import timezone
2013-01-23 01:55:36 +01:00
except ImportError :
2013-01-23 01:35:18 +01:00
from datetime import datetime as timezone
2007-12-27 01:29:17 +01:00
2011-11-08 17:31:05 +01:00
from helpdesk . lib import send_templated_mail , safe_template_context
2016-10-21 17:14:12 +02:00
from helpdesk . models import ( Ticket , Queue , FollowUp , Attachment , IgnoreEmail , TicketCC ,
CustomField , TicketCustomFieldValue , TicketDependency )
2012-01-17 22:40:44 +01:00
from helpdesk import settings as helpdesk_settings
2008-08-19 10:50:38 +02:00
2016-10-21 17:14:12 +02:00
User = get_user_model ( )
2014-06-05 01:45:07 +02:00
class CustomFieldMixin ( object ) :
"""
Mixin that provides a method to turn CustomFields into an actual field
"""
2016-10-23 22:09:17 +02:00
2014-06-05 01:45:07 +02:00
def customfield_to_field ( self , field , instanceargs ) :
if field . data_type == ' varchar ' :
fieldclass = forms . CharField
instanceargs [ ' max_length ' ] = field . max_length
elif field . data_type == ' text ' :
fieldclass = forms . CharField
instanceargs [ ' widget ' ] = forms . Textarea
instanceargs [ ' max_length ' ] = field . max_length
elif field . data_type == ' integer ' :
fieldclass = forms . IntegerField
elif field . data_type == ' decimal ' :
fieldclass = forms . DecimalField
instanceargs [ ' decimal_places ' ] = field . decimal_places
instanceargs [ ' max_digits ' ] = field . max_length
elif field . data_type == ' list ' :
fieldclass = forms . ChoiceField
choices = field . choices_as_array
if field . empty_selection_list :
2016-10-21 17:14:12 +02:00
choices . insert ( 0 , ( ' ' , ' --------- ' ) )
2014-06-05 01:45:07 +02:00
instanceargs [ ' choices ' ] = choices
elif field . data_type == ' boolean ' :
fieldclass = forms . BooleanField
elif field . data_type == ' date ' :
fieldclass = forms . DateField
elif field . data_type == ' time ' :
fieldclass = forms . TimeField
elif field . data_type == ' datetime ' :
fieldclass = forms . DateTimeField
elif field . data_type == ' email ' :
fieldclass = forms . EmailField
elif field . data_type == ' url ' :
fieldclass = forms . URLField
elif field . data_type == ' ipaddress ' :
2016-10-30 08:38:49 +01:00
fieldclass = forms . GenericIPAddressField
2014-06-05 01:45:07 +02:00
elif field . data_type == ' slug ' :
fieldclass = forms . SlugField
2016-10-30 08:38:49 +01:00
else :
raise NameError ( " Unrecognized data_type %s " % field . data_type )
2014-06-05 01:45:07 +02:00
self . fields [ ' custom_ %s ' % field . name ] = fieldclass ( * * instanceargs )
2016-10-21 17:14:12 +02:00
2014-06-05 01:45:07 +02:00
class EditTicketForm ( CustomFieldMixin , forms . ModelForm ) :
2016-10-23 22:09:17 +02:00
2009-06-03 13:43:46 +02:00
class Meta :
model = Ticket
exclude = ( ' created ' , ' modified ' , ' status ' , ' on_hold ' , ' resolution ' , ' last_escalation ' , ' assigned_to ' )
2016-10-18 15:35:41 +02:00
2011-05-09 23:54:44 +02:00
def __init__ ( self , * args , * * kwargs ) :
"""
Add any custom fields that are defined to the form
"""
super ( EditTicketForm , self ) . __init__ ( * args , * * kwargs )
for field in CustomField . objects . all ( ) :
try :
current_value = TicketCustomFieldValue . objects . get ( ticket = self . instance , field = field )
initial_value = current_value . value
except TicketCustomFieldValue . DoesNotExist :
initial_value = None
instanceargs = {
2016-10-23 22:09:17 +02:00
' label ' : field . label ,
' help_text ' : field . help_text ,
' required ' : field . required ,
' initial ' : initial_value ,
}
2014-06-05 01:45:07 +02:00
self . customfield_to_field ( field , instanceargs )
2011-05-09 23:54:44 +02:00
def save ( self , * args , * * kwargs ) :
2016-10-18 15:35:41 +02:00
2011-05-09 23:54:44 +02:00
for field , value in self . cleaned_data . items ( ) :
if field . startswith ( ' custom_ ' ) :
2014-10-25 21:53:56 +02:00
field_name = field . replace ( ' custom_ ' , ' ' , 1 )
2011-05-09 23:54:44 +02:00
customfield = CustomField . objects . get ( name = field_name )
try :
cfv = TicketCustomFieldValue . objects . get ( ticket = self . instance , field = customfield )
2016-10-21 17:14:12 +02:00
except ObjectDoesNotExist :
2011-05-09 23:54:44 +02:00
cfv = TicketCustomFieldValue ( ticket = self . instance , field = customfield )
cfv . value = value
cfv . save ( )
2016-10-18 15:35:41 +02:00
2011-05-09 23:54:44 +02:00
return super ( EditTicketForm , self ) . save ( * args , * * kwargs )
2009-06-03 13:43:46 +02:00
2011-01-29 07:02:03 +01:00
class EditFollowUpForm ( forms . ModelForm ) :
2016-10-23 22:09:17 +02:00
2011-01-29 07:02:03 +01:00
class Meta :
model = FollowUp
exclude = ( ' date ' , ' user ' , )
2016-10-21 17:14:12 +02:00
def __init__ ( self , * args , * * kwargs ) :
""" Filter not openned tickets here. """
super ( EditFollowUpForm , self ) . __init__ ( * args , * * kwargs )
self . fields [ " ticket " ] . queryset = Ticket . objects . filter ( status__in = ( Ticket . OPEN_STATUS , Ticket . REOPENED_STATUS ) )
2016-10-30 08:39:06 +01:00
class AbstractTicketForm ( CustomFieldMixin , forms . Form ) :
"""
Contain all the common code and fields between " TicketForm " and
" PublicTicketForm " . This Form is not intended to be used directly .
"""
2008-08-19 10:50:38 +02:00
queue = forms . ChoiceField (
label = _ ( ' Queue ' ) ,
required = True ,
choices = ( )
2016-10-23 22:09:17 +02:00
)
2008-08-19 10:50:38 +02:00
title = forms . CharField (
max_length = 100 ,
required = True ,
2016-10-23 22:09:17 +02:00
widget = forms . TextInput ( attrs = { ' size ' : ' 60 ' } ) ,
2008-08-19 10:50:38 +02:00
label = _ ( ' Summary of the problem ' ) ,
2016-10-23 22:09:17 +02:00
)
2008-08-19 10:50:38 +02:00
body = forms . CharField (
2011-11-28 16:06:36 +01:00
widget = forms . Textarea ( attrs = { ' cols ' : 47 , ' rows ' : 15 } ) ,
2016-10-30 08:39:06 +01:00
label = _ ( ' Description of your issue ' ) ,
2008-08-19 10:50:38 +02:00
required = True ,
2016-10-30 08:39:06 +01:00
help_text = _ ( ' Please be as descriptive as possible and include all details ' ) ,
2016-10-23 22:09:17 +02:00
)
2008-08-19 10:50:38 +02:00
priority = forms . ChoiceField (
choices = Ticket . PRIORITY_CHOICES ,
2016-10-30 08:39:06 +01:00
required = True ,
2008-08-19 10:50:38 +02:00
initial = ' 3 ' ,
label = _ ( ' Priority ' ) ,
2016-10-30 08:39:06 +01:00
help_text = _ ( " Please select a priority carefully. If unsure, leave it as ' 3 ' . " ) ,
2016-10-23 22:09:17 +02:00
)
2008-08-19 10:50:38 +02:00
2012-01-20 21:48:38 +01:00
due_date = forms . DateTimeField (
widget = extras . SelectDateWidget ,
required = False ,
label = _ ( ' Due on ' ) ,
2016-10-23 22:09:17 +02:00
)
2012-01-20 21:48:38 +01:00
2009-01-22 09:08:22 +01:00
attachment = forms . FileField (
required = False ,
label = _ ( ' Attach File ' ) ,
help_text = _ ( ' You can attach a file such as a document or screenshot to this ticket. ' ) ,
2016-10-23 22:09:17 +02:00
)
2009-01-22 09:08:22 +01:00
2016-10-30 08:39:06 +01:00
def _add_form_custom_fields ( self , staff_only_filter = None ) :
if staff_only_filter is None :
queryset = CustomField . objects . all ( )
else :
queryset = CustomField . objects . filter ( staff_only = staff_only_filter )
for field in queryset :
2011-02-02 12:22:46 +01:00
instanceargs = {
2016-10-23 22:09:17 +02:00
' label ' : field . label ,
' help_text ' : field . help_text ,
' required ' : field . required ,
}
2014-06-05 01:45:07 +02:00
self . customfield_to_field ( field , instanceargs )
2011-02-02 12:22:46 +01:00
2016-10-30 08:39:06 +01:00
def _create_ticket ( self ) :
2007-12-27 01:29:17 +01:00
q = Queue . objects . get ( id = int ( self . cleaned_data [ ' queue ' ] ) )
2008-08-19 10:50:38 +02:00
2016-10-21 17:14:12 +02:00
t = Ticket ( title = self . cleaned_data [ ' title ' ] ,
submitter_email = self . cleaned_data [ ' submitter_email ' ] ,
created = timezone . now ( ) ,
status = Ticket . OPEN_STATUS ,
queue = q ,
description = self . cleaned_data [ ' body ' ] ,
priority = self . cleaned_data [ ' priority ' ] ,
due_date = self . cleaned_data [ ' due_date ' ] ,
)
2008-08-19 10:50:38 +02:00
2016-10-30 08:39:06 +01:00
return t , q
2016-10-18 15:35:41 +02:00
2016-10-30 08:39:06 +01:00
def _create_custom_fields ( self , ticket ) :
2011-02-02 12:22:46 +01:00
for field , value in self . cleaned_data . items ( ) :
if field . startswith ( ' custom_ ' ) :
2014-10-25 21:53:56 +02:00
field_name = field . replace ( ' custom_ ' , ' ' , 1 )
2016-10-30 08:39:06 +01:00
custom_field = CustomField . objects . get ( name = field_name )
cfv = TicketCustomFieldValue ( ticket = ticket ,
field = custom_field ,
2016-10-21 17:14:12 +02:00
value = value )
2011-02-02 12:22:46 +01:00
cfv . save ( )
2007-12-27 01:29:17 +01:00
2016-10-30 08:39:06 +01:00
def _create_follow_up ( self , ticket , title , user = None ) :
f = FollowUp ( ticket = ticket ,
title = title ,
2016-10-21 17:14:12 +02:00
date = timezone . now ( ) ,
public = True ,
comment = self . cleaned_data [ ' body ' ] ,
2007-12-28 04:29:45 +01:00
)
2016-10-30 08:39:06 +01:00
if user :
f . user = user
return f
2007-12-28 04:29:45 +01:00
2016-10-30 08:39:06 +01:00
def _attach_files_to_follow_up ( self , followup ) :
attachments = [ ]
2009-01-22 09:08:22 +01:00
if self . cleaned_data [ ' attachment ' ] :
import mimetypes
2016-10-30 08:39:06 +01:00
attachment = self . cleaned_data [ ' attachment ' ]
filename = attachment . name . replace ( ' ' , ' _ ' )
2009-01-22 09:08:22 +01:00
a = Attachment (
2016-10-30 08:39:06 +01:00
followup = followup ,
2009-01-22 09:08:22 +01:00
filename = filename ,
mime_type = mimetypes . guess_type ( filename ) [ 0 ] or ' application/octet-stream ' ,
2016-10-30 08:39:06 +01:00
size = attachment . size ,
2016-10-23 22:09:17 +02:00
)
2016-10-30 08:39:06 +01:00
a . file . save ( attachment . name , attachment , save = False )
2009-01-22 09:08:22 +01:00
a . save ( )
2016-10-18 15:35:41 +02:00
2016-10-30 08:39:06 +01:00
if attachment . size < getattr ( settings , ' MAX_EMAIL_ATTACHMENT_SIZE ' , 512000 ) :
2016-10-18 15:35:41 +02:00
# Only files smaller than 512kb (or as defined in
2009-01-22 09:08:22 +01:00
# settings.MAX_EMAIL_ATTACHMENT_SIZE) are sent via email.
2013-11-19 22:24:52 +01:00
try :
2016-10-30 08:39:06 +01:00
attachments . append ( [ a . filename , a . file ] )
2013-11-19 22:24:52 +01:00
except NotImplementedError :
pass
2016-10-30 08:39:06 +01:00
return attachments
2008-08-19 10:50:38 +02:00
2016-10-30 08:39:06 +01:00
@staticmethod
def _send_messages ( ticket , queue , followup , files , user = None ) :
context = safe_template_context ( ticket )
context [ ' comment ' ] = followup . comment
2016-10-18 15:35:41 +02:00
2009-08-11 11:02:48 +02:00
messages_sent_to = [ ]
2008-01-15 00:39:43 +01:00
2016-10-30 08:39:06 +01:00
if ticket . submitter_email :
2008-08-19 10:50:38 +02:00
send_templated_mail (
' newticket_submitter ' ,
context ,
2016-10-30 08:39:06 +01:00
recipients = ticket . submitter_email ,
sender = queue . from_address ,
2008-08-19 10:50:38 +02:00
fail_silently = True ,
2009-01-22 09:08:22 +01:00
files = files ,
2016-10-23 22:09:17 +02:00
)
2016-10-30 08:39:06 +01:00
messages_sent_to . append ( ticket . submitter_email )
2007-12-28 04:29:45 +01:00
2016-10-30 08:39:06 +01:00
if ticket . assigned_to and \
ticket . assigned_to != user and \
ticket . assigned_to . usersettings . settings . get ( ' email_on_ticket_assign ' , False ) and \
ticket . assigned_to . email and \
ticket . assigned_to . email not in messages_sent_to :
2008-08-19 10:50:38 +02:00
send_templated_mail (
' assigned_owner ' ,
context ,
2016-10-30 08:39:06 +01:00
recipients = ticket . assigned_to . email ,
sender = queue . from_address ,
2008-08-19 10:50:38 +02:00
fail_silently = True ,
2009-01-22 09:08:22 +01:00
files = files ,
2016-10-23 22:09:17 +02:00
)
2016-10-30 08:39:06 +01:00
messages_sent_to . append ( ticket . assigned_to . email )
2008-01-21 02:02:12 +01:00
2016-10-30 08:39:06 +01:00
if queue . new_ticket_cc and queue . new_ticket_cc not in messages_sent_to :
2008-08-19 10:50:38 +02:00
send_templated_mail (
' newticket_cc ' ,
context ,
2016-10-30 08:39:06 +01:00
recipients = queue . new_ticket_cc ,
sender = queue . from_address ,
2008-08-19 10:50:38 +02:00
fail_silently = True ,
2009-01-22 09:08:22 +01:00
files = files ,
2016-10-23 22:09:17 +02:00
)
2016-10-30 08:39:06 +01:00
messages_sent_to . append ( queue . new_ticket_cc )
2008-08-19 10:50:38 +02:00
2016-10-30 08:39:06 +01:00
if queue . updated_ticket_cc and \
queue . updated_ticket_cc != q . new_ticket_cc and \
queue . updated_ticket_cc not in messages_sent_to :
2008-08-19 10:50:38 +02:00
send_templated_mail (
' newticket_cc ' ,
context ,
2016-10-30 08:39:06 +01:00
recipients = queue . updated_ticket_cc ,
sender = queue . from_address ,
2008-08-19 10:50:38 +02:00
fail_silently = True ,
2009-01-22 09:08:22 +01:00
files = files ,
2016-10-23 22:09:17 +02:00
)
2008-01-21 02:02:12 +01:00
2008-08-19 10:50:38 +02:00
2016-10-30 08:39:06 +01:00
class TicketForm ( AbstractTicketForm ) :
"""
Ticket Form creation for registered users .
"""
2008-08-19 10:50:38 +02:00
submitter_email = forms . EmailField (
2012-01-20 21:48:38 +01:00
required = False ,
2016-10-30 08:39:06 +01:00
label = _ ( ' Submitter E-Mail Address ' ) ,
widget = forms . TextInput ( attrs = { ' size ' : ' 60 ' } ) ,
help_text = _ ( ' This e-mail address will receive copies of all public '
' updates to this ticket. ' ) ,
2016-10-23 22:09:17 +02:00
)
2012-01-20 21:48:38 +01:00
2016-10-30 08:39:06 +01:00
assigned_to = forms . ChoiceField (
choices = ( ) ,
2009-01-22 09:08:22 +01:00
required = False ,
2016-10-30 08:39:06 +01:00
label = _ ( ' Case owner ' ) ,
help_text = _ ( ' If you select an owner other than yourself, they \' ll be '
' e-mailed details of this ticket immediately. ' ) ,
2016-10-23 22:09:17 +02:00
)
2009-01-22 09:08:22 +01:00
2011-02-02 12:22:46 +01:00
def __init__ ( self , * args , * * kwargs ) :
"""
2016-10-30 08:39:06 +01:00
Add any custom fields that are defined to the form .
2011-02-02 12:22:46 +01:00
"""
2016-10-30 08:39:06 +01:00
super ( TicketForm , self ) . __init__ ( * args , * * kwargs )
self . _add_form_custom_fields ( )
2011-02-02 12:22:46 +01:00
2016-10-30 08:39:06 +01:00
def save ( self , user = None ) :
2008-01-16 01:26:24 +01:00
"""
Writes and returns a Ticket ( ) object
"""
2008-08-19 10:50:38 +02:00
2016-10-30 08:39:06 +01:00
t , q = self . _create_ticket ( )
if self . cleaned_data [ ' assigned_to ' ] :
try :
u = User . objects . get ( id = self . cleaned_data [ ' assigned_to ' ] )
t . assigned_to = u
except User . DoesNotExist :
t . assigned_to = None
2008-01-16 01:26:24 +01:00
t . save ( )
2016-10-30 08:39:06 +01:00
self . _create_custom_fields ( t )
2008-01-16 01:26:24 +01:00
2016-10-30 08:39:06 +01:00
if self . cleaned_data [ ' assigned_to ' ] :
title = _ ( ' Ticket Opened & Assigned to %(name)s ' ) % {
' name ' : t . get_assigned_to or _ ( " <invalid user> " )
}
else :
title = _ ( ' Ticket Opened ' )
f = self . _create_follow_up ( t , title = title , user = user )
2008-01-16 01:26:24 +01:00
f . save ( )
2008-08-19 10:50:38 +02:00
2016-10-30 08:39:06 +01:00
files = self . _attach_files_to_follow_up ( f )
self . _send_messages ( ticket = t , queue = q , followup = f , files = files , user = user )
return t
2016-10-18 15:35:41 +02:00
2009-01-22 09:08:22 +01:00
2016-10-30 08:39:06 +01:00
class PublicTicketForm ( AbstractTicketForm ) :
"""
Ticket Form creation for all users ( public - facing ) .
"""
submitter_email = forms . EmailField (
required = True ,
label = _ ( ' Your E-Mail Address ' ) ,
help_text = _ ( ' We will e-mail you when your ticket is updated. ' ) ,
)
2008-01-16 01:26:24 +01:00
2016-10-30 08:39:06 +01:00
def __init__ ( self , * args , * * kwargs ) :
"""
Add any ( non - staff ) custom fields that are defined to the form
"""
super ( PublicTicketForm , self ) . __init__ ( * args , * * kwargs )
self . _add_form_custom_fields ( False )
2009-08-11 11:02:48 +02:00
2016-10-30 08:39:06 +01:00
def save ( self ) :
"""
Writes and returns a Ticket ( ) object
"""
t , q = self . _create_ticket ( )
if q . default_owner and not t . assigned_to :
t . assigned_to = q . default_owner
t . save ( )
2016-02-17 09:40:08 +01:00
2016-10-30 08:39:06 +01:00
self . _create_custom_fields ( t )
2008-08-19 10:50:38 +02:00
2016-10-30 08:39:06 +01:00
f = self . _create_follow_up ( t , title = _ ( ' Ticket Opened Via Web ' ) )
f . save ( )
2008-01-21 02:02:12 +01:00
2016-10-30 08:39:06 +01:00
files = self . _attach_files_to_follow_up ( f )
self . _send_messages ( ticket = t , queue = q , followup = f , files = files )
2008-01-16 01:26:24 +01:00
return t
2008-08-19 10:50:38 +02:00
2008-09-09 10:32:01 +02:00
class UserSettingsForm ( forms . Form ) :
login_view_ticketlist = forms . BooleanField (
label = _ ( ' Show Ticket List on Login? ' ) ,
help_text = _ ( ' Display the ticket list upon login? Otherwise, the dashboard is shown. ' ) ,
required = False ,
2016-10-23 22:09:17 +02:00
)
2008-09-09 10:32:01 +02:00
email_on_ticket_change = forms . BooleanField (
label = _ ( ' E-mail me on ticket change? ' ) ,
help_text = _ ( ' If you \' re the ticket owner and the ticket is changed via the web by somebody else, do you want to receive an e-mail? ' ) ,
required = False ,
2016-10-23 22:09:17 +02:00
)
2008-09-09 10:32:01 +02:00
email_on_ticket_assign = forms . BooleanField (
label = _ ( ' E-mail me when assigned a ticket? ' ) ,
help_text = _ ( ' If you are assigned a ticket via the web, do you want to receive an e-mail? ' ) ,
required = False ,
2016-10-23 22:09:17 +02:00
)
2008-09-09 10:32:01 +02:00
2009-07-22 10:19:46 +02:00
tickets_per_page = forms . IntegerField (
label = _ ( ' Number of tickets to show per page ' ) ,
help_text = _ ( ' How many tickets do you want to see on the Ticket List page? ' ) ,
required = False ,
min_value = 1 ,
max_value = 1000 ,
2016-10-23 22:09:17 +02:00
)
2009-07-22 10:19:46 +02:00
2009-08-06 10:56:02 +02:00
use_email_as_submitter = forms . BooleanField (
label = _ ( ' Use my e-mail address when submitting tickets? ' ) ,
help_text = _ ( ' When you submit a ticket, do you want to automatically use your e-mail address as the submitter address? You can type a different e-mail address when entering the ticket if needed, this option only changes the default. ' ) ,
required = False ,
2016-10-23 22:09:17 +02:00
)
2009-08-06 10:56:02 +02:00
2016-10-21 17:14:12 +02:00
2008-10-25 00:52:34 +02:00
class EmailIgnoreForm ( forms . ModelForm ) :
2016-10-23 22:09:17 +02:00
2008-10-25 00:52:34 +02:00
class Meta :
model = IgnoreEmail
2014-09-11 09:37:51 +02:00
exclude = [ ]
2009-09-09 10:47:48 +02:00
2016-10-21 17:14:12 +02:00
2009-09-09 10:47:48 +02:00
class TicketCCForm ( forms . ModelForm ) :
2016-10-23 22:09:17 +02:00
2016-10-21 17:14:12 +02:00
class Meta :
model = TicketCC
exclude = ( ' ticket ' , )
2011-02-06 18:49:07 +01:00
def __init__ ( self , * args , * * kwargs ) :
super ( TicketCCForm , self ) . __init__ ( * args , * * kwargs )
2012-01-17 22:40:44 +01:00
if helpdesk_settings . HELPDESK_STAFF_ONLY_TICKET_CC :
2014-10-22 07:18:04 +02:00
users = User . objects . filter ( is_active = True , is_staff = True ) . order_by ( User . USERNAME_FIELD )
2012-01-17 22:40:44 +01:00
else :
2014-10-22 07:18:04 +02:00
users = User . objects . filter ( is_active = True ) . order_by ( User . USERNAME_FIELD )
2016-10-18 15:35:41 +02:00
self . fields [ ' user ' ] . queryset = users
2016-10-21 17:14:12 +02:00
2011-02-06 18:49:07 +01:00
2011-05-10 11:27:11 +02:00
class TicketDependencyForm ( forms . ModelForm ) :
2016-10-23 22:09:17 +02:00
2011-05-10 11:27:11 +02:00
class Meta :
model = TicketDependency
exclude = ( ' ticket ' , )