# HG changeset patch # User Lennard de Rijk # Date 1233670791 0 # Node ID 8060f33a164f07ecf866b630adfd13a3f6ed250d # Parent 0a4c1af700a050425b4bc417648df5747462457c Added removal of an existing group application when someone else is applying. This makes sure that the fields we do not collect via the form also get wiped when a rejected application is being redone by someone else. Patch by: Lennard de Rijk Reviewed by: to-be-reviewed diff -r 0a4c1af700a0 -r 8060f33a164f app/soc/views/models/group_app.py --- a/app/soc/views/models/group_app.py Tue Feb 03 13:50:41 2009 +0000 +++ b/app/soc/views/models/group_app.py Tue Feb 03 14:19:51 2009 +0000 @@ -110,10 +110,22 @@ """See base.View._editPost(). """ - fields['backup_admin'] = fields['backup_admin_link_id'] + 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 not entity: - fields['applicant'] = user_logic.logic.getForCurrentAccount() + if 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 + + #set the backup_admin field with the cleaned link_id + fields['backup_admin'] = fields['backup_admin_link_id'] # the application has either been created or edited so # the status needs to be set accordingly