diff -r 7aef36e912bb -r 06ed84dbb1ed app/soc/views/models/role.py --- a/app/soc/views/models/role.py Fri Mar 20 16:54:01 2009 +0000 +++ b/app/soc/views/models/role.py Fri Mar 20 18:53:37 2009 +0000 @@ -156,8 +156,6 @@ new_params['extra_dynaexclude'] = ['user', 'status', 'agreed_to_tos_on'] - new_params['disallow_last_resign'] = False - params = dicts.merge(params, new_params, sub_merge=True) super(View, self).__init__(params=params) @@ -434,18 +432,9 @@ if resign == 'true': - if params.get('disallow_last_resign'): - # check if the current role is the last for this scope - fields = {'scope': role_entity.scope, - 'status': 'active'} - roles = logic.getForFields(fields, limit=2) + resign_error = params['logic'].canResign(role_entity) - # if there is more then one left we can safely resign - resign = len(roles) > 1 - else: - resign = True - - if resign: + if not resign_error: # change the status of this role_entity to invalid fields = {'status': 'invalid'} logic.updateEntityProperties(role_entity, fields) @@ -454,8 +443,7 @@ return http.HttpResponseRedirect(redirect) else: # show error to the user - context['not_allowed_to_resign'] = ugettext("This user can't be " - "resigned, please make sure it's not the last %(name)s." % params) + context['resign_error'] = ugettext(resign_error %params) # set the appropriate context context['entity'] = role_entity @@ -468,7 +456,6 @@ # return a proper response return responses.respond(request, template, context=context) - @decorators.merge_params @decorators.check_access def request(self, request, access_type,