app/soc/views/models/user.py
changeset 1157 76e2ed09661c
parent 1079 be1aacb33b0f
child 1159 3fefc88b0965
equal deleted inserted replaced
1156:40bccd791cf6 1157:76e2ed09661c
    71     new_params['edit_template'] = 'soc/user/edit.html'
    71     new_params['edit_template'] = 'soc/user/edit.html'
    72 
    72 
    73     new_params['sidebar_heading'] = 'Users'
    73     new_params['sidebar_heading'] = 'Users'
    74 
    74 
    75     new_params['extra_dynaexclude'] = ['former_accounts', 'agreed_to_tos',
    75     new_params['extra_dynaexclude'] = ['former_accounts', 'agreed_to_tos',
    76         'agreed_to_tos_on']
    76         'agreed_to_tos_on', 'status']
    77     new_params['create_extra_dynafields'] = {
    77     new_params['create_extra_dynafields'] = {
    78         'clean_link_id': cleaning.clean_user_not_exist('link_id'),
    78         'clean_link_id': cleaning.clean_user_not_exist('link_id'),
    79         'clean_account': cleaning.clean_user_account_not_in_use('account')}
    79         'clean_account': cleaning.clean_user_account_not_in_use('account')}
       
    80 
       
    81     # recreate the choices for the edit form
       
    82     status_choices = []
       
    83     for choice in user_logic.getModel().status.choices:
       
    84       status_choices.append((choice, choice))
    80 
    85 
    81     new_params['edit_extra_dynafields'] = {
    86     new_params['edit_extra_dynafields'] = {
    82         'link_id': forms.CharField(widget=widgets.ReadOnlyInput(),
    87         'link_id': forms.CharField(widget=widgets.ReadOnlyInput(),
    83             required=True),
    88             required=True),
    84         'clean_link_id': cleaning.clean_link_id('link_id'),
    89         'clean_link_id': cleaning.clean_link_id('link_id'),
    85         'agreed_to_tos_on' : forms.CharField(widget=widgets.ReadOnlyInput(),
    90         'agreed_to_tos_on' : forms.CharField(widget=widgets.ReadOnlyInput(),
    86             required=False),
    91             required=False),
       
    92         'status' : forms.ChoiceField(choices=status_choices),
    87         'clean_account': cleaning.clean_user_account('account'),
    93         'clean_account': cleaning.clean_user_account('account'),
    88         'clean': cleaning.validate_user_edit('link_id', 'account'),
    94         'clean': cleaning.validate_user_edit('link_id', 'account'),
    89     }
    95     }
    90 
    96 
    91     params = dicts.merge(params, new_params)
    97     params = dicts.merge(params, new_params)
    99 
   105 
   100     # fill in the email field with the data from the entity
   106     # fill in the email field with the data from the entity
   101     form.fields['account'].initial = entity.account.email()
   107     form.fields['account'].initial = entity.account.email()
   102     form.fields['agreed_to_tos_on'].initial = entity.agreed_to_tos_on
   108     form.fields['agreed_to_tos_on'].initial = entity.agreed_to_tos_on
   103     form.fields['agreed_to_tos_on'].example_text = self._getToSExampleText()
   109     form.fields['agreed_to_tos_on'].example_text = self._getToSExampleText()
       
   110     form.fields['status'].initial = entity.status
   104 
   111 
   105     super(View, self)._editGet(request, entity, form)
   112     super(View, self)._editGet(request, entity, form)
   106 
   113 
   107 
   114 
   108   def _getToSExampleText(self):
   115   def _getToSExampleText(self):