{% endblock %} + +{% block main_content %} +
+
+

{{ _('Are you sure you want to delete group - {name}?').format(name=c.group_dict.name) }}

+

+

+ + +
+

+
+
+{% endblock %} diff --git a/ckan/templates/organization/edit.html b/ckan/templates/organization/edit.html new file mode 100644 index 00000000000..09e4f8801f1 --- /dev/null +++ b/ckan/templates/organization/edit.html @@ -0,0 +1,7 @@ +{% extends "organization/base_form_page.html" %} + +{% block subtitle %}{{ _('Edit a Organization') }}{% endblock %} + +{% block breadcrumb_link %}{% link_for _('Edit Organization'), controller='organization', action='edit', id=c.group.name %}{% endblock %} + +{% block page_heading %}{{ _('Edit a Organization') }}{% endblock %} diff --git a/ckan/templates/organization/index.html b/ckan/templates/organization/index.html new file mode 100644 index 00000000000..018bf420a53 --- /dev/null +++ b/ckan/templates/organization/index.html @@ -0,0 +1,41 @@ +{% extends "page.html" %} + +{% block subtitle %}{{ _('Organizations of Datasets') }}{% endblock %} + +{% block breadcrumb_content %} +
  • {% link_for _('Organizations'), controller='organization', action='index' %}
  • +{% endblock %} + +{% block actions_content %} +
  • {% link_for _('Add Organization'), controller='organization', action='new', class_='btn', icon='plus' %}
  • +{% endblock %} + +{% block primary_content %} +
    +
    +

    {{ _('Organizations') }}

    + {% if c.page.items %} + {% snippet "organization/snippets/organization_list.html", organizations=c.page.items %} + {% else %} +

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

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

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

    +
    + {% trans %} +

    I have no idea

    + {% endtrans %} +
    +
    +{% endblock %} diff --git a/ckan/templates/organization/new.html b/ckan/templates/organization/new.html new file mode 100644 index 00000000000..859db1ee3b9 --- /dev/null +++ b/ckan/templates/organization/new.html @@ -0,0 +1,7 @@ +{% extends "organization/base_form_page.html" %} + +{% block subtitle %}{{ _('Create a Organization') }}{% endblock %} + +{% block breadcrumb_link %}{{ h.nav_link(_('Create Organization'), controller='organization', action='edit', id=c.organization.name) }}{% endblock %} + +{% block page_heading %}{{ _('Create a Organization') }}{% endblock %} diff --git a/ckan/templates/organization/new_organization_form.html b/ckan/templates/organization/new_organization_form.html new file mode 100644 index 00000000000..27ae8ff5076 --- /dev/null +++ b/ckan/templates/organization/new_organization_form.html @@ -0,0 +1,25 @@ +{% extends "organization/snippets/organization_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 %} diff --git a/ckan/templates/organization/read.html b/ckan/templates/organization/read.html new file mode 100644 index 00000000000..6683108f166 --- /dev/null +++ b/ckan/templates/organization/read.html @@ -0,0 +1,46 @@ +{% extends "page.html" %} + +{% block subtitle %}{{ c.group_dict.display_name }}{% endblock %} + +{% block breadcrumb_content %} +
  • {% link_for _('Organizations'), controller='organization', action='index' %}
  • +
  • {% link_for c.group_dict.display_name|truncate(35), controller='organization', action='read', id=c.group_dict.name %}
  • +{% endblock %} + +{% block actions_content %} + {% if h.check_access('organization_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='organization', action='edit', id=c.group_dict.name, class_='btn', icon='cog' %}
  • + {% endif %} + {#
  • {% link_for _('History'), controller='organization', 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/organization.html', organization=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 "organization/snippets/feeds.html" %} +{% endblock %} diff --git a/ckan/templates/organization/snippets/feeds.html b/ckan/templates/organization/snippets/feeds.html new file mode 100644 index 00000000000..fb7c48c26c1 --- /dev/null +++ b/ckan/templates/organization/snippets/feeds.html @@ -0,0 +1,4 @@ +{%- set dataset_feed = h.url(controller='feed', action='group', id=c.group_dict.name) -%} +{%- set history_feed = h.url(controller='revision', action='list', format='atom', days=1) -%} + + diff --git a/ckan/templates/organization/snippets/organization_form.html b/ckan/templates/organization/snippets/organization_form.html new file mode 100644 index 00000000000..f6d7c545db3 --- /dev/null +++ b/ckan/templates/organization/snippets/organization_form.html @@ -0,0 +1,81 @@ +{% import 'macros/form.html' as form %} + +
    + {% block error_summary %} + {{ form.errors(error_summary) }} + {% 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) }} + + {# Perhaps these should be moved into the controller? #} + {% set prefix = h.url_for(controller='organization', action='read', id='') %} + {% set domain = h.url_for(controller='organization', 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 %} + + {% block custom_fields %} + {% for extra in data.extras %} + {% set prefix = 'extras__%d__' % loop.index0 %} + {{ form.custom( + names=(prefix ~ 'key', prefix ~ 'value', prefix ~ 'deleted'), + id='field-extras-%d' % loop.index, + label=_('Custom Field'), + values=(extra.key, extra.value, extra.deleted), + error=errors[prefix ~ 'key'] or errors[prefix ~ 'value'] + ) }} + {% endfor %} + + {# Add a max if 3 empty columns #} + {% for extra in range(data.extras|count, 3) %} + {% set index = (loop.index0 + data.extras|count) %} + {% set prefix = 'extras__%d__' % index %} + {{ form.custom( + names=(prefix ~ 'key', prefix ~ 'value', prefix ~ 'deleted'), + id='field-extras-%d' % index, + label=_('Custom Field'), + values=(extra.key, extra.value, extra.deleted), + error=errors[prefix ~ 'key'] or errors[prefix ~ 'value'] + ) }} + {% endfor %} + {% endblock %} + + {% block dataset_fields %} + {% if data.packages %} +
    + +
    + {% for dataset in data.packages %} + + {% endfor %} +
    +
    + {% endif %} + + {% set dataset_name = 'packages__%s__name' % data.packages|length %} + {% set dataset_attrs = {'data-module': 'autocomplete', 'data-module-source': '/dataset/autocomplete?q=?'} %} + {{ form.input(dataset_name, label=_('Add Dataset'), id="field-dataset", value=data[dataset_name], classes=['control-medium'], attrs=dataset_attrs) }} + {% endblock %} + +
    + {% block delete_button %} + {% if h.check_access('organization_delete', {'id': data.id}) %} + {% set locale = h.dump_json({'content': _('Are you sure you want to delete this Organization?')}) %} + {% block delete_button_text %}{{ _('Delete') }}{% endblock %} + {% endif %} + {% endblock %} + +
    + diff --git a/ckan/templates/organization/snippets/organization_item.html b/ckan/templates/organization/snippets/organization_item.html new file mode 100644 index 00000000000..63d45bbae84 --- /dev/null +++ b/ckan/templates/organization/snippets/organization_item.html @@ -0,0 +1,38 @@ +{# +Renders a media item for a organization. This should be used in a list. + +organization - A organization dict. +first - Pass true if this is the first item in a row. +last - Pass true if this is the last item in a row. + +Example: + +
      + {% for organization in organizations %} + {% set first = loop.index0 % 3 == 0 %} + {% set last = loop.index0 % 3 == 2 %} + {% snippet "organization/snippets/organization_item.html", organization=organization, first=first, last=last %} + {% endfor %} +
    +#} +{% set url = h.url_for(organization.type ~ '_read', action='read', id=organization.name) %} +
  • + {{ organization.name }} +
    +

    + + {{ organization.display_name }} + +

    + {% if organization.description %} +

    {{ h.truncate(organization.description, length=80, whole_word=True) }}...

    + {% else %} +

    {{ _('This organization has no description') }}

    + {% endif %} + {% if organization.packages %} + {{ ungettext('{num} Dataset', '{num} Datasets', organization.packages).format(num=organization.packages) }} + {% else %} + {{ _('0 Datasets') }} + {% endif %} +
    +
  • diff --git a/ckan/templates/organization/snippets/organization_list.html b/ckan/templates/organization/snippets/organization_list.html new file mode 100644 index 00000000000..3ed7a12d3e5 --- /dev/null +++ b/ckan/templates/organization/snippets/organization_list.html @@ -0,0 +1,17 @@ +{# +Display a grid of organization items. + +organizations - A list of organizations. + +Example: + + {% snippet "organization/snippets/organization_list.html" %} + +#} +
      + {% for organization in organizations %} + {% set first = loop.index0 % 3 == 0 %} + {% set last = loop.index0 % 3 == 2 %} + {% snippet "organization/snippets/organization_item.html", organization=organization, first=first, last=last %} + {% endfor %} +
    diff --git a/ckan/templates/snippets/organization.html b/ckan/templates/snippets/organization.html new file mode 100644 index 00000000000..388aae640eb --- /dev/null +++ b/ckan/templates/snippets/organization.html @@ -0,0 +1,33 @@ +{# +Embeds a organization within the sidebar of a page. + +organization - The organization dict. +truncate - A max length for the organization description. If not provided the description + will be full length. + +Example: + + {% snippet 'snippets/organization, organization=c.group_dict %} + +#} +{% with truncate=truncate or 0, url=h.url_for(controller='organization', action='read', id=organization.name) %} +
    +
    + + {{ organization.name }} + +
    +

    {{ organization.title or organization.name }}

    + {% if organization.description %} + {% if truncate %} +

    {{ organization.description }}

    + {% else %} +

    {{ h.markdown_extract(organization.description, truncate) }}

    + {% endif %} + {% else %} +

    {{ _('There is no description for this organization') }}

    + {% endif %} +
    +
    +
    +{% endwith %} diff --git a/ckan/templates/snippets/organization_item.html b/ckan/templates/snippets/organization_item.html new file mode 100644 index 00000000000..aa812c700ee --- /dev/null +++ b/ckan/templates/snippets/organization_item.html @@ -0,0 +1,24 @@ +
    +
    + {% set url=h.url_for(controller='organization', action='read', id=organization.name) %} + {% set truncate=truncate or 0 %} + + {{ organization.name }} + +
    +

    {{ organization.title or organization.name }}

    + {% if organization.description %} + {% if truncate == 0 %} +

    {{ h.markdown_extract(organization.description)|urlize }}

    + {% else %} +

    {{ h.markdown_extract(organization.description, truncate)|urlize }}

    + {% endif %} + {% else %} +

    {{ _('There is no description for this organization') }}

    + {% endif %} +
    +
    + {% set list_class = "unstyled dataset-list" %} + {% set item_class = "dataset-item module-content" %} + {% snippet 'snippets/package_list.html', packages=organization.packages, list_class=list_class, item_class=item_class, truncate=120 %} +