Replaced the boolean properties in soc/models/request.py with a state property.
authorLennard de Rijk <ljvderijk@gmail.com>
Fri, 23 Jan 2009 17:07:54 +0000
changeset 928 df051fc9d7a1
parent 927 f790f77ba6b7
child 929 7431d7770197
Replaced the boolean properties in soc/models/request.py with a state property. new : new Request group_accepted : The group has accepted this request completed : This request has been handled either following a creation of the role entity rejected : This request has been rejected by either the user or the group ignored : The request has been ignored by the group and will not give the user access to create the role Patch by: Lennard de Rijk Reviewed by: to-be-reviewed
app/soc/logic/cleaning.py
app/soc/logic/helper/request.py
app/soc/logic/models/request.py
app/soc/models/request.py
app/soc/templates/soc/request/list/heading.html
app/soc/templates/soc/request/list/row.html
app/soc/templates/soc/request/public.html
app/soc/views/models/club_admin.py
app/soc/views/models/request.py
--- a/app/soc/logic/cleaning.py	Fri Jan 23 16:54:46 2009 +0000
+++ b/app/soc/logic/cleaning.py	Fri Jan 23 17:07:54 2009 +0000
@@ -20,6 +20,7 @@
 __authors__ = [
     '"Todd Larsen" <tlarsen@google.com>',
     '"Sverre Rabbelier" <sverre@rabbelier.nl>',
+    '"Lennard de Rijk" <ljvderijk@gmail.com>',
     ]
 
 
--- a/app/soc/logic/helper/request.py	Fri Jan 23 16:54:46 2009 +0000
+++ b/app/soc/logic/helper/request.py	Fri Jan 23 17:07:54 2009 +0000
@@ -48,4 +48,4 @@
   # mark the request completed, if there is any
   if request_entity:
     request_logic.updateModelProperties(request_entity,
-        {'completed' : True, 'group_accepted' : True, 'user_accepted' : True})
+        {'state' : 'completed'})
--- a/app/soc/logic/models/request.py	Fri Jan 23 16:54:46 2009 +0000
+++ b/app/soc/logic/models/request.py	Fri Jan 23 17:07:54 2009 +0000
@@ -63,10 +63,10 @@
     """Sends out a message notifying users about the new invite/request.
     """
 
-    if entity.group_accepted:
+    if entity.state == 'group_accepted':
       # this is an invite
       notifications.sendInviteNotification(entity)
-    elif entity.user_accepted:
+    elif entity.state == 'new':
       # this is a request
       # TODO(Lennard) Create a new request message
       pass
--- a/app/soc/models/request.py	Fri Jan 23 16:54:46 2009 +0000
+++ b/app/soc/models/request.py	Fri Jan 23 17:07:54 2009 +0000
@@ -18,6 +18,7 @@
 
 __authors__ = [
   '"Sverre Rabbelier" <sverre@rabbelier.nl>',
+  '"Lennard de Rijk" <ljvderijk@gmail.com>',
 ]
 
 
@@ -36,19 +37,22 @@
   role = db.StringProperty(required=True)
   role.help_text = ugettext_lazy(
       'This should be the type of the role that is requested')
-  
+
   role_verbose = db.StringProperty(required=True)
   role_verbose.help_text = ugettext_lazy(
       'This should be the verbose name of the role that is in this request')
 
-  group_accepted = db.BooleanProperty(required=True, default=False)
-  group_accepted.help_text = ugettext_lazy(
-      'Field used to indicate whether a request has been accepted by the group')
+  # property that determines the state of the request
+  # new : new Request
+  # group_accepted : The group has accepted this request
+  # completed : This request has been handled either following a creation of
+  #             the role entity
+  # rejected : This request has been rejected by either the user or the group
+  # ignored : The request has been ignored by the group and will not give
+  #           the user access to create the role
+  state = db.StringProperty(required=True, default='new',
+      choices=['new', 'group_accepted', 'completed', 'rejected','ignored'])
+  state.help_text = ugettext_lazy(
+      'Shows the state of the request')
 
-  user_accepted = db.BooleanProperty(required=True, default=False)
-  user_accepted.help_text = ugettext_lazy(
-      'Field used to indicate that a request has been accepted by the user')
-  
-  completed = db.BooleanProperty(required=True, default=False)
-  completed.help_text = ugettext_lazy(
-      'Field used to indiicate that a request has been completed and should be archived')
+
--- a/app/soc/templates/soc/request/list/heading.html	Fri Jan 23 16:54:46 2009 +0000
+++ b/app/soc/templates/soc/request/list/heading.html	Fri Jan 23 17:07:54 2009 +0000
@@ -2,4 +2,5 @@
   <th class="first" align="right">User</th>
   <th>Role</th>
   <th>For</th>
