Replaced boolean properties in soc/models/group_app with status property.
authorLennard de Rijk <ljvderijk@gmail.com>
Wed, 21 Jan 2009 22:47:22 +0000
changeset 892 c3cdb581ffd2
parent 891 3d40190f35b6
child 893 2dba566e4bf8
Replaced boolean properties in soc/models/group_app with status property. This property has 5 choices ['accepted','rejected','ignored','needs review','completed'] Patch by: Lennard de Rijk Reviewed by: to-be-reviewed
app/soc/logic/models/club.py
app/soc/models/group_app.py
app/soc/templates/soc/club_app/review.html
app/soc/views/helper/access.py
app/soc/views/models/club_app.py
--- a/app/soc/logic/models/club.py	Wed Jan 21 22:21:40 2009 +0000
+++ b/app/soc/logic/models/club.py	Wed Jan 21 22:47:22 2009 +0000
@@ -65,7 +65,7 @@
         request_logic.logic.updateOrCreateFromFields(properties, key_fields)
 
       # set the application to completed  
-      fields = {'application_completed' : True}
+      fields = {'status' : 'completed'}
       club_app_logic.logic.updateModelProperties(application, fields)
 
 
--- a/app/soc/models/group_app.py	Wed Jan 21 22:21:40 2009 +0000
+++ b/app/soc/models/group_app.py	Wed Jan 21 22:47:22 2009 +0000
@@ -96,20 +96,14 @@
       ' Please be as specific as possible.'))
   member_criteria.help_text = ugettext_lazy(
     'Members include mentors, admininstrators, and the like.')
