From 2bb669af21099daa360896650a9c389e1fc18ed8 Mon Sep 17 00:00:00 2001 From: amercader Date: Thu, 10 Jan 2013 12:23:01 +0000 Subject: [PATCH] [#4] Add owner_org field to schema and form This should store the owner organization id. Also added the errors box on the form. --- ckanext/harvest/logic/schema.py | 2 ++ .../templates_new/source/new_source_form.html | 26 ++++++++++++++++++- 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/ckanext/harvest/logic/schema.py b/ckanext/harvest/logic/schema.py index 5e37393..d071c05 100644 --- a/ckanext/harvest/logic/schema.py +++ b/ckanext/harvest/logic/schema.py @@ -1,6 +1,7 @@ from ckan.logic.schema import default_extras_schema from ckan.logic.validators import (package_id_exists, name_validator, + owner_org_validator, package_name_validator, ignore_not_package_admin, ) @@ -29,6 +30,7 @@ def harvest_source_schema(): 'source_type': [not_empty, unicode, harvest_source_type_exists, convert_to_extras], 'title': [if_empty_same_as("name"), unicode], 'notes': [ignore_missing, unicode], + 'owner_org': [owner_org_validator, unicode], 'frequency': [ignore_missing, unicode, harvest_source_frequency_exists, convert_to_extras], 'state': [ignore_missing], 'config': [ignore_missing, harvest_source_config_validator, convert_to_extras], diff --git a/ckanext/harvest/templates_new/source/new_source_form.html b/ckanext/harvest/templates_new/source/new_source_form.html index be509ef..2b4fae1 100644 --- a/ckanext/harvest/templates_new/source/new_source_form.html +++ b/ckanext/harvest/templates_new/source/new_source_form.html @@ -2,6 +2,8 @@
+ {% block errors %}{{ form.errors(error_summary) }}{% endblock %} + {% call form.input('url', id='field-url', label=_('URL'), value=data.url, error=errors.url, classes=['control-full', 'control-large']) %} {{ _('This should include the http:// part of the URL') }} @@ -32,7 +34,29 @@ {{ form.textarea('config', id='field-config', label=_('Configuration'), value=data.config, error=errors.config) }} -
TODO: state / delete
+ {# if we have a default group then this wants remembering #} + {% if data.group_id %} + + {% endif %} + {% set existing_org = data.owner_org or data.group_id %} + {% if h.check_access('sysadmin') or data.get('state', 'draft').startswith('draft') or data.get('state', 'none') == 'none' %} + {% set organizations_available = h.organizations_available('create_dataset') %} + {% if organizations_available %} +
+ +
+ +
+
+ {% endif %} + {% endif %}