Reverted r1819 and making an application will now reserve the link_id indefinitely.
authorLennard de Rijk <ljvderijk@gmail.com>
Thu, 05 Feb 2009 19:30:43 +0000
changeset 1217 aeabe6bed55b
parent 1216 ec4f1dd84b39
child 1218 569a3fe9cb88
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
app/soc/logic/cleaning.py
app/soc/views/models/group_app.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:
--- 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']