# HG changeset patch # User Mads Kiilerich # Date 2015-07-31 15:44:07 # 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 --git a/kallithea/controllers/admin/my_account.py b/kallithea/controllers/admin/my_account.py --- a/kallithea/controllers/admin/my_account.py +++ b/kallithea/controllers/admin/my_account.py @@ -100,8 +100,6 @@ class MyAccountController(BaseController 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 @@ class MyAccountController(BaseController 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 --git a/kallithea/controllers/admin/users.py b/kallithea/controllers/admin/users.py --- a/kallithea/controllers/admin/users.py +++ b/kallithea/controllers/admin/users.py @@ -166,8 +166,6 @@ class UsersController(BaseController): 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 @@ class UsersController(BaseController): 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 @@ class UsersController(BaseController): # 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 --git a/kallithea/templates/admin/my_account/my_account_profile.html b/kallithea/templates/admin/my_account/my_account_profile.html --- a/kallithea/templates/admin/my_account/my_account_profile.html +++ b/kallithea/templates/admin/my_account/my_account_profile.html @@ -22,11 +22,11 @@ ${h.form(url('my_account'), method='post <% 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 --git a/kallithea/templates/admin/users/user_edit_profile.html b/kallithea/templates/admin/users/user_edit_profile.html --- a/kallithea/templates/admin/users/user_edit_profile.html +++ b/kallithea/templates/admin/users/user_edit_profile.html @@ -20,11 +20,11 @@ ${h.form(url('update_user', id=c.user.us <% 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