68 raise forms.ValidationError("This link ID is in wrong format.") |
68 raise forms.ValidationError("This link ID is in wrong format.") |
69 |
69 |
70 properties = {'link_id': link_id} |
70 properties = {'link_id': link_id} |
71 user = soc.logic.models.user.logic.getForFields(properties, unique=True) |
71 user = soc.logic.models.user.logic.getForFields(properties, unique=True) |
72 |
72 |
73 link_id_user = soc.logic.models.user.logic.getForFields(properties, unique=True) |
73 link_id_user = soc.logic.models.user.logic.getForFields(properties, |
74 |
74 unique=True) |
75 key_name = self.data.get('key_name') |
75 key_name = self.data.get('key_name') |
76 if key_name: |
76 if key_name: |
77 key_name_user = user_logic.logic.getFromKeyName(key_name) |
77 key_name_user = user_logic.logic.getFromKeyName(key_name) |
78 |
78 |
79 if link_id_user and key_name_user and \ |
79 if (link_id_user and key_name_user |
80 link_id_user.account != key_name_user.account: |
80 and (link_id_user.account != key_name_user.account)): |
81 raise forms.ValidationError("This link ID is already in use.") |
81 raise forms.ValidationError("This link ID is already in use.") |
82 |
82 |
83 return link_id |
83 return link_id |
84 |
84 |
85 def clean_email(self): |
85 def clean_email(self): |
115 """ |
115 """ |
116 #: db.Model subclass for which the form will gather information |
116 #: db.Model subclass for which the form will gather information |
117 model = soc.models.user.User |
117 model = soc.models.user.User |
118 |
118 |
119 #: list of model fields which will *not* be gathered by the form |
119 #: list of model fields which will *not* be gathered by the form |
120 exclude = ['account', 'former_accounts', 'is_developer'] |
120 exclude = ['account', 'former_accounts', 'is_developer', |
|
121 'inheritance_line'] |
121 |
122 |
122 def clean_link_id(self): |
123 def clean_link_id(self): |
123 link_id = self.cleaned_data.get('link_id') |
124 link_id = self.cleaned_data.get('link_id') |
124 if not validate.isLinkIdFormatValid(link_id): |
125 if not validate.isLinkIdFormatValid(link_id): |
125 raise forms.ValidationError("This link ID is in wrong format.") |
126 raise forms.ValidationError("This link ID is in wrong format.") |
229 # check if user account is not in former_accounts |
230 # check if user account is not in former_accounts |
230 # if it is show error message that account is invalid |
231 # if it is show error message that account is invalid |
231 if soc.logic.models.user.logic.isFormerAccount(account): |
232 if soc.logic.models.user.logic.isFormerAccount(account): |
232 msg = DEF_USER_ACCOUNT_INVALID_MSG |
233 msg = DEF_USER_ACCOUNT_INVALID_MSG |
233 error = out_of_band.ErrorResponse(msg) |
234 error = out_of_band.ErrorResponse(msg) |
234 return simple.errorResponse(request, page_name, error, template, context) |
235 return simple.errorResponse(request, page_name, error, template, |
235 |
236 context) |
236 user = soc.logic.models.user.logic.updateOrCreateFromFields(properties, {'link_id': new_link_id}) |
237 |
|
238 user = soc.logic.models.user.logic.updateOrCreateFromFields( |
|
239 properties, {'link_id': new_link_id}) |
237 |
240 |
238 # redirect to /user/profile?s=0 |
241 # redirect to /user/profile?s=0 |
239 # (causes 'Profile saved' message to be displayed) |
242 # (causes 'Profile saved' message to be displayed) |
240 return helper.responses.redirectToChangedSuffix( |
243 return helper.responses.redirectToChangedSuffix( |
241 request, None, params=params['edit_params']) |
244 request, None, params=params['edit_params']) |