[#4] Add owner_org field to schema and form
This should store the owner organization id. Also added the errors box on the form.
This commit is contained in:
parent
acb17ff3b0
commit
2bb669af21
|
@ -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],
|
||||
|
|
|
@ -2,6 +2,8 @@
|
|||
|
||||
<form id="source-new" class="form-horizontal" method="post" >
|
||||
|
||||
{% 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']) %}
|
||||
<span class="info-block icon-large icon-info-sign">
|
||||
{{ _('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) }}
|
||||
|
||||
<div><b>TODO: state / delete</b> </div>
|
||||
{# if we have a default group then this wants remembering #}
|
||||
{% if data.group_id %}
|
||||
<input type="hidden" name="groups__0__id" value="{{ 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 %}
|
||||
<div class="control-group">
|
||||
<label for="field-organizations" class="control-label">{{ _('Organization') }}</label>
|
||||
<div class="controls">
|
||||
<select id="field-organizations" name="owner_org" data-module="autocomplete">
|
||||
<option value="">{{ _('Select an organization...') }}</option>
|
||||
{% for organization in organizations_available %}
|
||||
{# get out first org from users list only if there is not an existing org #}
|
||||
{% set selected_org = (existing_org and existing_org == organization.id) or (not existing_org and organization.id == organizations_available[0].id) %}
|
||||
<option value="{{ organization.id }}" {% if selected_org %} selected="selected" {% endif %}>{{ organization.name }}</option>
|
||||
{% endfor %}
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
|
||||
<input id="save" name="save" value="Save" type="submit" class="btn"/>
|
||||
|
||||
|
|
Loading…
Reference in New Issue