+  <th>State</th>
 </tr>
--- a/app/soc/templates/soc/request/list/row.html	Fri Jan 23 16:54:46 2009 +0000
+++ b/app/soc/templates/soc/request/list/row.html	Fri Jan 23 17:07:54 2009 +0000
@@ -6,4 +6,5 @@
   </td>
   <td><div class="role">{{ list.item.role_verbose }}</div></td>
   <td><div class="to">{{ list.item.scope_path }}</div></td>
+  <td><div class="state">{{ list.item.state }}</div></td>
 </tr>
--- a/app/soc/templates/soc/request/public.html	Fri Jan 23 16:54:46 2009 +0000
+++ b/app/soc/templates/soc/request/public.html	Fri Jan 23 17:07:54 2009 +0000
@@ -24,8 +24,7 @@
   {% readonly_field_as_table_row entity.fields.role.label entity.role %}
   {% readonly_field_as_table_row entity.fields.link_id.label entity.link_id %}
   {% readonly_field_as_table_row entity.fields.scope_path.label entity.scope_path %}
-  {% readonly_field_as_table_row entity.fields.user_accepted.label entity.group_accepted %}
-  {% readonly_field_as_table_row entity.fields.group_accepted.label entity.user_accepted %}
+  {% readonly_field_as_table_row entity.fields.state.label entity.state %}
   <!-- TODO(pawel.solyga) make this generic -->
  </table>
 </p>
--- a/app/soc/views/models/club_admin.py	Fri Jan 23 16:54:46 2009 +0000
+++ b/app/soc/views/models/club_admin.py	Fri Jan 23 17:07:54 2009 +0000
@@ -283,8 +283,7 @@
         'scope_path' : club.link_id,
         'role' : params['module_name'],
         'role_verbose' : params['name'],
-        'group_accepted' : True,
-        'completed' : False}
+        'state' : 'group_accepted'}
 
     # extract the key_name for the new request entity
     key_fields = request_logic.logic.getKeyFieldsFromDict(request_fields)
--- a/app/soc/views/models/request.py	Fri Jan 23 16:54:46 2009 +0000
+++ b/app/soc/views/models/request.py	Fri Jan 23 17:07:54 2009 +0000
@@ -82,8 +82,7 @@
 
     new_params['save_message'] = [ugettext_lazy('Request saved.')]
     
-    new_params['extra_dynaexclude'] = ['group_accepted', 'user_accepted', 
-        'role_verbose', 'completed']
+    new_params['extra_dynaexclude'] = ['state', 'role_verbose']
     
     # TODO(ljvderijk) add clean field that checks to see if the user already has
     # the role that's been entered in the create form fields
@@ -133,18 +132,16 @@
     fields = {'link_id' : kwargs['link_id'],
         'scope_path' : kwargs['scope_path'],
         'role' : kwargs['role'],
-        'group_accepted' : True,
-        'user_accepted' : False,
-        'completed' : False}
+        'state' : 'group_accepted'}
     request_entity = request_logic.getForFields(fields, unique=True)
     
     get_dict = request.GET
     
     if 'status' in get_dict.keys():
       if get_dict['status'] == 'rejected':
-        # this invite has been rejected mark accepted as False and mark completed as True
+        # this invite has been rejected mark as rejected
         request_logic.updateModelProperties(request_entity, {
-            'user_accepted' : False, 'completed' : True})
+            'state' : 'rejected'})
         
         # redirect to user role overview
         return http.HttpResponseRedirect('/user/roles')
@@ -180,9 +177,7 @@
 
     # only select the Invites for this user that haven't been handled yet
     filter = {'link_id': user_entity.link_id,
-              'group_accepted' : True,
-              'user_accepted' : False,
-              'completed' : False}
+              'state' : 'group_accepted'}
 
     uh_params = params.copy()
     uh_params['list_action'] = (redirects.inviteProcessRedirect, None)
@@ -197,8 +192,7 @@
     # only select the requests from the user
     # that haven't been accepted by an admin yet
     filter = {'link_id' : user_entity.link_id,
-              'group_accepted' : False,
-              'completed' : False}
+              'state' : 'new'}
 
     ar_params = params.copy()
     ar_params['list_description'] = ugettext_lazy(
@@ -226,7 +220,7 @@
     fields['scope_path'] = kwargs['scope_path']
     fields['role'] = kwargs['role']
     fields['role_verbose'] = 'Some Role'
-    fields['group_accepted'] = True
+    fields['state'] = 'group_accepted'
 
     super(View, self)._editPost(request, entity, fields)