From b96f72e16eea21ac93a1e6ee906d42220d0a060b Mon Sep 17 00:00:00 2001 From: John Martin Date: Wed, 12 Sep 2012 11:15:28 +0100 Subject: [PATCH] Organizations member admin now has new template --- ckan/controllers/organization.py | 2 +- .../javascript/modules/organization-users.js | 21 +++++++ ckan/public/base/less/forms.less | 32 ++++++++++ ckan/templates/organization/read.html | 4 +- ckan/templates/organization/users.html | 27 ++++++++ ckan/templates/organization/users_form.html | 62 +++++++++++++++++++ ckan/templates/snippets/scripts.html | 1 + 7 files changed, 146 insertions(+), 3 deletions(-) create mode 100644 ckan/public/base/javascript/modules/organization-users.js create mode 100644 ckan/templates/organization/users.html create mode 100644 ckan/templates/organization/users_form.html diff --git a/ckan/controllers/organization.py b/ckan/controllers/organization.py index 3a96fe49e7f..8936e06b704 100644 --- a/ckan/controllers/organization.py +++ b/ckan/controllers/organization.py @@ -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) diff --git a/ckan/public/base/javascript/modules/organization-users.js b/ckan/public/base/javascript/modules/organization-users.js new file mode 100644 index 00000000000..9b85fc3a749 --- /dev/null +++ b/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'); + }); + } + } +}); diff --git a/ckan/public/base/less/forms.less b/ckan/public/base/less/forms.less index df7377d7249..c6ba8b40196 100644 --- a/ckan/public/base/less/forms.less +++ b/ckan/public/base/less/forms.less @@ -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; + } + } +} diff --git a/ckan/templates/organization/read.html b/ckan/templates/organization/read.html index 070c4d377b7..70773e210ae 100644 --- a/ckan/templates/organization/read.html +++ b/ckan/templates/organization/read.html @@ -11,9 +11,9 @@ {% if h.check_access('organization_update', {'id': c.organization.id}) %}
  • {% link_for _('Add Dataset'), controller='package', action='new', organization=c.organization_dict.id, class_='btn', icon='plus' %}
  • {% link_for _('Edit'), controller='organization', action='edit', id=c.organization_dict.name, class_='btn', icon='cog' %}
  • -
  • {% link_for _('Manage Users'), controller='organization', action='users', id=c.organization_dict.name, class_='btn', icon='cog' %}
  • +
  • {% link_for _('Manage Users'), controller='organization', action='users', id=c.organization_dict.name, class_='btn', icon='group' %}
  • {% else %} -
  • {% link_for _('Join organization'), controller='organization', action='apply', id=c.organization_dict.name, class_='btn', icon='cog' %}
  • +
  • {% link_for _('Join organization'), controller='organization', action='apply', id=c.organization_dict.name, class_='btn', icon='plus' %}
  • {% endif %} {#
  • {% link_for _('History'), controller='organization', action='history', id=c.organization_dict.name, class_='btn', icon='undo' %}
  • #} {% endblock %} diff --git a/ckan/templates/organization/users.html b/ckan/templates/organization/users.html new file mode 100644 index 00000000000..e1b133f9e2c --- /dev/null +++ b/ckan/templates/organization/users.html @@ -0,0 +1,27 @@ +{% extends "page.html" %} + +{% block subtitle %}{{ c.organization.display_name }}{% endblock %} + +{% block breadcrumb_content %} +
  • {% link_for _('Organizations'), controller='organization', action='index' %}
  • +
  • {% link_for c.organization.display_name|truncate(35), controller='organization', action='users', id=c.organization.name %}
  • +{% endblock %} + +{% block actions_content %} +
  • {% link_for _('Back to organization'), controller='organization', action='read', id=c.organization.name, class_='btn', icon='caret-left' %}
  • +{% endblock %} + +{% block primary_content %} +
    +
    +

    {% block page_heading %}{{ _('Manage Users') }}{% endblock %}

    + {% block form %} + {{ c.form | safe }} + {% endblock %} +
    +
    +{% endblock %} + +{% block secondary_content %} + {% snippet 'snippets/organization.html', organization=c.organization %} +{% endblock %} diff --git a/ckan/templates/organization/users_form.html b/ckan/templates/organization/users_form.html new file mode 100644 index 00000000000..fee193c129f --- /dev/null +++ b/ckan/templates/organization/users_form.html @@ -0,0 +1,62 @@ +{% import 'macros/form.html' as form %} + +
    + + + {{ form.errors(error_summary) }} + + + + + + + + + + + + + + + + {% for user in data.users %} + + + + + + {% endfor %} + +
    {{ _('User') }}{{ _('Role') }}{{ _('Actions') }}
    {{ user.name }} +
    + + +
    +
    +
    + +
    +
    + + {{ _('Add user') }} +
    + +
    + +
    +
    + +
    + +
    + +
    diff --git a/ckan/templates/snippets/scripts.html b/ckan/templates/snippets/scripts.html index 30aacead011..46b2809beee 100644 --- a/ckan/templates/snippets/scripts.html +++ b/ckan/templates/snippets/scripts.html @@ -29,6 +29,7 @@ + {% if config.get('ckan.tracking_enabled', 'false') %} {% snippet 'snippets/internal_tracking.html' %} {% endif %}