##// END OF EJS Templates
No more raw html inside users controller....
marcink -
r2663:cc8d7d45 beta
parent child Browse files
Show More
@@ -40,6 +40,7 from rhodecode.lib.auth import LoginRequ
40 40 AuthUser
41 41 from rhodecode.lib.base import BaseController, render
42 42
43 import rhodecode
43 44 from rhodecode.model.db import User, Permission, UserEmailMap
44 45 from rhodecode.model.forms import UserForm
45 46 from rhodecode.model.user import UserModel
@@ -72,34 +73,33 class UsersController(BaseController):
72 73
73 74 users_data = []
74 75 total_records = len(c.users_list)
75 grav_tmpl = """<div class="gravatar"><img alt="gravatar" src="%s"/> </div>"""
76 usr_tmpl = """<a href="%s">%s</a>""" % (h.url('edit_user', id='__ID__'), '%s')
77 usr_tmpl = usr_tmpl.replace('__ID__', '%s')
78 edit_tmpl = '''
79 <form action="/_admin/users/%s" method="post">
80 <div style="display:none">
81 <input name="_method" type="hidden" value="%s">
82 </div>
83 <input class="delete_icon action_button" id="remove_user_%s"
84 name="remove_" onclick="return confirm('%s');"
85 type="submit" value="delete">
86 </form>
87 '''
76 _tmpl_lookup = rhodecode.CONFIG['pylons.app_globals'].mako_lookup
77 template = _tmpl_lookup.get_template('data_table/_dt_elements.html')
78
79 grav_tmpl = lambda user_email, size: (
80 template.get_def("user_gravatar")
81 .render(user_email, size, _=_, h=h))
82
83 user_lnk = lambda user_id, username: (
84 template.get_def("user_name")
85 .render(user_id, username, _=_, h=h))
86
87 user_actions = lambda user_id, username: (
88 template.get_def("user_actions")
89 .render(user_id, username, _=_, h=h))
90
88 91 for user in c.users_list:
89 92 users_data.append({
90 "gravatar": grav_tmpl % h.gravatar_url(user.email, 24),
93 "gravatar": grav_tmpl(user. email, 24),
91 94 "raw_username": user.username,
92 "username": usr_tmpl % (user.user_id, user.username),
95 "username": user_lnk(user.user_id, user.username),
93 96 "firstname": user.name,
94 97 "lastname": user.lastname,
95 98 "last_login": h.fmt_date(user.last_login),
96 99 "active": h.bool2icon(user.active),
97 100 "admin": h.bool2icon(user.admin),
98 101 "ldap": h.bool2icon(bool(user.ldap_dn)),
99 "action": edit_tmpl % (user.user_id, _('delete'),
100 user.user_id,
101 _('Confirm to delete this user: %s') % user.username
102 ),
102 "action": user_actions(user.user_id, user.username),
103 103 })
104 104
105 105 c.data = json.dumps({
@@ -140,9 +140,6
140 140 clearTimeout(filterTimeout);
141 141 filterTimeout = setTimeout(updateFilter,600);
142 142 });
143
144
145
146 143 </script>
147 144
148 145 </%def>
@@ -2,6 +2,12
2 2 ## usage:
3 3 ## <%namespace name="dt" file="/data_table/_dt_elements.html"/>
4 4
5 <%def name="repo_actions(repo_name)">
6 ${h.form(h.url('repo', repo_name=repo_name),method='delete')}
7 ${h.submit('remove_%s' % repo_name,_('delete'),class_="delete_icon action_button",onclick="return confirm('"+_('Confirm to delete this repository: %s') % repo_name+"');")}
8 ${h.end_form()}
9 </%def>
10
5 11 <%def name="quick_menu(repo_name)">
6 12 <ul class="menu_items hidden">
7 13 <li style="border-top:1px solid #003367;margin-left:18px;padding-left:-99px"></li>
@@ -87,3 +93,19
87 93 %endif
88 94 </div>
89 95 </%def>
96
97 <%def name="user_gravatar(email, size=24)">
98 <div class="gravatar"><img alt="gravatar" src="${h.gravatar_url(email, size)}"/> </div>
99 </%def>
100
101 <%def name="user_actions(user_id, username)">
102 ${h.form(h.url('delete_user', id=user_id),method='delete')}
103 ${h.submit('remove_',_('delete'),id="remove_user_%s" % user_id,
104 class_="delete_icon action_button",onclick="return confirm('"+_('Confirm to delete this user: %s') % username+"');")}
105 ${h.end_form()}
106 </%def>
107
108 <%def name="user_name(user_id, username)">
109 ${h.link_to(username,h.url('edit_user', id=user_id))}
110 </%def>
111
General Comments 0
You need to be logged in to leave comments. Login now