# HG changeset patch # User Mads Kiilerich # Date 1438350247 -7200 # Node ID e50a56e61b23bec5c8c67a0f025d53c9f725730d # Parent c9fcb3b04d4a4658fa62bd63b8e239b4ebaf6043 users: avoid unnecessary handling of c.extern_type and c.extern_name when editing users It is user data as anything else. diff -r c9fcb3b04d4a -r e50a56e61b23 kallithea/controllers/admin/my_account.py --- a/kallithea/controllers/admin/my_account.py Fri Jul 31 15:44:07 2015 +0200 +++ b/kallithea/controllers/admin/my_account.py Fri Jul 31 15:44:07 2015 +0200 @@ -100,8 +100,6 @@ self.__load_data() c.perm_user = AuthUser(user_id=self.authuser.user_id) c.ip_addr = self.ip_addr - c.extern_type = c.user.extern_type - c.extern_name = c.user.extern_name defaults = c.user.get_dict() update = False @@ -119,8 +117,9 @@ skip_attrs = ['admin', 'active', 'extern_type', 'extern_name', 'new_password', 'password_confirmation'] #TODO: plugin should define if username can be updated - if c.extern_type != EXTERN_TYPE_INTERNAL: + if c.user.extern_type != EXTERN_TYPE_INTERNAL: # forbid updating username for external accounts + # TODO: also skip username (and email etc) if self registration not enabled skip_attrs.append('username') UserModel().update(self.authuser.user_id, form_result, diff -r c9fcb3b04d4a -r e50a56e61b23 kallithea/controllers/admin/users.py --- a/kallithea/controllers/admin/users.py Fri Jul 31 15:44:07 2015 +0200 +++ b/kallithea/controllers/admin/users.py Fri Jul 31 15:44:07 2015 +0200 @@ -166,8 +166,6 @@ c.active = 'profile' user_model = UserModel() c.user = user_model.get(id) - c.extern_type = c.user.extern_type - c.extern_name = c.user.extern_name c.perm_user = AuthUser(user_id=id) c.ip_addr = self.ip_addr _form = UserForm(edit=True, old_data={'user_id': id, @@ -177,7 +175,7 @@ form_result = _form.to_python(dict(request.POST)) skip_attrs = ['extern_type', 'extern_name'] #TODO: plugin should define if username can be updated - if c.extern_type != kallithea.EXTERN_TYPE_INTERNAL: + if c.user.extern_type != kallithea.EXTERN_TYPE_INTERNAL: # forbid updating username for external accounts skip_attrs.append('username') @@ -247,8 +245,6 @@ # url('edit_user', id=ID) c.user = self._get_user_or_raise_if_default(id) c.active = 'profile' - c.extern_type = c.user.extern_type - c.extern_name = c.user.extern_name c.perm_user = AuthUser(user_id=id) c.ip_addr = self.ip_addr diff -r c9fcb3b04d4a -r e50a56e61b23 kallithea/templates/admin/my_account/my_account_profile.html --- a/kallithea/templates/admin/my_account/my_account_profile.html Fri Jul 31 15:44:07 2015 +0200 +++ b/kallithea/templates/admin/my_account/my_account_profile.html Fri Jul 31 15:44:07 2015 +0200 @@ -22,11 +22,11 @@ <% readonly = None %> <% disabled = "" %>
- %if c.extern_type != c.EXTERN_TYPE_INTERNAL: + %if c.user.extern_type != c.EXTERN_TYPE_INTERNAL: <% readonly = "readonly" %> <% disabled = " disabled" %> ${_('Your user is in an external Source of Record; some details cannot be managed here')}. - %endif + %endif
diff -r c9fcb3b04d4a -r e50a56e61b23 kallithea/templates/admin/users/user_edit_profile.html --- a/kallithea/templates/admin/users/user_edit_profile.html Fri Jul 31 15:44:07 2015 +0200 +++ b/kallithea/templates/admin/users/user_edit_profile.html Fri Jul 31 15:44:07 2015 +0200 @@ -20,11 +20,11 @@ <% readonly = None %> <% disabled = "" %>
- %if c.extern_type != c.EXTERN_TYPE_INTERNAL: + %if c.user.extern_type != c.EXTERN_TYPE_INTERNAL:
<% readonly = "readonly" %> <% disabled = " disabled" %> - ${_('This user is in an external Source of Record (%s); some details cannot be managed here.' % c.extern_type)}. + ${_('This user is in an external Source of Record (%s); some details cannot be managed here.' % c.user.extern_type)}.
%endif