#NEWLINE# def create_ticket( request ) : #NEWLINE# #INDENT# if helpdesk_settings . HELPDESK_STAFF_ONLY_TICKET_OWNERS : #NEWLINE# #INDENT# assignable_users = User . objects . filter ( is_active = True , is_staff = True ) . order_by ( User . USERNAME_FIELD ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# assignable_users = User . objects . filter ( is_active = True ) . order_by ( User . USERNAME_FIELD ) #NEWLINE# #UNINDENT# if ( request . method == 'POST' ) : #NEWLINE# #INDENT# form = TicketForm ( request . POST , request . FILES ) #NEWLINE# form . fields [ 'queue' ] . choices = ( [ ( '' , '--------' ) ] + [ [ q . id , q . title ] for q in Queue . objects . all ( ) ] ) #NEWLINE# form . fields [ 'assigned_to' ] . choices = ( [ ( '' , '--------' ) ] + [ [ u . id , u . get_username ( ) ] for u in assignable_users ] ) #NEWLINE# if form . is_valid ( ) : #NEWLINE# #INDENT# ticket = form . save ( user = request . user ) #NEWLINE# if _has_access_to_queue ( request . user , ticket . queue ) : #NEWLINE# #INDENT# return HttpResponseRedirect ( ticket . get_absolute_url ( ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# return HttpResponseRedirect ( reverse ( 'helpdesk_dashboard' ) ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# initial_data = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# if ( request . user . usersettings . settings . get ( 'use_email_as_submitter' , False ) and request . user . email ) : #NEWLINE# #INDENT# initial_data [ 'submitter_email' ] = request . user . email #NEWLINE# #UNINDENT# if ( 'queue' in request . GET ) : #NEWLINE# #INDENT# initial_data [ 'queue' ] = request . GET [ 'queue' ] #NEWLINE# #UNINDENT# form = TicketForm ( initial = initial_data ) #NEWLINE# form . fields [ 'queue' ] . choices = ( [ ( '' , '--------' ) ] + [ [ q . id , q . title ] for q in Queue . objects . all ( ) ] ) #NEWLINE# form . fields [ 'assigned_to' ] . choices = ( [ ( '' , '--------' ) ] + [ [ u . id , u . get_username ( ) ] for u in assignable_users ] ) #NEWLINE# if helpdesk_settings . HELPDESK_CREATE_TICKET_HIDE_ASSIGNED_TO : #NEWLINE# #INDENT# form . fields [ 'assigned_to' ] . widget = forms . HiddenInput ( ) #NEWLINE# #UNINDENT# #UNINDENT# return render_to_response ( 'helpdesk/create_ticket.html' , RequestContext ( request , { #NEWLINE# #INDENT# 'form' : form , #NEWLINE# #UNINDENT# } ) )