Changeset - ef71d7e63806
[Not reviewed]
beta
0 2 1
Marcin Kuzminski - 13 years ago 2012-05-28 16:51:22
marcin@python-works.com
highly improved performance of my_account page by removing super heavy htmlfill call on whole page
3 files changed with 93 insertions and 89 deletions:
0 comments (0 inline, 0 general)
rhodecode/controllers/admin/settings.py
Show inline comments
 
@@ -335,18 +335,20 @@ class SettingsController(BaseController)
 
        if c.user.username == 'default':
 
            h.flash(_("You can't edit this user since it's"
 
              " crucial for entire application"), category='warning')
 
            return redirect(url('users'))
 

	
 
        defaults = c.user.get_dict()
 
        return htmlfill.render(
 
            render('admin/users/user_edit_my_account.html'),
 

	
 
        c.form = htmlfill.render(
 
            render('admin/users/user_edit_my_account_form.html'),
 
            defaults=defaults,
 
            encoding="UTF-8",
 
            force_defaults=False
 
        )
 
        return render('admin/users/user_edit_my_account.html')
 

	
 
    def my_account_update(self):
 
        """PUT /_admin/my_account_update: Update an existing item"""
 
        # Forms posted to this method should contain a hidden field:
 
        #    <input type="hidden" name="_method" value="PUT" />
 
        # Or using helpers:
 
@@ -370,18 +372,19 @@ class SettingsController(BaseController)
 
            all_repos = self.sa.query(Repository)\
 
                .filter(Repository.user_id == c.user.user_id)\
 
                .order_by(func.lower(Repository.repo_name))\
 
                .all()
 
            c.user_repos = ScmModel().get_repos(all_repos)
 

	
 
            return htmlfill.render(
 
                render('admin/users/user_edit_my_account.html'),
 
            c.form = htmlfill.render(
 
                render('admin/users/user_edit_my_account_form.html'),
 
                defaults=errors.value,
 
                errors=errors.error_dict or {},
 
                prefix_error=False,
 
                encoding="UTF-8")
 
            return render('admin/users/user_edit_my_account.html')
 
        except Exception:
 
            log.error(traceback.format_exc())
 
            h.flash(_('error occurred during update of user %s') \
 
                    % form_result.get('username'), category='error')
 

	
 
        return redirect(url('my_account'))
rhodecode/templates/admin/users/user_edit_my_account.html
Show inline comments
 
@@ -18,97 +18,13 @@
 
<div class="box box-left">
 
    <!-- box / title -->
 
    <div class="title">
 
        ${self.breadcrumbs()}
 
    </div>
 
    <!-- end box / title -->
 
    <div>
 
    ${h.form(url('admin_settings_my_account_update'),method='put')}
 
	    <div class="form">
 

	
 
             <div class="field">
 
                <div class="gravatar_box">
 
                    <div class="gravatar"><img alt="gravatar" src="${h.gravatar_url(c.user.email)}"/></div>
 
                    <p>
 
                    %if c.use_gravatar:
 
                    <strong>${_('Change your avatar at')} <a href="http://gravatar.com">gravatar.com</a></strong>
 
                    <br/>${_('Using')} ${c.user.email}
 
                    %else:
 
                    <br/>${c.user.email}
 
                    %endif
 
                    </p>
 
                </div>
 
             </div>
 
	        <div class="field">
 
	            <div class="label">
 
	                <label>${_('API key')}</label> ${c.user.api_key}
 
	            </div>
 
	        </div>
 
	        <div class="fields">
 
	             <div class="field">
 
	                <div class="label">
 
	                    <label for="username">${_('Username')}:</label>
 
	                </div>
 
	                <div class="input">
 
	                    ${h.text('username',class_="medium")}
 
	                </div>
 
	             </div>
 

	
 
	             <div class="field">
 
	                <div class="label">
 
	                    <label for="new_password">${_('New password')}:</label>
 
	                </div>
 
	                <div class="input">
 
	                    ${h.password('new_password',class_="medium",autocomplete="off")}
 
	                </div>
 
	             </div>
 

	
 
                 <div class="field">
 
                    <div class="label">
 
                        <label for="password_confirmation">${_('New password confirmation')}:</label>
 
                    </div>
 
                    <div class="input">
 
                        ${h.password('password_confirmation',class_="medium",autocomplete="off")}
 
                    </div>
 
                 </div>
 

	
 
	             <div class="field">
 
	                <div class="label">
 
	                    <label for="name">${_('First Name')}:</label>
 
	                </div>
 
	                <div class="input">
 
	                    ${h.text('name',class_="medium")}
 
	                </div>
 
	             </div>
 

	
 
	             <div class="field">
 
	                <div class="label">
 
	                    <label for="lastname">${_('Last Name')}:</label>
 
	                </div>
 
	                <div class="input">
 
	                    ${h.text('lastname',class_="medium")}
 
	                </div>
 
	             </div>
 

	
 
	             <div class="field">
 
	                <div class="label">
 
	                    <label for="email">${_('Email')}:</label>
 
	                </div>
 
	                <div class="input">
 
	                    ${h.text('email',class_="medium")}
 
	                </div>
 
	             </div>
 

	
 
	            <div class="buttons">
 
	              ${h.submit('save',_('Save'),class_="ui-button")}
 
	              ${h.reset('reset',_('Reset'),class_="ui-button")}
 
	            </div>
 
	    	</div>
 
	    </div>
 
    ${h.end_form()}
 
    </div>
 
    ${c.form|n}
 
</div>
 

	
 
<div class="box box-right">
 
    <!-- box / title -->
 
    <div class="title">
 
        <h5>
rhodecode/templates/admin/users/user_edit_my_account_form.html
Show inline comments
 
new file 100644
 
<div>
 
    ${h.form(url('admin_settings_my_account_update'),method='put')}
 
        <div class="form">
 

	
 
             <div class="field">
 
                <div class="gravatar_box">
 
                    <div class="gravatar"><img alt="gravatar" src="${h.gravatar_url(c.user.email)}"/></div>
 
                    <p>
 
                    %if c.use_gravatar:
 
                    <strong>${_('Change your avatar at')} <a href="http://gravatar.com">gravatar.com</a></strong>
 
                    <br/>${_('Using')} ${c.user.email}
 
                    %else:
 
                    <br/>${c.user.email}
 
                    %endif
 
                    </p>
 
                </div>
 
             </div>
 
            <div class="field">
 
                <div class="label">
 
                    <label>${_('API key')}</label> ${c.user.api_key}
 
                </div>
 
            </div>
 
            <div class="fields">
 
                 <div class="field">
 
                    <div class="label">
 
                        <label for="username">${_('Username')}:</label>
 
                    </div>
 
                    <div class="input">
 
                        ${h.text('username',class_="medium")}
 
                    </div>
 
                 </div>
 

	
 
                 <div class="field">
 
                    <div class="label">
 
                        <label for="new_password">${_('New password')}:</label>
 
                    </div>
 
                    <div class="input">
 
                        ${h.password('new_password',class_="medium",autocomplete="off")}
 
                    </div>
 
                 </div>
 

	
 
                 <div class="field">
 
                    <div class="label">
 
                        <label for="password_confirmation">${_('New password confirmation')}:</label>
 
                    </div>
 
                    <div class="input">
 
                        ${h.password('password_confirmation',class_="medium",autocomplete="off")}
 
                    </div>
 
                 </div>
 

	
 
                 <div class="field">
 
                    <div class="label">
 
                        <label for="name">${_('First Name')}:</label>
 
                    </div>
 
                    <div class="input">
 
                        ${h.text('name',class_="medium")}
 
                    </div>
 
                 </div>
 

	
 
                 <div class="field">
 
                    <div class="label">
 
                        <label for="lastname">${_('Last Name')}:</label>
 
                    </div>
 
                    <div class="input">
 
                        ${h.text('lastname',class_="medium")}
 
                    </div>
 
                 </div>
 

	
 
                 <div class="field">
 
                    <div class="label">
 
                        <label for="email">${_('Email')}:</label>
 
                    </div>
 
                    <div class="input">
 
                        ${h.text('email',class_="medium")}
 
                    </div>
 
                 </div>
 

	
 
                <div class="buttons">
 
                  ${h.submit('save',_('Save'),class_="ui-button")}
 
                  ${h.reset('reset',_('Reset'),class_="ui-button")}
 
                </div>
 
            </div>
 
        </div>
 
    ${h.end_form()}
 
    </div>
 
\ No newline at end of file
0 comments (0 inline, 0 general)