#NEWLINE# @ login_required ( ) #NEWLINE# def edit( request , id ) : #NEWLINE# #INDENT# try : #NEWLINE# #INDENT# service = Service . objects . get ( id = id ) #NEWLINE# try : #NEWLINE# #INDENT# api_keys = ServiceTokens . objects . filter ( service_id = service ) #NEWLINE# #UNINDENT# except ServiceTokens . DoesNotExist : #NEWLINE# #INDENT# api_keys = [ ] #NEWLINE# #UNINDENT# try : #NEWLINE# #INDENT# ss_obj = ServiceSilenced . objects . get ( service = policy ) #NEWLINE# service_silenced = str ( ( ss_obj . silenced_until - timezone . now ( ) ) ) . split ( '.' ) [ 0 ] #NEWLINE# #UNINDENT# except ServiceSilenced . DoesNotExist : #NEWLINE# #INDENT# service_silenced = False #NEWLINE# #UNINDENT# policy = ( service . policy if service . policy else None ) #NEWLINE# all_polcies = SchedulePolicy . objects . all ( ) #NEWLINE# return TemplateResponse ( request , 'services/edit.html' , { #NEWLINE# #INDENT# 'item' : service , #NEWLINE# 'policy' : policy , #NEWLINE# 'policies' : all_polcies , #NEWLINE# 'api_keys' : api_keys , #NEWLINE# 'service_silenced' : service_silenced , #NEWLINE# 'url' : request . get_full_path ( ) , #NEWLINE# #UNINDENT# } ) #NEWLINE# #UNINDENT# except Service . DoesNotExist : #NEWLINE# #INDENT# raise Http404