Merge branch '2.0-dataset-sources' into 4-new-auth-for-2.0
Conflicts: ckanext/harvest/logic/action/get.py
This commit is contained in:
commit
1342463f8a
|
@ -3,9 +3,12 @@ from pylons import request
|
||||||
from ckan import logic
|
from ckan import logic
|
||||||
from ckan import model
|
from ckan import model
|
||||||
import ckan.lib.helpers as h
|
import ckan.lib.helpers as h
|
||||||
|
import ckan.plugins as p
|
||||||
|
|
||||||
|
from ckanext.harvest.model import UPDATE_FREQUENCIES
|
||||||
from ckanext.harvest.plugin import DATASET_TYPE_NAME
|
from ckanext.harvest.plugin import DATASET_TYPE_NAME
|
||||||
|
|
||||||
|
|
||||||
def package_list_for_source(source_id):
|
def package_list_for_source(source_id):
|
||||||
'''
|
'''
|
||||||
Creates a dataset list with the ones belonging to a particular harvest
|
Creates a dataset list with the ones belonging to a particular harvest
|
||||||
|
@ -46,3 +49,17 @@ def package_list_for_source(source_id):
|
||||||
out += pager.pager()
|
out += pager.pager()
|
||||||
|
|
||||||
return out
|
return out
|
||||||
|
|
||||||
|
def harvesters_info():
|
||||||
|
context = {'model': model, 'user': p.toolkit.c.user or p.toolkit.c.author}
|
||||||
|
return logic.get_action('harvesters_info_show')(context,{})
|
||||||
|
|
||||||
|
def harvester_types():
|
||||||
|
harvesters = harvesters_info()
|
||||||
|
return [{'text': p.toolkit._(h['title']), 'value': h['name']}
|
||||||
|
for h in harvesters]
|
||||||
|
|
||||||
|
def harvest_frequencies():
|
||||||
|
|
||||||
|
return [{'text': p.toolkit._(f.title()), 'value': f}
|
||||||
|
for f in UPDATE_FREQUENCIES]
|
||||||
|
|
|
@ -12,7 +12,6 @@ from ckanext.harvest import logic as harvest_logic
|
||||||
|
|
||||||
from ckanext.harvest.model import setup as model_setup
|
from ckanext.harvest.model import setup as model_setup
|
||||||
from ckanext.harvest.model import HarvestSource, HarvestJob, HarvestObject
|
from ckanext.harvest.model import HarvestSource, HarvestJob, HarvestObject
|
||||||
from ckanext.harvest.model import UPDATE_FREQUENCIES
|
|
||||||
|
|
||||||
|
|
||||||
log = getLogger(__name__)
|
log = getLogger(__name__)
|
||||||
|
@ -108,20 +107,9 @@ class Harvest(p.SingletonPlugin, DefaultDatasetForm):
|
||||||
return 'source/edit.html'
|
return 'source/edit.html'
|
||||||
|
|
||||||
def setup_template_variables(self, context, data_dict):
|
def setup_template_variables(self, context, data_dict):
|
||||||
harvesters_info = logic.get_action('harvesters_info_show')(context,{})
|
|
||||||
|
|
||||||
p.toolkit.c.harvest_source = p.toolkit.c.pkg
|
p.toolkit.c.harvest_source = p.toolkit.c.pkg
|
||||||
|
|
||||||
p.toolkit.c.frequencies = [
|
|
||||||
{'text': p.toolkit._(f.title()), 'value': f}
|
|
||||||
for f in UPDATE_FREQUENCIES
|
|
||||||
]
|
|
||||||
p.toolkit.c.harvester_types = [
|
|
||||||
{'text': p.toolkit._(h['title']), 'value': h['name']}
|
|
||||||
for h in harvesters_info
|
|
||||||
]
|
|
||||||
p.toolkit.c.harvesters_info = harvesters_info
|
|
||||||
|
|
||||||
p.toolkit.c.dataset_type = DATASET_TYPE_NAME
|
p.toolkit.c.dataset_type = DATASET_TYPE_NAME
|
||||||
|
|
||||||
def form_to_db_schema_options(self, options):
|
def form_to_db_schema_options(self, options):
|
||||||
|
@ -283,7 +271,12 @@ class Harvest(p.SingletonPlugin, DefaultDatasetForm):
|
||||||
## ITemplateHelpers
|
## ITemplateHelpers
|
||||||
def get_helpers(self):
|
def get_helpers(self):
|
||||||
from ckanext.harvest import helpers as harvest_helpers
|
from ckanext.harvest import helpers as harvest_helpers
|
||||||
return {'package_list_for_source': harvest_helpers.package_list_for_source}
|
return {
|
||||||
|
'package_list_for_source': harvest_helpers.package_list_for_source,
|
||||||
|
'harvesters_info': harvest_helpers.harvesters_info,
|
||||||
|
'harvester_types': harvest_helpers.harvester_types,
|
||||||
|
'harvest_frequencies': harvest_helpers.harvest_frequencies,
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
def _get_auth_functions(module_root, auth_functions = {}):
|
def _get_auth_functions(module_root, auth_functions = {}):
|
||||||
|
|
|
@ -19,18 +19,18 @@
|
||||||
|
|
||||||
{{ form.markdown('notes', id='field-notes', label=_('Description'), value=data.notes, error=errors.notes) }}
|
{{ form.markdown('notes', id='field-notes', label=_('Description'), value=data.notes, error=errors.notes) }}
|
||||||
|
|
||||||
{{ form.select('source_type', id='field-source_type', label=_('Source type'), options=c.harvester_types, selected=data.source_type, error=errors.source_type) }}
|
{{ form.select('source_type', id='field-source_type', label=_('Source type'), options=h.harvester_types(), selected=data.source_type, error=errors.source_type) }}
|
||||||
<div class="controls">
|
<div class="controls">
|
||||||
<ul>
|
<ul>
|
||||||
{% for harvester in c.harvesters_info %}
|
{% for harvester in h.harvesters_info() %}
|
||||||
<li><b>{{ harvester['title']}}</b>: {{harvester['description'] }}</li>
|
<li><b>{{ harvester['title']}}</b>: {{harvester['description'] }}</li>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{{ form.select('frequency', id='field-frequency', label=_('Frequency of update'), options=c.frequencies, selected=data.frequency, error=errors.frequency) }}
|
{{ form.select('frequency', id='field-frequency', label=_('Frequency of update'), options=h.harvest_frequencies(), selected=data.frequency, error=errors.frequency) }}
|
||||||
|
|
||||||
{{ form.textarea('config', id='field-config', label=_('Configuration'), value=data.config, error=errors.config) }}
|
{{ form.textarea('config', id='field-config', label=_('Configuration'), value=data.config, error=errors.config) }}
|
||||||
|
|
||||||
<div><b>TODO: state / delete</b> </div>
|
<div><b>TODO: state / delete</b> </div>
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue