Add function to edit harvest sources

This commit is contained in:
Adrià Mercader 2011-04-15 18:28:58 +01:00
parent e3a83ea14d
commit 7e75673cff
1 changed files with 14 additions and 0 deletions

View File

@ -178,6 +178,20 @@ def create_harvest_source(source_dict):
return _source_as_dict(source) return _source_as_dict(source)
def edit_harvest_source(source_id,source_dict):
try:
source = HarvestSource.get(source_id)
except:
raise Exception('Source %s does not exist' % source_id)
fields = ['url','type','active','description','user_id','publisher_id']
for f in fields:
if f in source_dict and source_dict[f] is not None and source_dict[f] != '':
source.__setattr__(f,source_dict[f])
source.save()
return _source_as_dict(source)
def remove_harvest_source(source_id): def remove_harvest_source(source_id):
try: try: