diff --git a/ckanext/knowledgehub/controllers/package.py b/ckanext/knowledgehub/controllers/package.py index b6908312..bdee4715 100644 --- a/ckanext/knowledgehub/controllers/package.py +++ b/ckanext/knowledgehub/controllers/package.py @@ -184,7 +184,7 @@ def pager_url(q=None, page=None): default_facet_titles = { 'organization': _('Organizations'), - 'groups': _('Groups'), + 'groups': _('Joint Analysis'), 'tags': _('Tags'), 'res_format': _('Formats'), 'license_id': _('Licenses'), diff --git a/ckanext/knowledgehub/templates/group/index.html b/ckanext/knowledgehub/templates/group/index.html new file mode 100644 index 00000000..1d7729a8 --- /dev/null +++ b/ckanext/knowledgehub/templates/group/index.html @@ -0,0 +1,43 @@ +{% extends "page.html" %} + +{% block subtitle %}{{ _('Joint Analysis') }}{% endblock %} + +{% block breadcrumb_content %} +
  • {% link_for _('Joint Analysis'), controller='group', action='index', named_route=group_type + '_index' %}
  • +{% endblock %} + +{% block page_header %}{% endblock %} + +{% block page_primary_action %} + {% if h.check_access('group_create') %} + {% link_for _('Add Joint Analysis'), controller='group', action='new', class_='btn btn-primary', icon='plus-square', named_route=group_type + '_new' %} + {% endif %} +{% endblock %} + +{% block primary_content_inner %} +

    {{ _('Joint Analysis') }}

    + {% block groups_search_form %} + {% snippet 'snippets/search_form.html', form_id='group-search-form', type='group', query=c.q, sorting_selected=c.sort_by_selected, count=c.page.item_count, placeholder=_('Search joint analysis...'), show_empty=request.params, no_bottom_border=true if c.page.items, sorting = [(_('Name Ascending'), 'title asc'), (_('Name Descending'), 'title desc')] %} + {% endblock %} + {% block groups_list %} + {% if c.page.items or request.params %} + {% if c.page.items %} + {% snippet "group/snippets/group_list.html", groups=c.page.items %} + {% endif %} + {% else %} +

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

    + {% endif %} + {% endblock %} + {% block page_pagination %} + {{ c.page.pager(q=c.q or '', sort=c.sort_by_selected or '') }} + {% endblock %} +{% endblock %} + +{% block secondary_content %} + {% snippet "group/snippets/helper.html" %} +{% endblock %} diff --git a/ckanext/knowledgehub/templates/group/new.html b/ckanext/knowledgehub/templates/group/new.html new file mode 100644 index 00000000..f95b093b --- /dev/null +++ b/ckanext/knowledgehub/templates/group/new.html @@ -0,0 +1,13 @@ +{% extends "group/base_form_page.html" %} + +{% block subtitle %}{{ _('Create a Joint Analysis') }}{% endblock %} + +{% block breadcrumb_link %}{{ h.nav_link(_('Create a Joint Analysis'), controller='group', action='edit', id=c.group.name) }}{% endblock %} + +{% block page_heading %}{{ _('Create a Joint Analysis') }}{% endblock %} + +{% block page_header %}{% endblock %} + +{% block secondary_content %} + {% snippet "group/snippets/helper.html" %} +{% endblock %} diff --git a/ckanext/knowledgehub/templates/group/new_group_form.html b/ckanext/knowledgehub/templates/group/new_group_form.html new file mode 100644 index 00000000..3018ea43 --- /dev/null +++ b/ckanext/knowledgehub/templates/group/new_group_form.html @@ -0,0 +1,25 @@ +{% 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 Joint Analysis') }} + {%- else -%} + {{ _('Create Joint Analysis') }} + {%- endif -%} +{% endblock %} + +{% block delete_button %} + {% if action == "edit" %}{{ super() }}{% endif %} +{% endblock %} diff --git a/ckanext/knowledgehub/templates/group/snippets/group_form.html b/ckanext/knowledgehub/templates/group/snippets/group_form.html new file mode 100644 index 00000000..ae24c87b --- /dev/null +++ b/ckanext/knowledgehub/templates/group/snippets/group_form.html @@ -0,0 +1,42 @@ +{% import 'macros/form.html' as form %} + +
    + {% block error_summary %} + {{ form.errors(error_summary) }} + {% endblock %} + + {% block basic_fields %} + {% set attrs = {'data-module': 'slug-preview-target', 'class': 'form-control'} %} + {{ form.input('title', label=_('Name'), id='field-name', placeholder=_('My Joint Analysis'), value=data.title, error=errors.title, classes=['control-full'], attrs=attrs) }} + + {%- set prefix = h.url_for(group_type + '_read', id='') -%} + {%- set domain = h.url_for(group_type + '_read', id='', qualified=true) -%} + {% set domain = domain|replace("http://", "")|replace("https://", "") %} + {% set attrs = {'data-module': 'slug-preview-slug', 'class': 'form-control input-sm', 'data-module-prefix': domain, 'data-module-placeholder': '<' + group_type + '>'} %} + + {{ form.prepend('name', label=_('URL'), prepend=prefix, id='field-url', placeholder=_('my-' + group_type), value=data.name, error=errors.name, attrs=attrs, is_required=true) }} + + {{ form.markdown('description', label=_('Description'), id='field-description', placeholder=_('A little information about my joint analysis...'), value=data.description, error=errors.description) }} + + {% set is_upload = data.image_url and not data.image_url.startswith('http') %} + {% set is_url = data.image_url and data.image_url.startswith('http') %} + + {{ form.image_upload(data, errors, is_upload_enabled=h.uploads_enabled(), is_url=is_url, is_upload=is_upload) }} + + {% endblock %} + + {% block custom_fields %} + {% snippet 'snippets/custom_form_fields.html', extras=data.extras, errors=errors, limit=3 %} + {% endblock %} + + {{ form.required_message() }} + +
    + {% block delete_button %} + {% if h.check_access('group_delete', {'id': data.id}) %} + {% block delete_button_text %}{{ _('Delete') }}{% endblock %} + {% endif %} + {% endblock %} + +
    +
    diff --git a/ckanext/knowledgehub/templates/group/snippets/helper.html b/ckanext/knowledgehub/templates/group/snippets/helper.html new file mode 100644 index 00000000..f8c2a319 --- /dev/null +++ b/ckanext/knowledgehub/templates/group/snippets/helper.html @@ -0,0 +1,16 @@ +
    +

    + + {{ _('What are Joint Analysis?') }} +

    +
    +

    + {% trans %} + You can use joint analysis to create and manage collections of datasets. + This could be to catalogue datasets for a particular project or team, + or on a particular theme, or as a very simple way to help people find + and search your own published datasets. + {% endtrans %} +

    +
    +
    \ No newline at end of file diff --git a/ckanext/knowledgehub/templates/header.html b/ckanext/knowledgehub/templates/header.html index 15a935e2..bc3741cf 100644 --- a/ckanext/knowledgehub/templates/header.html +++ b/ckanext/knowledgehub/templates/header.html @@ -32,7 +32,7 @@ {{ h.build_nav_main( ('search', _('Datasets')), ('organizations_index', _('Organizations')), - ('group_index', _('Groups')), + ('group_index', _('Joint Analysis')), ('datarequests_index', _('Data Requests') + h.get_open_datarequests_badge()), ('dashboards.index', _('Dashboards')), ('home.about', _('About')) diff --git a/ckanext/knowledgehub/templates/package/read_base.html b/ckanext/knowledgehub/templates/package/read_base.html new file mode 100644 index 00000000..3cba6987 --- /dev/null +++ b/ckanext/knowledgehub/templates/package/read_base.html @@ -0,0 +1,7 @@ +{% ckan_extends %} +{% block content_primary_nav %} + {{ h.build_nav_icon('dataset_read', _('Dataset'), id=pkg.name) }} + {{ h.build_nav_icon('dataset_groups', _('Joint Analysis'), id=pkg.name) }} + {{ h.build_nav_icon('dataset_activity', _('Activity Stream'), id=pkg.name) }} +{% endblock %} +{{ super() }} diff --git a/ckanext/knowledgehub/templates/snippets/search_result_text.html b/ckanext/knowledgehub/templates/snippets/search_result_text.html new file mode 100644 index 00000000..b782a7f9 --- /dev/null +++ b/ckanext/knowledgehub/templates/snippets/search_result_text.html @@ -0,0 +1,59 @@ +{# + + Displays a test for results of a search. + + query - The text that was searched for + count - The number of results for the search + type - Search result type (dataset, group, organization) + + Example: + + {% snippet 'snippets/search_result_text.html', query=query, count=count, type='dataset' %} + + #} + {% if type == 'dataset' %} + {% set text_query = ungettext('{number} dataset found for "{query}"', '{number} datasets found for "{query}"', count) %} + {% set text_query_none = _('No datasets found for "{query}"') %} + {% set text_no_query = ungettext('{number} dataset found', '{number} datasets found', count) %} + {% set text_no_query_none = _('No datasets found') %} + + {% elif type == 'group' %} + {% set text_query = ungettext('{number} joint analysis found for "{query}"', '{number} joint analysis found for "{query}"', count) %} + {% set text_query_none = _('No joint analysis found for "{query}"') %} + {% set text_no_query = ungettext('{number} joint analysis found', '{number} joint analysis found', count) %} + {% set text_no_query_none = _('No joint analysis found') %} + + {% elif type == 'organization' %} + {% set text_query = ungettext('{number} organization found for "{query}"', '{number} organizations found for "{query}"', count) %} + {% set text_query_none = _('No organizations found for "{query}"') %} + {% set text_no_query = ungettext('{number} organization found', '{number} organizations found', count) %} + {% set text_no_query_none = _('No organizations found') %} + + {% else %} + {% set text_query_singular = '{number} ' + type + ' found for "{query}"' %} + {% set text_query_plural = '{number} ' + type + 's found for "{query}"' %} + {% set text_query_none_plural = 'No ' + type + 's found for "{query}"' %} + {% set text_no_query_singular = '{number} ' + type + ' found' %} + {% set text_no_query_plural = '{number} ' + type + 's found' %} + {% set text_no_query_none_plural = 'No ' + type + 's found' %} + + {% set text_query = ungettext(text_query_singular, text_query_plural, count) %} + {% set text_query_none = _(text_query_none_plural) %} + {% set text_no_query = ungettext(text_no_query_singular, text_no_query_plural, count) %} + {% set text_no_query_none = _(text_no_query_none_plural) %} + {%- endif -%} + + {% if query %} + {%- if count -%} + {{ text_query.format(number=h.localised_number(count), query=query, type=type) }} + {%- else -%} + {{ text_query_none.format(query=query, type=type) }} + {%- endif -%} + {%- else -%} + {%- if count -%} + {{ text_no_query.format(number=h.localised_number(count), type=type) }} + {%- else -%} + {{ text_no_query_none.format(type=type) }} + {%- endif -%} + {%- endif -%} + \ No newline at end of file diff --git a/ckanext/knowledgehub/templates/user/dashboard.html b/ckanext/knowledgehub/templates/user/dashboard.html new file mode 100644 index 00000000..06990157 --- /dev/null +++ b/ckanext/knowledgehub/templates/user/dashboard.html @@ -0,0 +1,17 @@ +{% ckan_extends %} + +{% block page_header %} + + {% endblock %} + + {{ super() }}