diff --git a/ckanext/ozwillo_organization_api/plugin.py b/ckanext/ozwillo_organization_api/plugin.py index 83efaf2..a76b5ef 100644 --- a/ckanext/ozwillo_organization_api/plugin.py +++ b/ckanext/ozwillo_organization_api/plugin.py @@ -14,6 +14,7 @@ from ckan.common import request, _ from ckan.logic.action.create import _group_or_org_create as group_or_org_create from ckan.logic.action.create import user_create from ckan.logic.action.delete import _group_or_org_purge +from ckan.lib.plugins import DefaultOrganizationForm plugin_config_prefix = 'ckanext.ozwillo_organization_api.' @@ -150,6 +151,25 @@ def delete_organization(context, data_dict): _group_or_org_purge(context, data_dict, is_org=True) +class OrganizationForm(plugins.SingletonPlugin, DefaultOrganizationForm): + """ + Custom form ignoring 'title' and 'name' organization fields + """ + plugins.implements(plugins.IGroupForm) + + def is_fallback(self): + return True + + def group_types(self): + return ('organization',) + + def form_to_db_schema(self): + schema = super(OrganizationForm, self).form_to_db_schema() + del schema['name'] + del schema['title'] + return schema + + class OzwilloOrganizationApiPlugin(plugins.SingletonPlugin): """ API for OASIS to create and delete an organization diff --git a/ckanext/ozwillo_organization_api/templates/organization/snippets/organization_form.html b/ckanext/ozwillo_organization_api/templates/organization/snippets/organization_form.html index 807d5cf..8ed7b0a 100644 --- a/ckanext/ozwillo_organization_api/templates/organization/snippets/organization_form.html +++ b/ckanext/ozwillo_organization_api/templates/organization/snippets/organization_form.html @@ -7,7 +7,6 @@ {% block basic_fields %} {% set attrs = {'data-module': 'slug-preview-target'} %} - {{ form.input('title', label=_('Name'), id='field-name', 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='') %} @@ -15,8 +14,6 @@ {% 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, is_required=true) }} - {{ form.markdown('description', label=_('Description'), id='field-description', placeholder=_('A little information about my organization...'), value=data.description, error=errors.description) }} {% set is_upload = data.image_url and not data.image_url.startswith('http') %} diff --git a/setup.py b/setup.py index 798cda9..f227884 100644 --- a/setup.py +++ b/setup.py @@ -79,5 +79,6 @@ setup( entry_points=''' [ckan.plugins] ozwillo_organization_api=ckanext.ozwillo_organization_api.plugin:OzwilloOrganizationApiPlugin + ozwillo_organization_form=ckanext.ozwillo_organization_api.plugin:OrganizationForm ''', )