equal
deleted
inserted
replaced
31 from soc.logic import validate |
31 from soc.logic import validate |
32 from soc.logic.models import site as site_logic |
32 from soc.logic.models import site as site_logic |
33 from soc.logic.models import user as user_logic |
33 from soc.logic.models import user as user_logic |
34 |
34 |
35 |
35 |
36 def clean_link_id(self): |
36 def clean_link_id(field_name): |
37 # convert to lowercase for user comfort |
37 """Checks if the field_name value is in a valid link ID format. |
38 link_id = self.cleaned_data.get('link_id').lower() |
38 """ |
39 if not validate.isLinkIdFormatValid(link_id): |
39 def wrapper(self): |
40 raise forms.ValidationError("This link ID is in wrong format.") |
40 # convert to lowercase for user comfort |
41 return link_id |
41 link_id = self.cleaned_data.get(field_name).lower() |
|
42 if not validate.isLinkIdFormatValid(link_id): |
|
43 raise forms.ValidationError("This link ID is in wrong format.") |
|
44 return link_id |
|
45 return wrapper |
42 |
46 |
43 |
47 |
44 def clean_agrees_to_tos(field_name): |
48 def clean_agrees_to_tos(field_name): |
45 """Checks if there is a ToS to see if it is allowed to leave |
49 """Checks if there is a ToS to see if it is allowed to leave |
46 the field_name field false. |
50 the field_name field false. |
66 def clean_existing_user(field_name): |
70 def clean_existing_user(field_name): |
67 """Check if the field_name field is a valid user. |
71 """Check if the field_name field is a valid user. |
68 """ |
72 """ |
69 |
73 |
70 def wrapped(self): |
74 def wrapped(self): |
71 link_id = self.cleaned_data.get(field_name).lower() |
75 link_id = clean_link_id(field_name)(self) |
72 |
|
73 if not validate.isLinkIdFormatValid(link_id): |
|
74 raise forms.ValidationError("This link ID is in wrong format.") |
|
75 |
76 |
76 user_entity = user_logic.logic.getForFields({'link_id': link_id}, |
77 user_entity = user_logic.logic.getForFields({'link_id': link_id}, |
77 unique=True) |
78 unique=True) |
78 |
79 |
79 if not user_entity: |
80 if not user_entity: |
88 """Check if the field_name value is a valid link_id and a user with the |
89 """Check if the field_name value is a valid link_id and a user with the |
89 link id does not exist. |
90 link id does not exist. |
90 """ |
91 """ |
91 |
92 |
92 def wrapped(self): |
93 def wrapped(self): |
93 link_id = self.cleaned_data.get(field_name).lower() |
94 link_id = clean_link_id(field_name)(self) |
94 |
|
95 if not validate.isLinkIdFormatValid(link_id): |
|
96 raise forms.ValidationError("This link ID is in wrong format.") |
|
97 |
95 |
98 user_entity = user_logic.logic.getForFields({'link_id': link_id}, |
96 user_entity = user_logic.logic.getForFields({'link_id': link_id}, |
99 unique=True) |
97 unique=True) |
100 |
98 |
101 if user_entity: |
99 if user_entity: |