From 3aa4bcd4ff1df765da544cfac1b87d9550323261 Mon Sep 17 00:00:00 2001 From: Rae Knowler Date: Thu, 25 Jan 2024 09:52:41 +0100 Subject: [PATCH 1/4] feat: Override ckanext-scheming template --- .../scheming/organization/group_form.html | 54 +++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 ckanext/switzerland/templates/scheming/organization/group_form.html diff --git a/ckanext/switzerland/templates/scheming/organization/group_form.html b/ckanext/switzerland/templates/scheming/organization/group_form.html new file mode 100644 index 000000000..ebf78de76 --- /dev/null +++ b/ckanext/switzerland/templates/scheming/organization/group_form.html @@ -0,0 +1,54 @@ +{% import 'macros/form.html' as form %} +{% if group_type is not defined %} + {% set group_type = c.group_type %} +{% endif %} + + +{%- if not group_type -%} +

+ group_type not passed to template. your version of CKAN + might not be compatible with ckanext-scheming +

+{%- endif -%} + +
+ {{ h.csrf_input() if 'csrf_input' in h }} + {%- set schema = h.scheming_get_organization_schema(group_type) -%} + {%- for field in schema['fields'] -%} + {%- if field.form_snippet is not none -%} + {%- snippet 'scheming/snippets/form_field.html', + field=field, data=data, errors=errors, licenses=licenses, + entity_type='organization', object_type=group_type -%} + {%- endif -%} + {%- endfor -%} + + {{ form.required_message() }} + +
+ {% block delete_button %} + {% if action == 'edit' %} + {% if h.check_access('group_delete', {'id': data.id}) and action=='edit' %} + {% set locale = h.dump_json({'content': _('Are you sure you want to delete this Organization?')}) %} + {% block delete_button_text %}{{ _('Delete') }}{% endblock %} + {% endif %} + {% endif %} + {% endblock %} + +
+
From 1b34e9e14c8aba2ecce187abf977936b88a8821e Mon Sep 17 00:00:00 2001 From: Rae Knowler Date: Thu, 25 Jan 2024 09:54:27 +0100 Subject: [PATCH 2/4] fix: Fix button text humanize_entity_type returns None if we should use the default translated string in the template. In this case, we should actually use that string rather than just putting 'None' on the button. --- .../templates/scheming/organization/group_form.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ckanext/switzerland/templates/scheming/organization/group_form.html b/ckanext/switzerland/templates/scheming/organization/group_form.html index ebf78de76..b0dcc366c 100644 --- a/ckanext/switzerland/templates/scheming/organization/group_form.html +++ b/ckanext/switzerland/templates/scheming/organization/group_form.html @@ -37,13 +37,13 @@ {% block save_text %} {%- if action == "edit" -%} {%- if 'humanize_entity_type' in h -%} - {{ h.humanize_entity_type('organization', group_type, 'update label') }} + {{ h.humanize_entity_type('organization', group_type, 'update label') or _('Update Organization') }} {%- else -%} {{ _('Update Organization') }} {%- endif -%} {%- else -%} {%- if 'humanize_entity_type' in h -%} - {{ h.humanize_entity_type('organization', group_type, 'create label') }} + {{ h.humanize_entity_type('organization', group_type, 'create label') or _('Create Organization') }} {%- else -%} {{ _('Create Organization') }} {%- endif -%} From 6d0bacc3e5becdf55bf598c76b55ad41bb06e08f Mon Sep 17 00:00:00 2001 From: Rae Knowler Date: Thu, 25 Jan 2024 10:26:23 +0100 Subject: [PATCH 3/4] feat: Override ckan core template --- .../switzerland/templates/organization/edit.html | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 ckanext/switzerland/templates/organization/edit.html diff --git a/ckanext/switzerland/templates/organization/edit.html b/ckanext/switzerland/templates/organization/edit.html new file mode 100644 index 000000000..329617c99 --- /dev/null +++ b/ckanext/switzerland/templates/organization/edit.html @@ -0,0 +1,14 @@ +{% extends "organization/base_form_page.html" %} + +{% block subtitle %}{{ _('Edit') }} {{ g.template_title_delimiter }} {{ super() }}{% endblock %} + +{% block breadcrumb_content %} +
  • {% link_for h.humanize_entity_type('organization', group_type, 'breadcrumb') or _('Organizations'), named_route=group_type+'.index' %}
  • + {% block breadcrumb_content_inner %} +
  • {% link_for organization.display_name|truncate(35), named_route=group_type+'.read', id=organization.name %}
  • +
  • {% link_for _('Manage'), named_route=group_type+'.edit', id=organization.name %}
  • + {% endblock %} +{% endblock %} + +{% block page_heading_class %}hide-heading{% endblock %} +{% block page_heading %}{{ _('Edit Organization') }}{% endblock %} From 5cb2ae305d4bd57d4891619e06a945d6515209a0 Mon Sep 17 00:00:00 2001 From: Rae Knowler Date: Thu, 25 Jan 2024 10:26:53 +0100 Subject: [PATCH 4/4] feat: Localise organisation name in breadcrumb --- ckanext/switzerland/templates/organization/edit.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ckanext/switzerland/templates/organization/edit.html b/ckanext/switzerland/templates/organization/edit.html index 329617c99..c6f0374a2 100644 --- a/ckanext/switzerland/templates/organization/edit.html +++ b/ckanext/switzerland/templates/organization/edit.html @@ -5,7 +5,7 @@ {% block breadcrumb_content %}
  • {% link_for h.humanize_entity_type('organization', group_type, 'breadcrumb') or _('Organizations'), named_route=group_type+'.index' %}
  • {% block breadcrumb_content_inner %} -
  • {% link_for organization.display_name|truncate(35), named_route=group_type+'.read', id=organization.name %}
  • +
  • {% link_for h.get_localized_value(organization.title)|truncate(35), named_route=group_type+'.read', id=organization.name %}
  • {% link_for _('Manage'), named_route=group_type+'.edit', id=organization.name %}
  • {% endblock %} {% endblock %}