Skip to content

Commit

Permalink
Organizations member admin now has new template
Browse files Browse the repository at this point in the history
  • Loading branch information
johnmartin committed Sep 12, 2012
1 parent 7f37d12 commit b96f72e
Show file tree
Hide file tree
Showing 7 changed files with 146 additions and 3 deletions.
2 changes: 1 addition & 1 deletion ckan/controllers/organization.py
Expand Up @@ -506,7 +506,7 @@ def _add_users(self, group, parameters):
model_save.group_member_save(context, data_dict, 'users')
model.Session.commit()

h.redirect_to(controller='organization', action='edit', id=group.name)
h.redirect_to(controller='organization', action='users', id=group.name)

def users(self, id, data=None, errors=None, error_summary=None):
c.organization = model.Group.get(id)
Expand Down
21 changes: 21 additions & 0 deletions ckan/public/base/javascript/modules/organization-users.js
@@ -0,0 +1,21 @@
/*
* Module for the organizations users table
*/
this.ckan.module('organization-users', function ($, _) {
return {
initialize: function () {
// convert all the keep labels into buttons
$('.orginization-remove', this.el).each(function() {
$(this).addClass('btn btn-danger pull-right checkbox');
$('span', this).html('').addClass('icon-remove');
});
// ok checkbox change toggle the disabled state for display
this.el.on('change', '.orginization-remove :checkbox', function() {
var row = $(this).parents('tr');
row.toggleClass('disabled');
$('input[type=radio]', row).prop('disabled', !$(this).prop('checked'));
$('.btn', row).toggleClass('btn-info');
});
}
}
});
32 changes: 32 additions & 0 deletions ckan/public/base/less/forms.less
Expand Up @@ -673,3 +673,35 @@ textarea {
font-weight: normal !important;
}
}

.organization-form-users {
font-size: 14px;
td.username {
font-weight: bold;
line-height: 28px;
}
table .control-group {
line-height: 1;
margin: 0;
label.radio {
margin-top: 0;
padding-top: 0;
}
}
.disabled {
label,
td {
color: #999;
text-decoration: line-through !important;
}
.btn {
color: #FFF !important;
}
}
.orginization-remove.btn {
border-radius: 100px;
input {
display: none;
}
}
}
4 changes: 2 additions & 2 deletions ckan/templates/organization/read.html
Expand Up @@ -11,9 +11,9 @@
{% if h.check_access('organization_update', {'id': c.organization.id}) %}
<li>{% link_for _('Add Dataset'), controller='package', action='new', organization=c.organization_dict.id, class_='btn', icon='plus' %}</li>
<li>{% link_for _('Edit'), controller='organization', action='edit', id=c.organization_dict.name, class_='btn', icon='cog' %}</li>
<li>{% link_for _('Manage Users'), controller='organization', action='users', id=c.organization_dict.name, class_='btn', icon='cog' %}</li>
<li>{% link_for _('Manage Users'), controller='organization', action='users', id=c.organization_dict.name, class_='btn', icon='group' %}</li>
{% else %}
<li>{% link_for _('Join organization'), controller='organization', action='apply', id=c.organization_dict.name, class_='btn', icon='cog' %}</li>
<li>{% link_for _('Join organization'), controller='organization', action='apply', id=c.organization_dict.name, class_='btn', icon='plus' %}</li>
{% endif %}
{# <li>{% link_for _('History'), controller='organization', action='history', id=c.organization_dict.name, class_='btn', icon='undo' %}</li> #}
{% endblock %}
Expand Down
27 changes: 27 additions & 0 deletions ckan/templates/organization/users.html
@@ -0,0 +1,27 @@
{% extends "page.html" %}

{% block subtitle %}{{ c.organization.display_name }}{% endblock %}

{% block breadcrumb_content %}
<li>{% link_for _('Organizations'), controller='organization', action='index' %}</li>
<li class="active">{% link_for c.organization.display_name|truncate(35), controller='organization', action='users', id=c.organization.name %}</li>
{% endblock %}

{% block actions_content %}
<li>{% link_for _('Back to organization'), controller='organization', action='read', id=c.organization.name, class_='btn', icon='caret-left' %}</li>
{% endblock %}

{% block primary_content %}
<section class="module">
<div class="module-content">
<h1 class="page-heading">{% block page_heading %}{{ _('Manage Users') }}{% endblock %}</h1>
{% block form %}
{{ c.form | safe }}
{% endblock %}
</div>
</section>
{% endblock %}

{% block secondary_content %}
{% snippet 'snippets/organization.html', organization=c.organization %}
{% endblock %}
62 changes: 62 additions & 0 deletions ckan/templates/organization/users_form.html
@@ -0,0 +1,62 @@
{% import 'macros/form.html' as form %}

<form class="form-horizontal organization-form-users" method="post" data-module="organization-users">
<input type="hidden" name="type" value="organization">

{{ form.errors(error_summary) }}

<table class="table table-bordered table-striped">
<colgroup>
<col width="58%">
<col width="30%">
<col width="12%">
</colgroup>
<thead>
<tr>
<th>{{ _('User') }}</th>
<th>{{ _('Role') }}</th>
<th><span class="pull-right">{{ _('Actions') }}</span></th>
</tr>
</thead>
<tbody>
{% for user in data.users %}
<tr>
<td class="username">{{ user.name }}</td>
<td>
<div class="control-group">
<label class="radio inline">
<input type="radio" name="users__{{ loop.index0 + 1 }}__capacity" value="admin" {{"checked" if (user or {}).get('capacity','') == 'admin' else ''}}>
{{ _('Admin') }}
</label>
<label class="radio inline">
<input type="radio" name="users__{{ loop.index0 + 1 }}__capacity" value="editor" {{"checked" if (user or {}).get('capacity','') in ['editor', 'member', ''] else ''}}>
{{ _('Editor') }}
</label>
</div>
</td>
<td>
<div class="control-group">
<label class="orginization-remove">
<input id="users__{{ loop.index0 + 1 }}__name" name="users__{{ loop.index0 + 1 }}__name" type="checkbox" value="{{ user.name }}" checked="checked">
<span>{{ _('Keep this user?') }}</span>
</label>
</div>
</td>
</tr>
{% endfor %}
</tbody>
</table>

<legend>{{ _('Add user') }}</legend>
<div class="control-group organization-adduser">
<label for="users__0__name" class="control-label">{{ _('Username') }}</label>
<div class="controls">
<input id="users__0__name" name="users__0__name" type="text">
</div>
</div>

<div class="form-actions">
<button name="save" type="submit" class="btn btn-primary">{{ _('Save') }}</button>
</div>

</form>
1 change: 1 addition & 0 deletions ckan/templates/snippets/scripts.html
Expand Up @@ -29,6 +29,7 @@
<script src="{% url_for_static '/base/javascript/modules/autocomplete.js' %}"></script>
<script src="{% url_for_static '/base/javascript/modules/custom-fields.js' %}"></script>
<script src="{% url_for_static '/base/javascript/modules/related-item.js' %}"></script>
<script src="{% url_for_static '/base/javascript/modules/organization-users.js' %}"></script>
{% if config.get('ckan.tracking_enabled', 'false') %}
{% snippet 'snippets/internal_tracking.html' %}
{% endif %}

0 comments on commit b96f72e

Please sign in to comment.