Skip to content
Permalink
Browse files
revamp permission page
Signed-off-by: Chris Warrick <kwpolska@gmail.com>
  • Loading branch information
Kwpolska committed Jan 6, 2015
1 parent e80f7c9 commit c98551e6a134b6b901148b7566602e02323b2ab6
Showing with 56 additions and 33 deletions.
  1. +1 −3 COMET/__init__.py
  2. +13 −9 COMET/templates/mako/comet_users.tmpl
  3. +32 −11 COMET/templates/mako/comet_users_permissions.tmpl
  4. +10 −10 COMET/users.json
@@ -472,6 +472,7 @@ def acp_users_permissions():
setattr(user, perm, False)
current_user.is_admin = True # cannot deadmin oneself
action = 'save'
write_users()
else:
action = 'edit'

@@ -498,10 +499,7 @@ def display_permission(user, permission):


@app.route('/users/reload')
@login_required
def acp_users_reload():
if not current_user.is_admin:
return "Not authorized to edit users.", 401
read_users()
return redirect('/users')

@@ -8,6 +8,10 @@
.uid {
text-align: right;
}

td {
vertical-align: middle !important;
}
</style>
</%block>
<%block name="extra_js">
@@ -45,7 +49,7 @@ $('#deleteModal').on('show.bs.modal', function (event) {
<div class="alert alert-${alert_status}" role="alert">${alert}</div>
% endif

<table class="table table-hover">
<table class="table table-hover" style="table-layout: fixed;">
<thead><tr>
<th class="uid">#</th>
<th class="username">Username</th>
@@ -75,26 +79,26 @@ $('#deleteModal').on('show.bs.modal', function (event) {
<input type="hidden" name="action" value="edit">
<div class="btn-group" role="group">
% if user.active:
<button type="submit" class="btn btn-info btn-xs" title="Edit"><i class="fa fa-pencil fa-fw"></i> Edit</button>
<button type="submit" class="btn btn-info" title="Edit"><i class="fa fa-pencil fa-fw"></i> Edit</button>
% if user == current_user:
<button type="button" class="btn btn-danger btn-xs" title="Delete" disabled><i class="fa fa-trash fa-fw"></i> Delete</button>
<button type="button" class="btn btn-danger" title="Delete" disabled><i class="fa fa-trash fa-fw"></i> Delete</button>
% else:
<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 fa-fw"></i> Delete</button>
<button type="button" class="btn btn-danger" data-toggle="modal" data-target="#deleteModal" data-username="${user.username}" data-uid="${uid}" data-direction="del" title="Delete"><i class="fa fa-trash fa-fw"></i> Delete</button>
% endif
% else:
<button type="button" class="btn btn-info btn-xs" title="Edit" disabled><i class="fa fa-pencil fa-fw"></i> Edit</button>
<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 fa-fw"></i> Undelete</button>
<button type="button" class="btn btn-info" title="Edit" disabled><i class="fa fa-pencil fa-fw"></i> Edit</button>
<button type="button" class="btn btn-success" data-toggle="modal" data-target="#deleteModal" data-username="${user.username}" data-uid="${uid}" data-direction="undel" title="Undelete"><i class="fa fa-trash-o fa-fw"></i> Undelete</button>
% endif
</div>
</form>
</tr>
% endfor
<tr><form action="/users/edit" method="POST">
<td><i class="fa fa-plus"></i></td>
<td><input name="username" placeholder="User to create"></td>
<td></td>
<td><input name="username" placeholder="New user" class="form-control"></td>
<td><input name="action" value="new" type="hidden"></td>
<td></td>
<td><button type="submit" class="btn btn-primary btn-xs"><i class="fa fa-plus-square fa-fw"></i> Create</button></td>
<td><button type="submit" class="btn btn-primary"><i class="fa fa-plus-square fa-fw"></i> Create</button></td>
</form></tr>
</table>

@@ -7,6 +7,9 @@
.perm, .select_all {
text-align: center;
}
td {
vertical-align: middle !important;
}
</style>
</%block>
<%block name="extra_js">
@@ -21,11 +24,11 @@ $(document).ready(function() {

for (var i = 0; i < PERMISSIONS.length; i++) {
var p = PERMISSIONS[i];
$('th.' + p + ' i.fa-check-square-o').click(function() {
$('th.' + p + ' button.select_all-perm').click(function() {
p = this.attributes['data-perm'].value;
$('.' + p + ' input').each(function() { this.checked = true; });
});
$('th.' + p + ' i.fa-square-o').click(function() {
$('th.' + p + ' button.select_none-perm').click(function() {
p = this.attributes['data-perm'].value;
$('.' + p + ' input').each(function() {
if (p != 'is_admin' || this.attributes['data-uid'].value != ${current_user.uid}) {
@@ -37,11 +40,11 @@ $(document).ready(function() {

for (var i = 0; i < USERS.length; i++) {
uid = USERS[i];
$('.u' + uid + ' td.select_all i.fa-check-square-o').click(function() {
$('.u' + uid + ' button.select_all-user').click(function() {
uid = this.attributes['data-uid'].value;
$('input.u' + uid).each(function() { this.checked = true; });
});
$('.u' + uid + ' td.select_all i.fa-square-o').click(function() {
$('.u' + uid + ' button.select_none-user').click(function() {
uid = this.attributes['data-uid'].value;
$('input.u' + uid).each(function() {
if (uid != current_uid || this.attributes['data-perm'].value != 'is_admin') { this.checked = false; }
@@ -63,12 +66,30 @@ $(document).ready(function() {
<thead><tr>
<th class="uid">#</th>
<th class="username">Username</th>
<th class="perm is_admin">Admin<br><i class="fa fa-check-square-o fa-fw" data-perm="is_admin"></i><i class="fa fa-square-o fa-fw" data-perm="is_admin"></i></th>
<th class="perm can_edit_all_posts">Can all posts<br><i class="fa fa-check-square-o fa-fw" data-perm="can_edit_all_posts"></i><i class="fa fa-square-o fa-fw" data-perm="can_edit_all_posts"></i></th>
<th class="perm wants_all_posts">Want all posts<br><i class="fa fa-check-square-o fa-fw" data-perm="wants_all_posts"></i><i class="fa fa-square-o fa-fw" data-perm="wants_all_posts"></i></th>
<th class="perm can_upload_attachments">Attachments<br><i class="fa fa-check-square-o fa-fw" data-perm="can_upload_attachments"></i><i class="fa fa-square-o fa-fw" data-perm="can_upload_attachments"></i></th>
<th class="perm can_rebuild_site">Rebuild<br><i class="fa fa-check-square-o fa-fw" data-perm="can_rebuild_site"></i><i class="fa fa-square-o fa-fw" data-perm="can_rebuild_site"></i></th>
<th class="perm can_transfer_post_authorship">Transfer authorship<br><i class="fa fa-check-square-o fa-fw" data-perm="can_transfer_post_authorship"></i><i class="fa fa-square-o fa-fw" data-perm="can_transfer_post_authorship"></i></th>
<th class="perm is_admin">Admin<br>
<button type="button" class="btn btn-info btn-xs select_all-perm" data-perm="is_admin"><i class="fa fa-check-square-o fa-fw"></i></button>
<button type="button" class="btn btn-info btn-xs select_none-perm" data-perm="is_admin"><i class="fa fa-square-o fa-fw"></i></button>
</th>
<th class="perm can_edit_all_posts">Can all posts<br>
<button type="button" class="btn btn-info btn-xs select_all-perm" data-perm="can_edit_all_posts"><i class="fa fa-check-square-o fa-fw"></i></button>
<button type="button" class="btn btn-info btn-xs select_none-perm" data-perm="can_edit_all_posts"><i class="fa fa-square-o fa-fw"></i></button>
</th>
<th class="perm wants_all_posts">Wants all posts<br>
<button type="button" class="btn btn-info btn-xs select_all-perm" data-perm="wants_all_posts"><i class="fa fa-check-square-o fa-fw"></i></button>
<button type="button" class="btn btn-info btn-xs select_none-perm" data-perm="wants_all_posts"><i class="fa fa-square-o fa-fw"></i></button>
</th>
<th class="perm can_upload_attachments">Attachments<br>
<button type="button" class="btn btn-info btn-xs select_all-perm" data-perm="can_upload_attachments"><i class="fa fa-check-square-o fa-fw"></i></button>
<button type="button" class="btn btn-info btn-xs select_none-perm" data-perm="can_upload_attachments"><i class="fa fa-square-o fa-fw"></i></button>
</th>
<th class="perm can_rebuild_site">Rebuild<br>
<button type="button" class="btn btn-info btn-xs select_all-perm" data-perm="can_rebuild_site"><i class="fa fa-check-square-o fa-fw"></i></button>
<button type="button" class="btn btn-info btn-xs select_none-perm" data-perm="can_rebuild_site"><i class="fa fa-square-o fa-fw"></i></button>
</th>
<th class="perm can_transfer_post_authorship">Transfer authorship<br>
<button type="button" class="btn btn-info btn-xs select_all-perm" data-perm="can_transfer_post_authorship"><i class="fa fa-check-square-o fa-fw"></i></button>
<button type="button" class="btn btn-info btn-xs select_none-perm" data-perm="can_transfer_post_authorship"><i class="fa fa-square-o fa-fw"></i></button>
</th>
<th class="select_all">Select all</th>
</tr></thead>
% for uid, user in USERS.items():
@@ -79,7 +100,7 @@ $(document).ready(function() {
% for p in PERMISSIONS:
<td class="perm ${p}">${display_permission(user, p)}</td>
% endfor
<td class="select_all info"><i class="fa fa-check-square-o fa-fw" data-uid="${uid}"></i><i class="fa fa-square-o fa-fw" data-uid="${uid}"></i></td>
<td class="select_all"><button type="button" class="btn btn-info select_all-user" data-uid="${uid}"><i class="fa fa-check-square-o fa-fw"></i></button> <button type="button" class="btn btn-info select_none-user" data-uid="${uid}"><i class="fa fa-square-o fa-fw"></i></button></td>
</tr>
% endif
% endfor
@@ -9,7 +9,7 @@
"password": "$2a$12$.qMCcA2uOo0BKkDtEF/bueYtHjcdPBmfEdpxtktRwRTgsR7ZVTWmW",
"realname": "Website Administrator",
"username": "admin",
"wants_all_posts": false
"wants_all_posts": true
},
"2": {
"active": true,
@@ -21,14 +21,14 @@
"password": "$2a$12$GlbUlIMPBhLeWbQfK07g8uKsc8LO9P5gI7MyWsRpKt5exajp7ySoK",
"realname": "User Two",
"username": "user2",
"wants_all_posts": false
"wants_all_posts": true
},
"3": {
"active": true,
"can_edit_all_posts": false,
"can_rebuild_site": false,
"can_transfer_post_authorship": false,
"can_upload_attachments": false,
"can_rebuild_site": true,
"can_transfer_post_authorship": true,
"can_upload_attachments": true,
"is_admin": false,
"password": "$2a$12$LGFk3vhXFXA75ZwYIPV6o.Bv/ING9dfSxNroTXQ15tQpjGW9FjCU2",
"realname": "User Three",
@@ -37,14 +37,14 @@
},
"4": {
"active": true,
"can_edit_all_posts": true,
"can_rebuild_site": true,
"can_transfer_post_authorship": true,
"can_upload_attachments": true,
"can_edit_all_posts": false,
"can_rebuild_site": false,
"can_transfer_post_authorship": false,
"can_upload_attachments": false,
"is_admin": false,
"password": "$2a$12$7fQihZDxHFayBkUAX2LSgeAX9m8MAkx2jovDv3B6WW47e1UfVV2Ue",
"realname": "User Four",
"username": "user4",
"wants_all_posts": true
"wants_all_posts": false
}
}

0 comments on commit c98551e

Please sign in to comment.