Changeset - e50a56e61b23
[Not reviewed]
default
0 4 0
Mads Kiilerich - 10 years ago 2015-07-31 15:44:07
madski@unity3d.com
users: avoid unnecessary handling of c.extern_type and c.extern_name when editing users

It is user data as anything else.
4 files changed with 7 insertions and 12 deletions:
0 comments (0 inline, 0 general)
kallithea/controllers/admin/my_account.py
Show inline comments
 
@@ -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,
kallithea/controllers/admin/users.py
Show inline comments
 
@@ -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
 

	
kallithea/templates/admin/my_account/my_account_profile.html
Show inline comments
 
@@ -22,11 +22,11 @@ ${h.form(url('my_account'), method='post
 
        <% readonly = None %>
 
        <% disabled = "" %>
 
        <div class="fields">
 
           %if c.extern_type != c.EXTERN_TYPE_INTERNAL:
 
            %if c.user.extern_type != c.EXTERN_TYPE_INTERNAL:
 
                <% readonly = "readonly" %>
 
                <% disabled = " disabled" %>
 
                <strong>${_('Your user is in an external Source of Record; some details cannot be managed here')}.</strong>
 
           %endif
 
            %endif
 
             <div class="field">
 
                <div class="label">
 
                    <label for="username">${_('Username')}:</label>
kallithea/templates/admin/users/user_edit_profile.html
Show inline comments
 
@@ -20,11 +20,11 @@ ${h.form(url('update_user', id=c.user.us
 
        <% readonly = None %>
 
        <% disabled = "" %>
 
        <div class="fields">
 
            %if c.extern_type != c.EXTERN_TYPE_INTERNAL:
 
            %if c.user.extern_type != c.EXTERN_TYPE_INTERNAL:
 
             <div class="field">
 
               <% readonly = "readonly" %>
 
               <% disabled = " disabled" %>
 
               <strong>${_('This user is in an external Source of Record (%s); some details cannot be managed here.' % c.extern_type)}.</strong>
 
               <strong>${_('This user is in an external Source of Record (%s); some details cannot be managed here.' % c.user.extern_type)}.</strong>
 
             </div>
 
            %endif
 

	
0 comments (0 inline, 0 general)