equal
deleted
inserted
replaced
25 |
25 |
26 from django import forms |
26 from django import forms |
27 |
27 |
28 from soc.logic import validate |
28 from soc.logic import validate |
29 from soc.logic.models import user as user_logic |
29 from soc.logic.models import user as user_logic |
30 |
|
31 |
|
32 def clean_new_link_id(logic): |
|
33 """Clean method for new link_id's |
|
34 |
|
35 Returns a clean method that checks if the specified link_id is |
|
36 in the proper format, and verifies that the link_id is not already in |
|
37 in use by another entity of the same type. |
|
38 """ |
|
39 |
|
40 def wrapped(self): |
|
41 # convert to lowercase for user comfort |
|
42 link_id = self.cleaned_data.get('link_id').lower() |
|
43 if not validate.isLinkIdFormatValid(link_id): |
|
44 raise forms.ValidationError("This link ID is in wrong format.") |
|
45 if logic.getFromFields(link_id=link_id): |
|
46 raise forms.ValidationError("This link ID is already in use.") |
|
47 return link_id |
|
48 |
|
49 return wrapped |
|
50 |
30 |
51 |
31 |
52 def clean_link_id(self): |
32 def clean_link_id(self): |
53 # convert to lowercase for user comfort |
33 # convert to lowercase for user comfort |
54 link_id = self.cleaned_data.get('link_id').lower() |
34 link_id = self.cleaned_data.get('link_id').lower() |