@@ -76,7 +76,7 @@ def add_machine_key():
76
76
expires = form .expires .data ,
77
77
readonly = form .readonly .data ,
78
78
comment = form .comment .data ,
79
- user_id = session ["user_id" ]
79
+ user_id = session ["user_id" ],
80
80
)
81
81
82
82
db .session .add (model )
@@ -87,10 +87,7 @@ def add_machine_key():
87
87
else :
88
88
for field , errors in form .errors .items ():
89
89
for error in errors :
90
- print (
91
- "Error in the %s field - %s"
92
- % (getattr (form , field ).label .text , error )
93
- )
90
+ print ("Error in the %s field - %s" % (getattr (form , field ).label .text , error ))
94
91
95
92
return render_template ("forms/machine_api_key.html" , form = form , generated_key = generated )
96
93
@@ -117,12 +114,8 @@ def delete_machine_key(key_id):
117
114
@admin_required
118
115
def user ():
119
116
form = UserForm (request .form )
120
- form .role_ids .choices = [
121
- (g .id , g .name ) for g in db .session .query (Role ).order_by ("name" )
122
- ]
123
- form .org_ids .choices = [
124
- (g .id , g .name ) for g in db .session .query (Organization ).order_by ("name" )
125
- ]
117
+ form .role_ids .choices = [(g .id , g .name ) for g in db .session .query (Role ).order_by ("name" )]
118
+ form .org_ids .choices = [(g .id , g .name ) for g in db .session .query (Organization ).order_by ("name" )]
126
119
127
120
if request .method == "POST" and form .validate ():
128
121
# test if user is unique
@@ -157,12 +150,8 @@ def user():
157
150
def edit_user (user_id ):
158
151
user = db .session .query (User ).get (user_id )
159
152
form = UserForm (request .form , obj = user )
160
- form .role_ids .choices = [
161
- (g .id , g .name ) for g in db .session .query (Role ).order_by ("name" )
162
- ]
163
- form .org_ids .choices = [
164
- (g .id , g .name ) for g in db .session .query (Organization ).order_by ("name" )
165
- ]
153
+ form .role_ids .choices = [(g .id , g .name ) for g in db .session .query (Role ).order_by ("name" )]
154
+ form .org_ids .choices = [(g .id , g .name ) for g in db .session .query (Organization ).order_by ("name" )]
166
155
167
156
if request .method == "POST" and form .validate ():
168
157
user .update (form )
@@ -233,9 +222,7 @@ def organization():
233
222
flash ("Organization saved" )
234
223
return redirect (url_for ("admin.organizations" ))
235
224
else :
236
- flash (
237
- "Organization {} already exists" .format (form .name .data ), "alert-danger"
238
- )
225
+ flash ("Organization {} already exists" .format (form .name .data ), "alert-danger" )
239
226
240
227
action_url = url_for ("admin.organization" )
241
228
return render_template (
@@ -391,9 +378,7 @@ def action():
391
378
return redirect (url_for ("admin.actions" ))
392
379
else :
393
380
flash (
394
- "Action with name {} or command {} already exists" .format (
395
- form .name .data , form .command .data
396
- ),
381
+ "Action with name {} or command {} already exists" .format (form .name .data , form .command .data ),
397
382
"alert-danger" ,
398
383
)
399
384
@@ -480,9 +465,7 @@ def community():
480
465
flash ("Community saved" , "alert-success" )
481
466
return redirect (url_for ("admin.communities" ))
482
467
else :
483
- flash (
484
- f"Community with name { form .name .data } already exists" , "alert-danger"
485
- )
468
+ flash (f"Community with name { form .name .data } already exists" , "alert-danger" )
486
469
487
470
community_url = url_for ("admin.community" )
488
471
return render_template (
@@ -527,9 +510,7 @@ def delete_community(community_id):
527
510
try :
528
511
db .session .commit ()
529
512
except IntegrityError :
530
- message = "Community {} is in use in some rules, can not be deleted!" .format (
531
- aname
532
- )
513
+ message = "Community {} is in use in some rules, can not be deleted!" .format (aname )
533
514
alert_type = "alert-danger"
534
515
535
516
flash (message , alert_type )
0 commit comments