# HG changeset patch # User Lennard de Rijk # Date 1233508482 0 # Node ID 76e2ed09661cfc7403b0326f1d92ec07c3c1c865 # Parent 40bccd791cf6a99c8425d077f1e6eeb13b788c54 Added status property to the user model. This is to accommodate the ability to exclude users from using the website. Note that since the access modules is currently undergoing some reconstruction changing the status will not actually effect the User yet. Patch by: Lennard de Rijk Reviewed by: to-be-reviewed diff -r 40bccd791cf6 -r 76e2ed09661c app/soc/models/user.py --- a/app/soc/models/user.py Sun Feb 01 16:18:04 2009 +0000 +++ b/app/soc/models/user.py Sun Feb 01 17:14:42 2009 +0000 @@ -107,3 +107,11 @@ agreed_to_tos_on.help_text = ugettext( 'Indicates when the user agreed to the site-wide Terms of Service.') + #: field storing the status of this User. + #: valid: Is just that, it's a valid User. + #: invalid: This means that this User has been excluded from using the website. + status = db.StringProperty(required=True, default='valid', + choices=['valid', 'invalid'],) + status.help_text = ugettext( + 'Indicates the status of the User. Invalid means that this account ' + 'has been excluded from using the website.') diff -r 40bccd791cf6 -r 76e2ed09661c app/soc/views/models/user.py --- a/app/soc/views/models/user.py Sun Feb 01 16:18:04 2009 +0000 +++ b/app/soc/views/models/user.py Sun Feb 01 17:14:42 2009 +0000 @@ -73,17 +73,23 @@ new_params['sidebar_heading'] = 'Users' new_params['extra_dynaexclude'] = ['former_accounts', 'agreed_to_tos', - 'agreed_to_tos_on'] + 'agreed_to_tos_on', 'status'] new_params['create_extra_dynafields'] = { 'clean_link_id': cleaning.clean_user_not_exist('link_id'), 'clean_account': cleaning.clean_user_account_not_in_use('account')} + # recreate the choices for the edit form + status_choices = [] + for choice in user_logic.getModel().status.choices: + status_choices.append((choice, choice)) + new_params['edit_extra_dynafields'] = { 'link_id': forms.CharField(widget=widgets.ReadOnlyInput(), required=True), 'clean_link_id': cleaning.clean_link_id('link_id'), 'agreed_to_tos_on' : forms.CharField(widget=widgets.ReadOnlyInput(), required=False), + 'status' : forms.ChoiceField(choices=status_choices), 'clean_account': cleaning.clean_user_account('account'), 'clean': cleaning.validate_user_edit('link_id', 'account'), } @@ -101,6 +107,7 @@ form.fields['account'].initial = entity.account.email() form.fields['agreed_to_tos_on'].initial = entity.agreed_to_tos_on form.fields['agreed_to_tos_on'].example_text = self._getToSExampleText() + form.fields['status'].initial = entity.status super(View, self)._editGet(request, entity, form) diff -r 40bccd791cf6 -r 76e2ed09661c app/soc/views/models/user_self.py --- a/app/soc/views/models/user_self.py Sun Feb 01 16:18:04 2009 +0000 +++ b/app/soc/views/models/user_self.py Sun Feb 01 17:14:42 2009 +0000 @@ -84,7 +84,7 @@ # set the specific fields for the users profile page new_params['extra_dynaexclude'] = ['former_accounts', - 'account', 'is_developer'] + 'account', 'is_developer', 'status'] new_params['create_extra_dynafields'] = { 'clean_agreed_to_tos': cleaning.clean_agrees_to_tos('agreed_to_tos'),