File tree 1 file changed +13
-6
lines changed
1 file changed +13
-6
lines changed Original file line number Diff line number Diff line change 15
15
from warehouse import forms
16
16
17
17
18
- class CreateRoleForm (forms .Form ):
19
- username = wtforms .StringField (
20
- validators = [
21
- wtforms .validators .DataRequired (message = "Must specify a username" ),
22
- ]
23
- )
18
+ class RoleNameMixin :
24
19
25
20
role_name = wtforms .SelectField (
26
21
'Select a role' ,
@@ -33,6 +28,15 @@ class CreateRoleForm(forms.Form):
33
28
]
34
29
)
35
30
31
+
32
+ class UsernameMixin :
33
+
34
+ username = wtforms .StringField (
35
+ validators = [
36
+ wtforms .validators .DataRequired (message = "Must specify a username" ),
37
+ ]
38
+ )
39
+
36
40
def validate_username (self , field ):
37
41
userid = self .user_service .find_userid (field .data )
38
42
@@ -41,6 +45,9 @@ def validate_username(self, field):
41
45
"No user found with that username. Please try again."
42
46
)
43
47
48
+
49
+ class CreateRoleForm (RoleNameMixin , UsernameMixin , forms .Form ):
50
+
44
51
def __init__ (self , * args , user_service , ** kwargs ):
45
52
super ().__init__ (* args , ** kwargs )
46
53
self .user_service = user_service
You can’t perform that action at this time.
0 commit comments