From db28796b61f4eef590d979435521c39bd867668e Mon Sep 17 00:00:00 2001 From: Ross Jones Date: Wed, 29 Aug 2012 13:45:54 +0100 Subject: [PATCH] Tidying up the legacy organization templates, and create skeletons for new templates. Currently requires user management templates, applying for membership and a plan for how to integrate the organisation IDatasetForm into the dataset form for auto-adding to group. --- ckanext/organizations/controllers.py | 13 ++--- ckanext/organizations/forms.py | 12 ++--- .../templates/organizations/form.html | 42 +++++++++++++++++ .../templates/organizations/index.html | 41 ++++++++++++++++ .../templates/organizations/new.html | 19 ++++++++ .../templates/organizations/read.html | 47 +++++++++++++++++++ .../templates/organizations/users.html | 0 .../templates/organizations/users_form.html | 0 .../apply.html} | 2 +- .../apply_form.html} | 0 .../email/join_publisher_request.txt | 0 .../form.html} | 0 .../history.html} | 2 +- .../index.html} | 2 +- .../layout.html} | 2 +- .../new.html} | 2 +- .../package_form.html} | 0 .../read.html} | 2 +- .../users.html} | 2 +- .../users_form.html} | 0 20 files changed, 169 insertions(+), 19 deletions(-) create mode 100644 ckanext/organizations/templates/organizations/form.html create mode 100644 ckanext/organizations/templates/organizations/index.html create mode 100644 ckanext/organizations/templates/organizations/new.html create mode 100644 ckanext/organizations/templates/organizations/read.html create mode 100644 ckanext/organizations/templates/organizations/users.html create mode 100644 ckanext/organizations/templates/organizations/users_form.html rename ckanext/organizations/templates_legacy/{organization_apply.html => organizations/apply.html} (86%) rename ckanext/organizations/templates_legacy/{organization_apply_form.html => organizations/apply_form.html} (100%) rename ckanext/organizations/templates_legacy/{ => organizations}/email/join_publisher_request.txt (100%) rename ckanext/organizations/templates_legacy/{organization_form.html => organizations/form.html} (100%) rename ckanext/organizations/templates_legacy/{organization_history.html => organizations/history.html} (97%) rename ckanext/organizations/templates_legacy/{organization_index.html => organizations/index.html} (94%) rename ckanext/organizations/templates_legacy/{organization_layout.html => organizations/layout.html} (98%) rename ckanext/organizations/templates_legacy/{organization_new.html => organizations/new.html} (86%) rename ckanext/organizations/templates_legacy/{organization_package_form.html => organizations/package_form.html} (100%) rename ckanext/organizations/templates_legacy/{organization_read.html => organizations/read.html} (98%) rename ckanext/organizations/templates_legacy/{organization_users.html => organizations/users.html} (87%) rename ckanext/organizations/templates_legacy/{organization_users_form.html => organizations/users_form.html} (100%) diff --git a/ckanext/organizations/controllers.py b/ckanext/organizations/controllers.py index 371b2141d98..56bba8f30e6 100644 --- a/ckanext/organizations/controllers.py +++ b/ckanext/organizations/controllers.py @@ -51,8 +51,9 @@ def _send_application( self, group, reason ): 'requester': c.userobj, 'reason' : reason } - email_msg = render("email/join_publisher_request.txt", extra_vars=extra_vars, - loader_class=NewTextTemplate) + email_msg = render("organizations/email/join_publisher_request.txt", + extra_vars=extra_vars, + loader_class=NewTextTemplate) try: for (name,recipient) in recipients: @@ -90,8 +91,8 @@ def apply(self, id=None, data=None, errors=None, error_summary=None): data.update(request.params) vars = {'data': data, 'errors': errors, 'error_summary': error_summary} - c.form = render('organization_apply_form.html', extra_vars=vars) - return render('organization_apply.html') + c.form = render('organizations/apply_form.html', extra_vars=vars) + return render('organizations/apply.html') def _add_users( self, group, parameters ): if not group: @@ -161,9 +162,9 @@ def users(self, id, data=None, errors=None, error_summary=None): for user in c.group.members_of_type( model.User, 'editor' ).all() ) vars = {'data': data, 'errors': errors, 'error_summary': error_summary} - c.form = render('organization_users_form.html', extra_vars=vars) + c.form = render('organizations/users_form.html', extra_vars=vars) - return render('organization_users.html') + return render('organizations/users.html') def _add_publisher_list(self): c.possible_parents = model.Session.query(model.Group).\ diff --git a/ckanext/organizations/forms.py b/ckanext/organizations/forms.py index 4318b73c490..629413b2a5f 100644 --- a/ckanext/organizations/forms.py +++ b/ckanext/organizations/forms.py @@ -80,35 +80,35 @@ def new_template(self): Returns a string representing the location of the template to be rendered for the new page """ - return 'organization_new.html' + return 'organizations/new.html' def index_template(self): """ Returns a string representing the location of the template to be rendered for the index page """ - return 'organization_index.html' + return 'organizations/index.html' def read_template(self): """ Returns a string representing the location of the template to be rendered for the read page """ - return 'organization_read.html' + return 'organizations/read.html' def history_template(self): """ Returns a string representing the location of the template to be rendered for the read page """ - return 'organization_history.html' + return 'organizations/history.html' def group_form(self): """ Returns a string representing the location of the template to be rendered. e.g. "forms/group_form.html". """ - return 'organization_form.html' + return 'organizations/form.html' def group_types(self): """ @@ -228,7 +228,7 @@ def history_template(self): return 'package/history.html' def package_form(self): - return 'organization_package_form.html' + return 'organizations/package_form.html' def db_to_form_schema(self): '''This is an interface to manipulate data from the database diff --git a/ckanext/organizations/templates/organizations/form.html b/ckanext/organizations/templates/organizations/form.html new file mode 100644 index 00000000000..01d57727822 --- /dev/null +++ b/ckanext/organizations/templates/organizations/form.html @@ -0,0 +1,42 @@ +{% extends "group/snippets/group_form.html" %} + +{# +As the form is rendered as a seperate page we take advantage of this by +overriding the form blocks depending on the current context +#} +{% block dataset_fields %} + {% if action == "edit" %}{{ super() }}{% endif %} +{% endblock %} + +{% block custom_fields %} + {% if action == "edit" %}{{ super() }}{% endif %} +{% endblock %} + +{% block save_text %} + {%- if action == "edit" -%} + {{ _('Update Organization') }} + {%- else -%} + {{ _('Create Organization') }} + {%- endif -%} +{% endblock %} + +{% block delete_button %} + {% if action == "edit" %}{{ super() }}{% endif %} +{% endblock %} + +{% block basic_fields %} + {% set attrs = {'data-module': 'slug-preview-target'} %} + {{ form.input('title', label=_('Title'), id='field-title', placeholder=_('My Organization'), value=data.title, error=errors.title, classes=['control-full'], attrs=attrs) }} + + {% set prefix = h.url_for(controller='group', action='read', id='') %} + {% set domain = h.url_for(controller='group', action='read', id='', qualified=true) %} + {% set domain = domain|replace("http://", "")|replace("https://", "") %} + {% set attrs = {'data-module': 'slug-preview-slug', 'data-module-prefix': domain, 'data-module-placeholder': ''} %} + + {{ form.prepend('name', label=_('URL'), prepend=prefix, id='field-url', placeholder=_('my-organization'), value=data.name, error=errors.name, attrs=attrs) }} + + {{ form.markdown('description', label=_('Description'), id='field-description', placeholder=_('A little information about my organization...'), value=data.description, error=errors.description) }} + + {{ form.input('image_url', label=_('Image URL'), id='field-image-url', type='url', placeholder=_('http://example.com/my-image.jpg'), value=data.image_url, error=errors.image_url, classes=['control-full']) }} + + {% endblock %} \ No newline at end of file diff --git a/ckanext/organizations/templates/organizations/index.html b/ckanext/organizations/templates/organizations/index.html new file mode 100644 index 00000000000..41532b77b87 --- /dev/null +++ b/ckanext/organizations/templates/organizations/index.html @@ -0,0 +1,41 @@ +{% extends "page.html" %} + +{% block subtitle %}{{ _('Organization') }}{% endblock %} + +{% block breadcrumb_content %} +
  • {% link_for _('Organizations'), controller='group', action='index' %}
  • +{% endblock %} + +{% block actions_content %} +
  • {% link_for _('Add Organization'), controller='group', action='new', class_='btn', icon='plus' %}
  • +{% endblock %} + +{% block primary_content %} +
    +
    +

    {{ _('Organizations') }}

    + {% if c.page.items %} + {% snippet "group/snippets/group_list.html", groups=c.page.items %} + {% else %} +

    + {{ _('There are currently no organizations for this site') }}. + {% if h.check_access('package_create') %} + {% link_for _('How about creating one?'), controller='group', action='new' %}. + {% endif %} +

    + {% endif %} +
    + {{ c.page.pager() }} +
    +{% endblock %} + +{% block secondary_content %} +
    +

    {{ _('What are Organizations?') }}

    +
    + {% trans %} +

    Organizations allow you to add both users and datasets to it in order to control who can access and manage your datasets

    + {% endtrans %} +
    +
    +{% endblock %} diff --git a/ckanext/organizations/templates/organizations/new.html b/ckanext/organizations/templates/organizations/new.html new file mode 100644 index 00000000000..73a284f46a3 --- /dev/null +++ b/ckanext/organizations/templates/organizations/new.html @@ -0,0 +1,19 @@ +{% extends "group/base_form_page.html" %} + +{% block subtitle %}{{ _('Create an organization') }}{% endblock %} + +{% block breadcrumb_link %}{{ h.nav_link(_('Create Organization'), controller='group', action='edit', id=c.group.name) }}{% endblock %} + +{% block page_heading %}{{ _('Create an organization') }}{% endblock %} + +{% block secondary_content %} +
    +

    {{ _('What are Organizations?') }}

    +
    + {% trans %} +

    An organization can be set-up to specify which users have permission to add or + remove datasets from it.

    + {% endtrans %} +
    +
    +{% endblock %} diff --git a/ckanext/organizations/templates/organizations/read.html b/ckanext/organizations/templates/organizations/read.html new file mode 100644 index 00000000000..c3a66ca1f84 --- /dev/null +++ b/ckanext/organizations/templates/organizations/read.html @@ -0,0 +1,47 @@ +{% extends "page.html" %} + +{% block subtitle %}{{ c.group_dict.display_name }}{% endblock %} + +{% block breadcrumb_content %} +
  • {% link_for _('Organizations'), controller='group', action='index' %}
  • +
  • {% link_for c.group_dict.display_name|truncate(35), controller='group', action='read', id=c.group_dict.name %}
  • +{% endblock %} + +{% block actions_content %} + {% if h.check_access('group_update', {'id': c.group.id}) %} +
  • {% link_for _('Add Dataset to Organization'), controller='package', action='new', group=c.group_dict.id, class_='btn', icon='plus' %}
  • +
  • {% link_for _('Edit'), controller='group', action='edit', id=c.group_dict.name, class_='btn', icon='cog' %}
  • +
  • {% link_for _('Manage Users'), controller='ckanext.organizations.controllers:OrganizationController', action='users', id=c.group_dict.name, class_='btn', icon='cog' %}
  • + {% endif %} + {#
  • {% link_for _('History'), controller='group', action='history', id=c.group_dict.name, class_='btn', icon='undo' %}
  • #} +{% endblock %} + +{% block primary_content %} +
    +
    + {% include "package/snippets/search_form.html" %} +
    + {{ c.page.pager(q=c.q) }} +
    +{% endblock %} + +{% block secondary_content %} + {% snippet 'snippets/group.html', group=c.group_dict %} + +
    +

    {{ _('Administrators') }}

    + +
    + + {{ h.snippet('snippets/facet_list.html', title='Tags', name='tags', extras={'id':c.group_dict.id}) }} + {{ h.snippet('snippets/facet_list.html', title='Formats', name='res_format', extras={'id':c.group_dict.id}) }} +{% endblock %} + +{% block links %} + {{ super() }} + {% include "group/snippets/feeds.html" %} +{% endblock %} diff --git a/ckanext/organizations/templates/organizations/users.html b/ckanext/organizations/templates/organizations/users.html new file mode 100644 index 00000000000..e69de29bb2d diff --git a/ckanext/organizations/templates/organizations/users_form.html b/ckanext/organizations/templates/organizations/users_form.html new file mode 100644 index 00000000000..e69de29bb2d diff --git a/ckanext/organizations/templates_legacy/organization_apply.html b/ckanext/organizations/templates_legacy/organizations/apply.html similarity index 86% rename from ckanext/organizations/templates_legacy/organization_apply.html rename to ckanext/organizations/templates_legacy/organizations/apply.html index e4450a52a89..d88eee54370 100644 --- a/ckanext/organizations/templates_legacy/organization_apply.html +++ b/ckanext/organizations/templates_legacy/organizations/apply.html @@ -10,6 +10,6 @@ ${Markup(c.form)} - + diff --git a/ckanext/organizations/templates_legacy/organization_apply_form.html b/ckanext/organizations/templates_legacy/organizations/apply_form.html similarity index 100% rename from ckanext/organizations/templates_legacy/organization_apply_form.html rename to ckanext/organizations/templates_legacy/organizations/apply_form.html diff --git a/ckanext/organizations/templates_legacy/email/join_publisher_request.txt b/ckanext/organizations/templates_legacy/organizations/email/join_publisher_request.txt similarity index 100% rename from ckanext/organizations/templates_legacy/email/join_publisher_request.txt rename to ckanext/organizations/templates_legacy/organizations/email/join_publisher_request.txt diff --git a/ckanext/organizations/templates_legacy/organization_form.html b/ckanext/organizations/templates_legacy/organizations/form.html similarity index 100% rename from ckanext/organizations/templates_legacy/organization_form.html rename to ckanext/organizations/templates_legacy/organizations/form.html diff --git a/ckanext/organizations/templates_legacy/organization_history.html b/ckanext/organizations/templates_legacy/organizations/history.html similarity index 97% rename from ckanext/organizations/templates_legacy/organization_history.html rename to ckanext/organizations/templates_legacy/organizations/history.html index acf10d1db35..227bf1b9a42 100644 --- a/ckanext/organizations/templates_legacy/organization_history.html +++ b/ckanext/organizations/templates_legacy/organizations/history.html @@ -55,5 +55,5 @@

    href="${h.url(controller='group', action='history', id=c.group_dict['name'], format='atom', days=7)}" /> - + diff --git a/ckanext/organizations/templates_legacy/organization_index.html b/ckanext/organizations/templates_legacy/organizations/index.html similarity index 94% rename from ckanext/organizations/templates_legacy/organization_index.html rename to ckanext/organizations/templates_legacy/organizations/index.html index f5b200f48d0..cbf38919286 100644 --- a/ckanext/organizations/templates_legacy/organization_index.html +++ b/ckanext/organizations/templates_legacy/organizations/index.html @@ -20,5 +20,5 @@

    What Are Organizations?

    ${c.page.pager()} - + diff --git a/ckanext/organizations/templates_legacy/organization_layout.html b/ckanext/organizations/templates_legacy/organizations/layout.html similarity index 98% rename from ckanext/organizations/templates_legacy/organization_layout.html rename to ckanext/organizations/templates_legacy/organizations/layout.html index 0e4c8c4a431..7e740e9bd3a 100644 --- a/ckanext/organizations/templates_legacy/organization_layout.html +++ b/ckanext/organizations/templates_legacy/organizations/layout.html @@ -40,5 +40,5 @@ - + diff --git a/ckanext/organizations/templates_legacy/organization_new.html b/ckanext/organizations/templates_legacy/organizations/new.html similarity index 86% rename from ckanext/organizations/templates_legacy/organization_new.html rename to ckanext/organizations/templates_legacy/organizations/new.html index 06a155136db..642d57f5b5e 100644 --- a/ckanext/organizations/templates_legacy/organization_new.html +++ b/ckanext/organizations/templates_legacy/organizations/new.html @@ -9,6 +9,6 @@ ${Markup(c.form)} - + diff --git a/ckanext/organizations/templates_legacy/organization_package_form.html b/ckanext/organizations/templates_legacy/organizations/package_form.html similarity index 100% rename from ckanext/organizations/templates_legacy/organization_package_form.html rename to ckanext/organizations/templates_legacy/organizations/package_form.html diff --git a/ckanext/organizations/templates_legacy/organization_read.html b/ckanext/organizations/templates_legacy/organizations/read.html similarity index 98% rename from ckanext/organizations/templates_legacy/organization_read.html rename to ckanext/organizations/templates_legacy/organizations/read.html index f7f9a1a48e8..a0224c00bca 100644 --- a/ckanext/organizations/templates_legacy/organization_read.html +++ b/ckanext/organizations/templates_legacy/organizations/read.html @@ -77,5 +77,5 @@

    Datasets

    - + diff --git a/ckanext/organizations/templates_legacy/organization_users.html b/ckanext/organizations/templates_legacy/organizations/users.html similarity index 87% rename from ckanext/organizations/templates_legacy/organization_users.html rename to ckanext/organizations/templates_legacy/organizations/users.html index 21ae7cfecea..9b5e47d9dbf 100644 --- a/ckanext/organizations/templates_legacy/organization_users.html +++ b/ckanext/organizations/templates_legacy/organizations/users.html @@ -10,7 +10,7 @@ ${Markup(c.form)} - + diff --git a/ckanext/organizations/templates_legacy/organization_users_form.html b/ckanext/organizations/templates_legacy/organizations/users_form.html similarity index 100% rename from ckanext/organizations/templates_legacy/organization_users_form.html rename to ckanext/organizations/templates_legacy/organizations/users_form.html