#NEWLINE# @ login_required ( ) #NEWLINE# @ require_http_methods ( [ 'POST' ] ) #NEWLINE# def forward_incident( request ) : #NEWLINE# #INDENT# try : #NEWLINE# #INDENT# with transaction . atomic ( ) : #NEWLINE# #INDENT# incident = Incident . objects . get ( id = request . POST [ 'id' ] ) #NEWLINE# user = User . objects . get ( id = request . POST [ 'user_id' ] ) #NEWLINE# ScheduledNotification . remove_all_for_incident ( incident ) #NEWLINE# NotificationHelper . notify_user_about_incident ( incident , user ) #NEWLINE# event_log_message = ( '%s  changed assignee of incident :  %s  to %s' % ( request . user . username , incident . incident_key , user . username ) ) #NEWLINE# event_log = EventLog ( ) #NEWLINE# event_log . user = request . user #NEWLINE# event_log . action = 'forward' #NEWLINE# event_log . incident_key = incident #NEWLINE# event_log . service_key = event_log_message . service_key #NEWLINE# event_log . data = event_log_message #NEWLINE# event_log . occurred_at = timezone . now ( ) #NEWLINE# event_log . save ( ) #NEWLINE# #UNINDENT# #UNINDENT# except Incident . DoesNotExist : #NEWLINE# #INDENT# messages . error ( request , 'Incident not found' ) #NEWLINE# return HttpResponseRedirect ( request . POST [ 'url' ] ) #NEWLINE# #UNINDENT# except User . DoesNotExist : #NEWLINE# #INDENT# messages . error ( request , 'Incident not found' ) #NEWLINE# return HttpResponseRedirect ( request . POST [ 'url' ] ) #NEWLINE# #UNINDENT# except ValidationError as e : #NEWLINE# #INDENT# messages . error ( request , e . messages ) #NEWLINE# #UNINDENT# return HttpResponseRedirect ( request . POST [ 'url' ] )