|
1 | 1 | <%inherit file="base.tmpl"/>
|
2 | 2 | <%block name="extra_head">
|
3 | 3 | <link href="//maxcdn.bootstrapcdn.com/font-awesome/4.2.0/css/font-awesome.min.css" rel="stylesheet">
|
| 4 | +<style> |
| 5 | +.inactive-user .username, .inactive-user .realname { |
| 6 | + text-decoration: line-through; |
| 7 | +} |
| 8 | +</style> |
| 9 | +</%block> |
| 10 | +<%block name="extra_js"> |
| 11 | +<script> |
| 12 | +$('#deleteModal').on('show.bs.modal', function (event) { |
| 13 | + var button = $(event.relatedTarget); |
| 14 | + var username = button.data('username'); |
| 15 | + var uid = button.data('uid'); |
| 16 | + var direction = button.data('direction'); |
| 17 | + var modal = $(this); |
| 18 | + modal.find('.del-title').text(username); |
| 19 | + modal.find('.del-uid').val(uid); |
| 20 | + modal.find('.del-direction').val(direction); |
| 21 | + if (direction == 'del') { |
| 22 | + modal.find('.del-noun').text('deletion'); |
| 23 | + modal.find('.del-verb').text('delete'); |
| 24 | + modal.find('.del-verb-capital').text('Delete'); |
| 25 | + } else { |
| 26 | + modal.find('.del-noun').text('undeletion'); |
| 27 | + modal.find('.del-verb').text('undelete'); |
| 28 | + modal.find('.del-verb-capital').text('Undelete'); |
| 29 | + } |
| 30 | +}); |
| 31 | +</script> |
4 | 32 | </%block>
|
5 | 33 | <%block name="content">
|
6 | 34 | <h1 class="title">Users</h1>
|
7 | 35 |
|
| 36 | +% if alert: |
| 37 | +<div class="alert alert-${alert_status}" role="alert">${alert}</div> |
| 38 | +% endif |
| 39 | + |
8 | 40 | <table class="table table-hover">
|
9 | 41 | <thead><tr>
|
| 42 | + <th>#</th> |
10 | 43 | <th>Username</th>
|
11 | 44 | <th>Real name</th>
|
12 |
| - <th>Can edit users</th> |
| 45 | + <th>Admin</th> |
13 | 46 | <th>Actions</th>
|
14 | 47 | </tr></thead>
|
15 |
| -% for user, data in USERS.items(): |
| 48 | +% for uid, user in USERS.items(): |
| 49 | +% if user.active: |
16 | 50 | <tr>
|
17 |
| - <td>${user}</td> |
18 |
| - <td>${data['name']}</td> |
| 51 | +% else: |
| 52 | +<tr class="danger inactive-user"> |
| 53 | +% endif |
| 54 | + <td class="uid">${uid}</td> |
| 55 | + <td class="username">${user.username}</td> |
| 56 | + <td class="realname">${user.realname}</td> |
19 | 57 | <td>
|
20 |
| - % if data['can_edit_users']: |
| 58 | + % if user.is_admin: |
21 | 59 | <i class="fa fa-check"></i>
|
22 | 60 | % else:
|
23 | 61 | <i class="fa fa-times"></i>
|
24 | 62 | % endif
|
25 | 63 | </td>
|
26 | 64 | <td>
|
| 65 | + <form action="/users/edit" method="POST"><input type="hidden" name="uid" value="${uid}"> |
27 | 66 | <div class="btn-group" role="group">
|
28 |
| - <a href="/users/${user}" class="btn btn-info btn-xs"><i class="fa fa-pencil"></i></a> |
29 |
| - % if user == USERNAME: |
30 |
| - <a href="#" class="btn btn-danger btn-xs disabled"><i class="fa fa-trash"></i></a> |
| 67 | + % if user.active: |
| 68 | + <button type="submit" class="btn btn-info btn-xs"><i class="fa fa-pencil"></i></button> |
| 69 | + % if user == current_user: |
| 70 | + <button type="button" class="btn btn-danger btn-xs" disabled><i class="fa fa-trash"></i></button> |
| 71 | + % else: |
| 72 | + <button type="button" class="btn btn-danger btn-xs" data-toggle="modal" data-target="#deleteModal" data-username="${user.username}" data-uid="${uid}" data-direction="del" title="Delete"><i class="fa fa-trash"></i></button> |
| 73 | + % endif |
31 | 74 | % else:
|
32 |
| - <a href="/users/${user}/delete" class="btn btn-danger btn-xs"><i class="fa fa-trash"></i></a> |
| 75 | + <button type="button" class="btn btn-info btn-xs" disabled><i class="fa fa-pencil"></i></button> |
| 76 | + <button type="button" class="btn btn-success btn-xs" data-toggle="modal" data-target="#deleteModal" data-username="${user.username}" data-uid="${uid}" data-direction="undel" title="Undelete"><i class="fa fa-trash-o"></i></button> |
33 | 77 | % endif
|
34 | 78 | </div>
|
| 79 | + </form> |
35 | 80 | </tr>
|
36 | 81 | % endfor
|
37 |
| -<tr><form action="/users/create/new" method="POST"> |
38 |
| - <td><input name="name" placeholder="User to create"></td> |
| 82 | +<tr><form action="/users/new" method="POST"> |
| 83 | + <td><i class="fa fa-plus"></i></td> |
| 84 | + <td><input name="username" placeholder="User to create"></td> |
39 | 85 | <td></td>
|
40 | 86 | <td></td>
|
41 |
| - <td><button type="submit" class="btn btn-success btn-xs"><i class="fa fa-check"></button></td> |
| 87 | + <td><button type="submit" class="btn btn-success btn-xs"><i class="fa fa-arrow-circle-right"></i></button></td> |
42 | 88 | </form></tr>
|
43 | 89 | </table>
|
44 | 90 |
|
| 91 | +<div class="modal fade" id="deleteModal" tabindex="-1" role="dialog" aria-labelledby="deleteModalLabel" aria-hidden="true"> |
| 92 | + <div class="modal-dialog"> |
| 93 | + <div class="modal-content"> |
| 94 | + <div class="modal-header"> |
| 95 | + <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button> |
| 96 | + <h4 class="modal-title" id="deleteModalLabel">Confirm <span class="del-noun">something</span></h4> |
| 97 | + </div> |
| 98 | + <div class="modal-body"> |
| 99 | + Really <span class="del-verb">do something to</span> <span class="del-title">user</span>? |
| 100 | + </div> |
| 101 | + <div class="modal-footer"> |
| 102 | + <form method="POST" action="/users/delete" class="delete-button"> |
| 103 | + <input type="hidden" name="uid" class="del-uid"> |
| 104 | + <input type="hidden" name="direction" class="del-direction"> |
| 105 | + <button type="button" class="btn btn-default" data-dismiss="modal">Cancel</button> |
| 106 | + <button type="submit" class="btn btn-danger del-verb-capital">Delete</button> |
| 107 | + </div> |
| 108 | + </div> |
| 109 | + </div> |
| 110 | +</div> |
45 | 111 | </%block>
|
0 commit comments