/
authz.html
161 lines (145 loc) · 4.71 KB
/
authz.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
{% extends "page.html" %}
{% block title %}{{ _('Administration - Authorization') }} - {{ super() }}{% endblock %}
{% block breadcrumb_content %}
{% endblock %}
{% macro authz_form_table(id, roles, users, user_role_dict) %}
<table class="table table-bordered table-striped table-condensed">
<tr>
<th> User </th>
{% for role in roles %}
<th> {{ role }} </th>
{% endfor %}
</tr>
{% for user in users %}
<tr>
<td>
{{ h.linked_user(user) }}
</td>
{% for role in roles %}
<td>
<input type="hidden" name="{{ h.literal( '%s$%s' % (user,role)) }}" value="submitted"/>
{% if user_role_dict[(user,role)] %}
<input type="checkbox"
name="{{ h.literal( '%s$%s' % (user,role)) }}"
checked='checked'/>
{% else %}
<input type="checkbox"
name="{{ h.literal( '%s$%s' % (user,role)) }}"
/>
{% endif %}
</td>
{% endfor %}
</tr>
{% endfor %}
</table>
{% endmacro %}
{% macro authz_add_table(roles) %}
<table class="table table-bordered table-striped table-condensed">
<tr>
<th>User</th>
{% for role in roles %}
<th> {{ role }} </th>
{% endfor %}
</tr>
<tr>
<td>
<input type="textbox" name="new_user_name" class="autocomplete-user" />
</td>
{% for role in roles %}
<td>
<input type="hidden" name="{{ h.literal( '%s' % role) }}" value="submitted"/>
<input type="checkbox" name="{{ h.literal( '%s' % role) }}"/>
</td>
{% endfor %}
</tr>
</table>
{% endmacro %}
{% macro authz_form_group_table(id, roles, users, user_role_dict) %}
<table class="table table-bordered table-striped table-condensed">
<tr>
<th>User Group</th>
{% for role in roles %}
<th> {{ role }} </th>
{% endfor %}
</tr>
{% for user in users %}
<tr>
<td>
{{ h.linked_authorization_group(user) }}
</td>
{% for role in roles %}
<td>
<input type="hidden" name="${ h.literal( '%s$%s' % (user,role)) }" value="submitted"/>
{% if user_role_dict[(user,role)] %}
<input type="checkbox"
name="{{ h.literal( '%s$%s' % (user,role)) }}"
checked='checked'/>
{% else %}
<input type="checkbox"
name="{{ h.literal( '%s$%s' % (user,role)) }}"
/>
{% endif %}
</td>
{% endfor %}
</tr>
{% endfor %}
</table>
{% endmacro %}
{% macro authz_add_group_table(roles) %}
<table class="table table-bordered table-striped table-condensed">
<tr>
<th>User Group</th>
{% for role in roles %}
<th> {{ role }} </th>
{% endfor %}
</tr>
<tr>
<td>
<input type="textbox" name="new_user_name" class="autocomplete-authzgroup" />
</td>
{% for role in roles %}
<td>
<input type="hidden" name="{{ h.literal( '%s' % role) }}" value="submitted"/>
<input type="checkbox" name="{{ h.literal( '%s' % role) }}"/>
</td>
{% endfor %}
</tr>
</table>
{% endmacro %}
{% block primary %}
<article class="module">
<div class="module-content">
<h1 class="page-heading">{{ _('Administration - Authorization') }}</h1>
<h3>Update Existing Roles</h3>
<form id="theform" method="POST">
{{ authz_form_table('theform', c.roles, c.users, c.user_role_dict) }}
<button type="submit" name="save" class="btn btn-primary">
Save Changes
</button>
<div class="clear"></div>
</form>
<h3>Add Roles for Any User</h3>
<form id="addform" method="POST">
{{ authz_add_table(c.roles) }}
<button type="submit" name="add" class="btn btn-primary">Add Role</button>
<div class="clear"></div>
</form>
<hr/>
{% if c.are_any_authz_groups %}
<h3>Existing Roles for Authorization Groups</h3>
<form id="authzgroup_form" method="POST">
{{ authz_form_group_table('authzgroup_form', c.roles, c.authz_groups, c.authz_groups_role_dict) }}
<button type="submit" name="authz_save" class="btn btn-primary">Save Changes</button>
<div class="clear"></div>
</form>
<h3>Add Roles for Any Authorization Group</h3>
<form id="authzgroup_addform" method="POST">
{{ authz_add_group_table(c.roles) }}
<button type="submit" name="authz_add" class="btn btn-primary">Add Role</button>
<div class="clear"></div>
</form>
{% endif %}
</div>
</article>
{% endblock %}
{% block sidebar %}{% endblock %}