Skip to content
Snippets Groups Projects
Commit d64223cd authored by anonymous's avatar anonymous
Browse files

fix harvest bug

parent df8e21cc
No related branches found
No related tags found
No related merge requests found
...@@ -5,12 +5,26 @@ ckan.module('odsh_form', function ($) ...@@ -5,12 +5,26 @@ ckan.module('odsh_form', function ($)
{ {
// enable multiselect for input // enable multiselect for input
if (this.options.multiselect) if (this.options.multiselect)
$(this.el[0]).multiselect({ {
var multi = $(this.el[0])
if (multi)
{
multi.multiselect({
allSelectedText: this.options.allselectedtext, allSelectedText: this.options.allselectedtext,
nonSelectedText: this.options.nonselectedtext, nonSelectedText: this.options.nonselectedtext,
nSelectedText: this.options.nselectedtext, nSelectedText: this.options.nselectedtext,
numberDisplayed: 1 numberDisplayed: 1,
onChange: function (option, checked, select)
{
var values = $('#field-groups option:selected')
.map(function (a, item) { return item.value; }).get().join(',')
console.log(values)
$('#field-groups-value').val(values);
}
}); });
}
}
if (this.options.licensetoggle) if (this.options.licensetoggle)
{ {
// toggle input for 'Namensgebung' depending on the selected licence // toggle input for 'Namensgebung' depending on the selected licence
......
...@@ -299,7 +299,6 @@ class OdshPlugin(plugins.SingletonPlugin, DefaultTranslation, DefaultDatasetForm ...@@ -299,7 +299,6 @@ class OdshPlugin(plugins.SingletonPlugin, DefaultTranslation, DefaultDatasetForm
plugins.implements(plugins.IDatasetForm) plugins.implements(plugins.IDatasetForm)
plugins.implements(plugins.IValidators) plugins.implements(plugins.IValidators)
plugins.implements(plugins.IPackageController, inherit=True) plugins.implements(plugins.IPackageController, inherit=True)
plugins.implements(IDCATRDFHarvester)
# IConfigurer # IConfigurer
...@@ -610,8 +609,8 @@ class OdshPlugin(plugins.SingletonPlugin, DefaultTranslation, DefaultDatasetForm ...@@ -610,8 +609,8 @@ class OdshPlugin(plugins.SingletonPlugin, DefaultTranslation, DefaultDatasetForm
return dict_pkg return dict_pkg
## implementation of IDCATRDFHarvester ## implementation of IDCATRDFHarvester
def before_download(self, url, harvest_job): class OdshDCATRDFHarvesterPlugin(plugins.SingletonPlugin):
return url, [] plugins.implements(IDCATRDFHarvester)
def update_session(self, session): def update_session(self, session):
return session return session
...@@ -619,42 +618,32 @@ class OdshPlugin(plugins.SingletonPlugin, DefaultTranslation, DefaultDatasetForm ...@@ -619,42 +618,32 @@ class OdshPlugin(plugins.SingletonPlugin, DefaultTranslation, DefaultDatasetForm
def after_download(self, content, harvest_job): def after_download(self, content, harvest_job):
return content, [] return content, []
def before_update(self, harvest_object, dataset_dict, temp_dict):
pass
def after_update(self, harvest_object, dataset_dict, temp_dict): def after_update(self, harvest_object, dataset_dict, temp_dict):
return None return None
def before_create(self, harvest_object, dataset_dict, temp_dict):
pass
def after_create(self, harvest_object, dataset_dict, temp_dict): def after_create(self, harvest_object, dataset_dict, temp_dict):
return None return None
def before_download(self, url, harvest_job):
return url, []
def before_update(self, harvest_object, dataset_dict, temp_dict): def _updateLicense(self, harvest_object, dataset_dict):
if 'license_id' in dataset_dict: if 'license_id' in dataset_dict and dataset_dict['license_id']:
return return
register = model.Package.get_license_register() register = model.Package.get_license_register()
for resource in harvest_object.resources: for resource in dataset_dict['resources']:
license = resource.license license = resource['license']
if license: print(license)
if license in register: if license and license in register:
print("LICENSRE")
print(license)
dataset_dict['license_id'] = license dataset_dict['license_id'] = license
return return
def before_create(self, harvest_object, dataset_dict, temp_dict): def before_update(self, harvest_object, dataset_dict, temp_dict):
self._updateLicense(json.loads(harvest_object.content), dataset_dict)
if 'license_id' in dataset_dict:
return
register = model.Package.get_license_register()
for resource in harvest_object.resources: def before_create(self, harvest_object, dataset_dict, temp_dict):
license = resource.license self._updateLicense(json.loads(harvest_object.content), dataset_dict)
if license:
if license in register:
dataset_dict['license_id'] = license
return
\ No newline at end of file
{% import 'macros/form.html' as form %} {% import 'macros/form.html' as form %}
{% resource 'odsh/odsh_form.js' %} {% resource 'odsh/odsh_form.js' %}
{% resource 'odsh/bootstrap-multiselect.js' %}
{% set dataset_is_draft = data.get('state', 'draft').startswith('draft') or data.get('state', 'none') == 'none' %} {% set dataset_is_draft = data.get('state', 'draft').startswith('draft') or data.get('state', 'none') == 'none' %}
<!-- field title --> <!-- field title -->
...@@ -263,3 +264,41 @@ is_required=true,placeholder=_('Enter title')) }} ...@@ -263,3 +264,41 @@ is_required=true,placeholder=_('Enter title')) }}
</div> </div>
</div> </div>
{% endif %} {% endif %}
<!-- field groups -->
{#
<div class="control-group">
{% set groups_label='Kategorien'%}
{% set multiselect_nonSelectedText='keine' %}
{% set multiselect_allSelectedText='alle' %}
{% set multiselect_nSelectedText='gewählt' %}
<!-- {% set error = errors.groups %} -->
<label for="field-groups" class="control-label">{{ groups_label }}
<span title="{{ _("This field is required") }}" class="control-required">*</span>
</label>
<div class="controls">
{% set existing_groups = data.get('groups') %}
{% if existing_groups %}
{% set existing_groups_string = existing_groups|map(attribute='id')|join(',') %}
{% else %}
{% set existing_groups_string = h.odsh_extract_value_from_extras(data.extras,'groups') %}
{% endif %}
{{existing_groups_string}}
{{existing_groups}}
{% if data.id %}
<input name='groups' value='[{"id":"ener"}]'></input>
{% else %}
<select id='field-groups' multiple="multiple" data-module="odsh_form" data-module-multiselect='true'
data-module-nonSelectedText="{{multiselect_nonSelectedText}}" data-module-allSelectedText="{{multiselect_allSelectedText}}"
data-module-nSelectedText="{{multiselect_nSelectedText}}">
{% for option in h.groups_available()%}
<option value={{option.id}} {% if existing_groups_string!=None and option['id'] in existing_groups_string %}selected="selected"
{% endif %}>
{{ option['display_name'] }}</option>
{% endfor %}
</select>
{{ form.input_extra('groups', value=existing_groups_string, index=h.odsh_create_checksum('groups'), type='hidden')}}
{% endif %}
</div>
</div>
#}
\ No newline at end of file
...@@ -6,6 +6,8 @@ ...@@ -6,6 +6,8 @@
{% set active = data and data.state=='active' %} {% set active = data and data.state=='active' %}
{% set action = form_action or h.url_for(controller='package', action='new_resource', id=pkg_name) %} {% set action = form_action or h.url_for(controller='package', action='new_resource', id=pkg_name) %}
{{errors}}
<form id="resource-edit" class="dataset-form dataset-resource-form {%if(data)%}resource-edit-form{%endif%}" method="post" action="{{ action }}" data-module="basic-form resource-form" <form id="resource-edit" class="dataset-form dataset-resource-form {%if(data)%}resource-edit-form{%endif%}" method="post" action="{{ action }}" data-module="basic-form resource-form"
enctype="multipart/form-data" novalidate> enctype="multipart/form-data" novalidate>
{% block stages %} {% block stages %}
......
...@@ -39,7 +39,7 @@ Example: ...@@ -39,7 +39,7 @@ Example:
{{ text_query_none.format(query=query) }} {{ text_query_none.format(query=query) }}
{%- endif -%} {%- endif -%}
{%- else -%} {%- else -%}
{%- if count -%} {%- if count and text_no_query -%}
{{ text_no_query.format(number=h.localised_number(count)) }} {{ text_no_query.format(number=h.localised_number(count)) }}
{%- else -%} {%- else -%}
{{ text_no_query_none }} {{ text_no_query_none }}
......
...@@ -82,6 +82,7 @@ setup( ...@@ -82,6 +82,7 @@ setup(
[ckan.plugins] [ckan.plugins]
odsh=ckanext.odsh.plugin:OdshPlugin odsh=ckanext.odsh.plugin:OdshPlugin
odsh_icap=ckanext.odsh.plugin:OdshIcapPlugin odsh_icap=ckanext.odsh.plugin:OdshIcapPlugin
odsh_dcatdeharvester=ckanext.odsh.plugin:OdshDCATRDFHarvesterPlugin
statistikamtnord_harvester=ckanext.odsh.harvesters:StatistikamtNordHarvester statistikamtnord_harvester=ckanext.odsh.harvesters:StatistikamtNordHarvester
kiel_harvester=ckanext.odsh.harvesters:KielHarvester kiel_harvester=ckanext.odsh.harvesters:KielHarvester
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment