# HG changeset patch # User Lennard de Rijk # Date 1232730474 0 # Node ID df051fc9d7a1ec8a1bd1db1f99f2a5f9a49cc492 # Parent f790f77ba6b7ddb8d90ebc3baf134e954da3c8af 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 diff -r f790f77ba6b7 -r df051fc9d7a1 app/soc/logic/cleaning.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" ', '"Sverre Rabbelier" ', + '"Lennard de Rijk" ', ] diff -r f790f77ba6b7 -r df051fc9d7a1 app/soc/logic/helper/request.py --- 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'}) diff -r f790f77ba6b7 -r df051fc9d7a1 app/soc/logic/models/request.py --- 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 diff -r f790f77ba6b7 -r df051fc9d7a1 app/soc/models/request.py --- 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" ', + '"Lennard de Rijk" ', ] @@ -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') + diff -r f790f77ba6b7 -r df051fc9d7a1 app/soc/templates/soc/request/list/heading.html --- 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 @@ User Role For + State diff -r f790f77ba6b7 -r df051fc9d7a1 app/soc/templates/soc/request/list/row.html --- 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 @@
{{ list.item.role_verbose }}
{{ list.item.scope_path }}
+
{{ list.item.state }}
diff -r f790f77ba6b7 -r df051fc9d7a1 app/soc/templates/soc/request/public.html --- 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 %}

diff -r f790f77ba6b7 -r df051fc9d7a1 app/soc/views/models/club_admin.py --- 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) diff -r f790f77ba6b7 -r df051fc9d7a1 app/soc/views/models/request.py --- 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)