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