#NEWLINE# def post( self , group_id = None , name = None ) : #NEWLINE# #INDENT# group = Group . get ( self . session , group_id , name ) #NEWLINE# if ( not group ) : #NEWLINE# #INDENT# return self . notfound ( ) #NEWLINE# #UNINDENT# if ( not self . current_user . is_member ( group . my_members ( ) ) ) : #NEWLINE# #INDENT# return self . forbidden ( ) #NEWLINE# #UNINDENT# args_by_perm = get_grantable_permissions ( self . session , settings . restricted_ownership_permissions ) #NEWLINE# ( dropdown_form , text_form ) = GroupPermissionRequest . _get_forms ( args_by_perm , self . request . arguments ) #NEWLINE# argument_type = self . request . arguments . get ( 'argument_type' ) #NEWLINE# if ( argument_type and ( argument_type [ 0 ] == 'text' ) ) : #NEWLINE# #INDENT# form = text_form #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( argument_type and ( argument_type [ 0 ] == 'dropdown' ) ) : #NEWLINE# #INDENT# form = dropdown_form #NEWLINE# form . argument . choices = [ ( a , a ) for a in args_by_perm [ form . permission_name . data ] ] #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# self . log_message ( 'unknown argument type' , group_name = group . name , argument_type = argument_type ) #NEWLINE# return self . forbidden ( ) #NEWLINE# #UNINDENT# #UNINDENT# if ( not form . validate ( ) ) : #NEWLINE# #INDENT# return self . render ( 'group-permission-request.html' , dropdown_form = dropdown_form , text_form = text_form , group = group , args_by_perm_json = json . dumps ( args_by_perm ) , alerts = self . get_form_alerts ( form . errors ) , dropdown_help = settings . permission_request_dropdown_help , text_help = settings . permission_request_text_help ) #NEWLINE# #UNINDENT# permission = Permission . get ( self . session , name . permission_name . data ) #NEWLINE# assert ( permission is not None ) , 'our prefilled permission should exist or we have problems' #NEWLINE# try : #NEWLINE# #INDENT# permissions . create_request ( self . session , self . current_user , group , permission , form . argument . data , form . reason . data ) #NEWLINE# #UNINDENT# except permissions . RequestAlreadyGranted : #NEWLINE# #INDENT# alerts = [ Alert ( 'danger' , 'This group already has this permission and argument.' ) ] #NEWLINE# #UNINDENT# except permissions . RequestAlreadyExists : #NEWLINE# #INDENT# alerts = [ Alert ( 'danger' , 'Request for permission and argument already exists, please wait patiently.' ) ] #NEWLINE# #UNINDENT# except permissions . NoOwnersAvailable : #NEWLINE# #INDENT# self . log_message ( 'prefilled perm+arg have no owner' , group_name = group . name , permission_name = permission . name , argument = form . argument . data ) #NEWLINE# alerts = [ Alert ( 'danger' , 'No owners available for requested permission and argument. If this error persists please contact an adminstrator.' ) ] #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# alerts = None #NEWLINE# #UNINDENT# if alerts : #NEWLINE# #INDENT# return self . render ( 'group-permission-request.html' , dropdown_form = dropdown_form , text_form = text_form , group = group , args_by_perm_json = json . dumps ( args_by_perm ) , alerts = alerts ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# return self . redirect ( '/groups/{}' . format ( group . name ) )