]> git.datanom.net - liogui.git/blob - webapp/templates/auth/update.html
Completed User Administration
[liogui.git] / webapp / templates / auth / update.html
1 {% extends 'base.html' %}
2
3 {% block header %}
4 <h1>{% block title %}User Administration{% endblock %}</h1>
5 <a class="action" href="{{ url_for('index') }}">Index</a>
6 {% endblock %}
7
8 {% block content %}
9 <table>
10 <tr>
11 <th>Username</th><th>Permission</th><th>Action</th>
12 </tr>
13 {% for user in users %}
14 <tr>
15 <td>{{ user.username }}</td>
16 <td>
17 <select name="perm" id="perm{{user.id}}">
18 {% for perm in perms %}
19 {% if perm.name == user.name %}
20 <option value="{{ perm.id }}" selected>{{ perm.name }}</option>
21 {% else %}
22 <option value="{{ perm.id }}">{{ perm.name }}</option>
23 {% endif %}
24 {% endfor %}
25 </select>
26 </td>
27 <td>
28 |
29 {% if g.user.id == user.id %}
30 <button type="button" onclick="submit_update({{user.id}})">update</button>
31 | <button type="button" onclick="submit_chpwd({{user.id}})">change password</button>
32 {% else %}
33 <button type="button" onclick="submit_update({{user.id}})">update</button>
34 | <button type="button" onclick="submit_delete({{user.id}})">delete</button>
35 | <button type="button" onclick="submit_chpwd({{user.id}})">change password</button>
36 {% endif %}
37 </td>
38 </tr>
39 {% endfor %}
40 </table>
41 <script type="text/javascript">
42 function submit_update(id) {
43 var perm = document.getElementById("perm"+id).value;
44 var url = '/auth/userupdate/'+id;
45 fetch(url, {
46 method: 'POST',
47 headers: {
48 'Content-Type': 'application/json'
49 },
50 body: JSON.stringify({ "perm_id": parseInt(perm) })
51 })
52 return true;
53 }
54 </script>
55 <script type="text/javascript">
56 function submit_delete(id) {
57 fetch('/auth/userdelete/'+id, {
58 method: 'POST',
59 headers: {
60 'Content-Type': 'application/json'
61 },
62 body: ""
63 })
64 document.location.replace('/auth/update');
65 return true;
66 }
67 </script>
68 <script type="text/javascript">
69 function submit_chpwd(id) {
70 document.location.replace('/auth/changepwd/'+id);
71 return true;
72 }
73 </script>
74 {% endblock %}
75
This page took 0.231908 seconds and 6 git commands to generate.