-  
-  # boolean to indicate if an application has been reviewed
-  reviewed = db.BooleanProperty(required=True, default=False,
-      verbose_name=ugettext_lazy('Has been reviewed')
-      )
-  # boolean to indicate if an application has been accepted
-  accepted = db.BooleanProperty(required=True, default=False,
-      verbose_name=ugettext_lazy('Has been accepted')
-      )
-  
-  # boolean to indicate that this application has been
-  # handled and turned into a group
-  application_completed = db.BooleanProperty(required=True, default=False,
-      verbose_name=ugettext_lazy('Has been completed'))
+
+  # property containing the status of the application
+  # completed means that the application has been processed into a real group
+  status = db.StringProperty(required=True, 
+      choices=['accepted','rejected','ignored','needs review','completed'],
+      default='needs review',
+      verbose_name=ugettext_lazy('Application Status'))
+
   
   # timestamp to record the time on which this application has been created
   created_on = db.DateTimeProperty(required=True, auto_now_add=True,
--- a/app/soc/templates/soc/club_app/review.html	Wed Jan 21 22:21:40 2009 +0000
+++ b/app/soc/templates/soc/club_app/review.html	Wed Jan 21 22:47:22 2009 +0000
@@ -31,9 +31,7 @@
   {% readonly_field_as_twoline_table_row entity.fields.irc_channel.label entity.irc_channel %}
   {% readonly_field_as_twoline_table_row entity.fields.backup_admin.label entity.backup_admin.link_id %}
   {% readonly_field_as_twoline_table_row entity.fields.member_criteria.label entity.member_criteria %}
-  {% readonly_field_as_table_row entity.fields.reviewed.label entity.reviewed %}
-  {% readonly_field_as_table_row entity.fields.accepted.label entity.accepted %}
-  {% readonly_field_as_table_row entity.fields.application_completed.label entity.application_completed %}
+  {% readonly_field_as_table_row entity.fields.status.label entity.status %}
   {% readonly_field_as_table_row "Created on" entity.created_on %}
   {% readonly_field_as_table_row "Last Modified on" entity.last_modified_on %}
  </table>
@@ -41,8 +39,9 @@
 
 <tr>
   <td>
-    <input type="button" onclick="location.href='/{{ entity_type_url|lower }}/review/{{ entity.link_id }}?accepted=true'" value="Accept"/>
-    <input type="button" onclick="location.href='/{{ entity_type_url|lower }}/review/{{ entity.link_id }}?accepted=false'" value="Deny"/>
+    <input type="button" onclick="location.href='/{{ entity_type_url|lower }}/review/{{ entity.link_id }}?status=accepted'" value="Accept"/>
+    <input type="button" onclick="location.href='/{{ entity_type_url|lower }}/review/{{ entity.link_id }}?status=rejected'" value="Reject"/>
+    <input type="button" onclick="location.href='/{{ entity_type_url|lower }}/review/{{ entity.link_id }}?status=ignored'" value="Ignore"/>
     <input type="button" onclick="location.href='/{{ entity_type_url|lower }}/delete/{{ entity.link_id }}'" value="Delete"/>
   </td>
 </tr>
--- a/app/soc/views/helper/access.py	Wed Jan 21 22:21:40 2009 +0000
+++ b/app/soc/views/helper/access.py	Wed Jan 21 22:47:22 2009 +0000
@@ -399,9 +399,7 @@
 
     properties = {
         'applicant': user,
-        'reviewed': True,
-        'accepted': True,
-        'application_completed': False,
+        'status': 'accepted'
         }
 
     application = app_logic.logic.getForFields(properties, unique=True)
--- a/app/soc/views/models/club_app.py	Wed Jan 21 22:21:40 2009 +0000
+++ b/app/soc/views/models/club_app.py	Wed Jan 21 22:47:22 2009 +0000
@@ -71,8 +71,7 @@
     new_params['create_template'] = 'soc/models/twoline_edit.html'
     new_params['edit_template'] = 'soc/models/twoline_edit.html'
 
-    new_params['extra_dynaexclude'] = ['applicant', 'backup_admin',
-        'reviewed', 'accepted', 'application_completed', 
+    new_params['extra_dynaexclude'] = ['applicant', 'backup_admin', 'status',
         'created_on', 'last_modified_on']
     new_params['create_extra_dynafields'] = {
         'backup_admin_link_id': forms.CharField(
@@ -121,8 +120,7 @@
     is_developer = accounts.isDeveloper(user=user_entity)
 
     filter = {
-        'application_completed': False,
-        'reviewed': False,
+        'status': 'needs review',
         }
 
     if not is_developer:
@@ -146,8 +144,7 @@
     # Get all the reviewed applications now
 
     # Re-use the old filter, but set to only reviewed and accepted
-    filter['reviewed'] = True
-    filter['accepted'] = True
+    filter['status'] = 'accepted'
 
     aa_params = params.copy() # accepted applications
 
@@ -164,10 +161,10 @@
     aa_list = list_helper.getListContent(
         request, aa_params, filter, 1)
 
-    # Get all the reviewd applications that were denied
+    # Get all the reviewed applications that were denied
 
     # Re use the old filter, but this time only for denied apps
-    filter['accepted'] = False
+    filter['status'] = 'rejected'
 
     da_params = params.copy() # denied applications
 
@@ -203,9 +200,8 @@
       fields['applicant'] = user_logic.logic.getForCurrentAccount()
 
     # the application has either been created or edited so
-    # the review status needs to be set accordingly
-    fields['reviewed'] = False
-    fields['accepted'] = False
+    # the status needs to be set accordingly
+    fields['status'] = 'needs review'
 
   def _public(self, request, entity, context):
     """See base._public().
@@ -241,24 +237,13 @@
     get_dict = request.GET
 
     # check to see if we can make a decision for this application
-    if 'accepted' in get_dict.keys():
-      accepted_value = get_dict['accepted']
-
-      fields = {'reviewed' : False}
+    if 'status' in get_dict.keys():
+      status_value = get_dict['status']
 
-      if accepted_value == 'true':
-        # the application has been accepted
-        fields['accepted'] = True
-        fields['reviewed'] = True
-        notifications.sendNewClubNotification(entity)
-      elif accepted_value == 'false':
-        # the application has been denied
-        fields['accepted'] = False
-        fields['reviewed'] = True
+      if status_value in ['accepted', 'rejected', 'ignored']:
+        # this application has been properly reviewed update the status
+        fields = {'status' : status_value}
 
-      if fields['reviewed']:
-        # the application has either been denied or accepted
-        # mark it as reviewed and update accordingly
         application = self._logic.getFromFields(link_id=kwargs['link_id'])
         self._logic.updateModelProperties(application, fields)
 
@@ -283,7 +268,7 @@
     params = dicts.merge(params, self._params)
 
     # only select the requests that haven't been reviewed yet
-    filter = {'reviewed' : False}
+    filter = {'status' : 'needs review'}
 
     ur_params = params.copy()
     ur_params['list_description'] = ugettext_lazy('A list of all unhandled '
@@ -294,8 +279,7 @@
         request, ur_params, filter, 0)
 
     # only select the requests that haven't been turned into a group yet
-    filter = {'accepted' : True,
-        'application_completed' : False}
+    filter['status'] = 'accepted'
 
     uh_params = params.copy()
     uh_params['list_description'] = ugettext_lazy('A list of all applications '
@@ -306,8 +290,7 @@
         request, uh_params, filter, 0)
 
     #only select the requests the have been denied
-    filter = {'reviewed' : True,
-        'accepted' : False}
+    filter ['status'] = 'rejected'
 
     den_params = params.copy()
     den_params['list_description'] = ugettext_lazy('A list of all applications '