Skip to content

Commit

Permalink
[#2375] start of admin template fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
tobes committed Jul 24, 2012
1 parent 46381d6 commit 9fb1d16
Show file tree
Hide file tree
Showing 2 changed files with 187 additions and 0 deletions.
161 changes: 161 additions & 0 deletions ckan/templates/admin/authz.html
@@ -0,0 +1,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 %}
26 changes: 26 additions & 0 deletions ckan/templates/admin/index.html
@@ -0,0 +1,26 @@
{% extends "page.html" %}

{% block title %}{{ _('Administration') }} - {{ super() }}{% endblock %}

{% block breadcrumb_content %}
{% endblock %}

{% block primary %}
<article class="module">
<div class="module-content">
<h1 class="page-heading">{{ _('Current Sysadmins') }}</h1>
<p>You can change sysadmins on the
<a href="{% url_for controller='admin', action='authz' %}">authorization page</a>
.</p>
<ul>
{% for user in c.sysadmins %}
<li py:for="user in c.sysadmins">
{{ h.linked_user(user) }}
</li>
{% endfor %}
</ul>
</div>
</article>
{% endblock %}

{% block sidebar %}{% endblock %}

0 comments on commit 9fb1d16

Please sign in to comment.