Parent: [42ec21] (diff)

Child: [0d6290] (diff)

Download this file

project_roles.html    103 lines (97 with data), 3.8 kB

  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
{% extends g.theme.master %}
{% macro role_select(name) %}
<select name="{{name}}">
{% for r in c.project.roles %}
<option value="{{r._id}}">{{r.display()}}</option>
{% endfor %}
</select>
{% endmacro %}
{% block title %}{{c.project.name}} / Roles{% endblock %}
{% block header %}Project Roles for {{c.project.shortname}}{% endblock %}
{% block content %}
{% if c.project.deleted %}
<div class="notice">This project has been deleted and is not visible to non-admin users</div>
{% endif %}
<p>
Each user on the project has a private role.
Each role can have subroles. A role inherits all the permissions
that its subroles have. All users who have read access should
automatically appear here.
</p>
<form method="POST" action="update_roles" id="roles_form">
{% for r in c.project.roles %}
<input py:for=""
type="hidden"
name="role-{{loop.index0}}.id"
value="{{r._id}}"/>
{% endfor %}
<table>
<thead>
<tr>
<th>User</th>
<th>Roles</th>
<th>Edit</th>
<th/>
</tr>
</thead>
<tbody>
{% for r in c.project.roles %}
<tr class="{{loop.cycle('', 'even')}}">
<td>{{r.display()}}</td>
<td>
{% set i = loop.index0 %}
{% for sr in h.make_roles(r.roles) %}
<span class="removable">
{{sr.display()}}
<input type="hidden" name="role-{{i}}.subroles-{{loop.index0}}.id" value="{{sr._id}}"/>
<!-- <input type="submit" name="role-{{i}}.subroles-{{loop.index0}}.delete" value="Del"/> -->
</span>
{% endfor %}
</td>
<td>
Acts as
<select name="role-{{loop.index0}}.new.id" style="width: 100px" class="add_role">
<option value=""> </option>
{% for r in roles if not r.special %}
<option value="{{r._id}}">
{{r.display()}}
</option>
{% endfor %}
</select>
{% if not r.special %}
<input name="role-{{loop.index0}}.delete" type="submit" value="Delete" />
{% endif %}
</td>
</tr>
{% endfor %}
<tr>
<td><input name="new.name" class="title"/></td>
<td colspan="3">
<input type="submit" name="new.add" value="Create Role"
/>
</td>
</tr>
</tbody>
</table>
</form>
{% endblock %}
{% block extra_js %}
<script type="text/javascript">
/*<![CDATA[*/
$('span.removable').click(function(e){
var vals = $('#roles_form').serialize();
var del_name = $('input', this)[0].name.replace('.id','.delete');
$.post($('#roles_form')[0].action, vals+'&'+del_name+'=Del', function(){
e.target.parentNode.removeChild(e.target);
});
});
$('select.add_role').change(function(e){
var vals = $('#roles_form').serialize();
var add_name = e.target.name.replace('.id','.add');
$.post($('#roles_form')[0].action, vals+'&'+add_name+'=Add', function(){
window.location.reload();
});
});
/*]]>*/
</script>
{% endblock %}