70 |
70 |
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'] |
75 new_params['extra_dynaexclude'] = ['former_accounts', 'agreed_to_tos', |
|
76 'agreed_to_tos_on'] |
76 new_params['create_extra_dynafields'] = { |
77 new_params['create_extra_dynafields'] = { |
77 'clean_link_id': cleaning.clean_user_not_exist('link_id'), |
78 'clean_link_id': cleaning.clean_user_not_exist('link_id'), |
78 'clean_account': cleaning.clean_user_account_not_in_use('account')} |
79 'clean_account': cleaning.clean_user_account_not_in_use('account')} |
79 |
80 |
80 new_params['edit_extra_dynafields'] = { |
81 new_params['edit_extra_dynafields'] = { |
81 'link_id': forms.CharField(widget=widgets.ReadOnlyInput(), |
82 'link_id': forms.CharField(widget=widgets.ReadOnlyInput(), |
82 required=True), |
83 required=True), |
83 'clean_link_id': cleaning.clean_link_id, |
84 'clean_link_id': cleaning.clean_link_id, |
|
85 'agreed_to_tos_on' : forms.CharField(widget=widgets.ReadOnlyInput(), |
|
86 required=False), |
84 'clean_account': cleaning.clean_user_account('account'), |
87 'clean_account': cleaning.clean_user_account('account'), |
85 'clean': cleaning.validate_user_edit('link_id', 'account'), |
88 'clean': cleaning.validate_user_edit('link_id', 'account'), |
86 } |
89 } |
|
90 |
87 params = dicts.merge(params, new_params) |
91 params = dicts.merge(params, new_params) |
88 |
92 |
89 super(View, self).__init__(params=params) |
93 super(View, self).__init__(params=params) |
90 |
94 |
91 |
95 |
93 """See base.View._editGet(). |
97 """See base.View._editGet(). |
94 """ |
98 """ |
95 |
99 |
96 # fill in the email field with the data from the entity |
100 # fill in the email field with the data from the entity |
97 form.fields['account'].initial = entity.account.email() |
101 form.fields['account'].initial = entity.account.email() |
98 form.fields['agrees_to_tos'].example_text = self.getToSExampleText() |
102 form.fields['agreed_to_tos_on'].initial = entity.agreed_to_tos_on |
|
103 form.fields['agreed_to_tos_on'].example_text = self._getToSExampleText() |
99 |
104 |
100 super(View, self)._editGet(request, entity, form) |
105 super(View, self)._editGet(request, entity, form) |
101 |
106 |
102 def _editPost(self, request, entity, fields): |
|
103 """See base.View._editPost(). |
|
104 """ |
|
105 |
107 |
106 if not entity: |
108 def _getToSExampleText(self): |
107 # developer is creating a new entity set agrees_to_tos to None |
|
108 fields['agrees_to_tos'] = None |
|
109 else: |
|
110 # editing an existing user so don't change the agrees_to_tos field |
|
111 fields['agrees_to_tos'] = entity.agrees_to_tos |
|
112 |
|
113 super(View, self)._editPost(request, entity, fields) |
|
114 |
|
115 def getToSExampleText(self): |
|
116 """Returns example_text linking to site-wide ToS, or a warning message. |
109 """Returns example_text linking to site-wide ToS, or a warning message. |
117 """ |
110 """ |
118 tos_link = redirects.getToSRedirect(site_logic.getSingleton()) |
111 tos_link = redirects.getToSRedirect(site_logic.getSingleton()) |
119 |
112 |
120 if not tos_link: |
113 if not tos_link: |