only get out harvest items in interface and when indexing
This commit is contained in:
parent
634a0bbd30
commit
b676fb02e1
|
@ -54,16 +54,28 @@ class Harvest(p.SingletonPlugin, DefaultDatasetForm):
|
|||
# Delete the actual HarvestSource object
|
||||
_delete_harvest_source_object(context, package_dict)
|
||||
|
||||
def before_view(self, data_dict):
|
||||
|
||||
if not 'type' in data_dict or data_dict['type'] != DATASET_TYPE_NAME:
|
||||
# This is a normal dataset, check if it was harvested and if so, add
|
||||
# info about the HarvestObject and HarvestSource
|
||||
harvest_object = model.Session.query(HarvestObject) \
|
||||
.filter(HarvestObject.package_id==data_dict['id']) \
|
||||
.filter(HarvestObject.current==True) \
|
||||
.first()
|
||||
|
||||
if harvest_object:
|
||||
for key, value in [
|
||||
('harvest_object_id', harvest_object.id),
|
||||
('harvest_source_id', harvest_object.source.id),
|
||||
('harvest_source_title', harvest_object.source.title),
|
||||
]:
|
||||
_add_extra(data_dict, key, value)
|
||||
return data_dict
|
||||
|
||||
|
||||
def after_show(self, context, data_dict):
|
||||
|
||||
def add_extra(data_dict, key, value):
|
||||
if not 'extras' in data_dict:
|
||||
data_dict['extras'] = []
|
||||
|
||||
data_dict['extras'].append({
|
||||
'key': key, 'value': value, 'state': u'active'
|
||||
})
|
||||
|
||||
if 'type' in data_dict and data_dict['type'] == DATASET_TYPE_NAME:
|
||||
# This is a harvest source dataset, add extra info from the
|
||||
# HarvestSource object
|
||||
|
@ -83,13 +95,14 @@ class Harvest(p.SingletonPlugin, DefaultDatasetForm):
|
|||
.filter(HarvestObject.current==True) \
|
||||
.first()
|
||||
|
||||
if harvest_object:
|
||||
# validate is false is passed only on indexing.
|
||||
if harvest_object and not context.get('validate', True):
|
||||
for key, value in [
|
||||
('harvest_object_id', harvest_object.id),
|
||||
('harvest_source_id', harvest_object.source.id),
|
||||
('harvest_source_title', harvest_object.source.title),
|
||||
]:
|
||||
add_extra(data_dict, key, value)
|
||||
_add_extra(data_dict, key, value)
|
||||
|
||||
return data_dict
|
||||
|
||||
|
@ -272,6 +285,14 @@ class Harvest(p.SingletonPlugin, DefaultDatasetForm):
|
|||
('source_type','Type'),
|
||||
])
|
||||
|
||||
def _add_extra(data_dict, key, value):
|
||||
if not 'extras' in data_dict:
|
||||
data_dict['extras'] = []
|
||||
|
||||
data_dict['extras'].append({
|
||||
'key': key, 'value': value, 'state': u'active'
|
||||
})
|
||||
|
||||
def _get_logic_functions(module_root, logic_functions = {}):
|
||||
|
||||
for module_name in ['get', 'create', 'update','delete']:
|
||||
|
|
Loading…
Reference in New Issue