# HG changeset patch # User Lennard de Rijk # Date 1233862243 0 # Node ID aeabe6bed55b317d2c902bbd92839437e183872f # Parent ec4f1dd84b39020620233528037d126477f54a7c Reverted r1819 and making an application will now reserve the link_id indefinitely. This is to make sure our statistics dont get messed up. Patch by: Lennard de Rijk Reviewed by: to-be-reviewed diff -r ec4f1dd84b39 -r aeabe6bed55b app/soc/logic/cleaning.py --- a/app/soc/logic/cleaning.py Wed Feb 04 23:09:28 2009 +0000 +++ b/app/soc/logic/cleaning.py Thu Feb 05 19:30:43 2009 +0000 @@ -251,13 +251,13 @@ """Clean method used to clean the group application or new group form. Raises ValidationError if: - -A valid application with this link id and scope path already exists - -A valid group with this link id and scope path already exists + -A application with this link id and scope path already exists + -A group with this link id and scope path already exists """ def wrapper(self): cleaned_data = self.cleaned_data - fields = {'status': ['accepted', 'ignored', 'needs review', 'completed']} + fields = {} link_id = cleaned_data.get(link_id_field) @@ -271,7 +271,12 @@ # get the application group_app_entity = group_app_logic.logic.getForFields(fields, unique=True) - if group_app_entity: + # get the current user + user_entity = user_logic.logic.getForCurrentAccount() + + # make sure it's not the applicant creating the new group + if group_app_entity and ( + group_app_entity.applicant.key() != user_entity.key()): # add the error message to the link id field self._errors[link_id_field] = ErrorList([DEF_LINK_ID_IN_USE_MSG]) del cleaned_data[link_id_field] @@ -279,7 +284,6 @@ return cleaned_data # check if there is already a group for the given fields - fields['status'] = ['new', 'active', 'inactive'] group_entity = group_logic.logic.getForFields(fields, unique=True) if group_entity: diff -r ec4f1dd84b39 -r aeabe6bed55b app/soc/views/models/group_app.py --- a/app/soc/views/models/group_app.py Wed Feb 04 23:09:28 2009 +0000 +++ b/app/soc/views/models/group_app.py Thu Feb 05 19:30:43 2009 +0000 @@ -111,19 +111,8 @@ """ if not entity: - # creating a new group application - key_fields = self._logic.getKeyFieldsFromFields(fields) - group_app_entity = self._logic.getForFields(key_fields, unique=True) - - user_entity = user_logic.logic.getForCurrentAccount() - - if group_app_entity and ( - group_app_entity.applicant.key() != user_entity.key()): - # someone else is applying remove the existing group application - group_app_logic.logic.delete(group_app_entity) - # set the applicant field to the current user - fields['applicant'] = user_entity + fields['applicant'] = user_logic.logic.getForCurrentAccount() #set the backup_admin field with the cleaned link_id fields['backup_admin'] = fields['backup_admin_link_id']