Commit 0b14c771 authored by Denis Laxalde's avatar Denis Laxalde
Browse files

[entities] Let dataset_maintainer just return name and email information

Thus do not force that downstream code to use CWUser.
parent e9f30ed9b309
......@@ -104,14 +104,11 @@ class CKANDatasetAdapter(EntityAdapter):
'owner_org':self.ckan_get_organization_id(
self.ckan_organization)
}
maintainer = self.dataset_maintainer()
maintainer, maintainer_email = self.dataset_maintainer()
if maintainer:
if isinstance(maintainer, basestring):
data['maintainer'] = maintainer
else:
data['maintainer'] = maintainer.dc_long_title()
if maintainer.primary_email:
data['maintainer_email'] = maintainer.primary_email[0].address
data['maintainer'] = maintainer
if maintainer_email:
data['maintainer_email'] = maintainer_email
data['tags'] = list(self.dataset_tags())
data['extras'] = list(self.dataset_extras())
return data
......@@ -127,10 +124,10 @@ class CKANDatasetAdapter(EntityAdapter):
yield {'name': slugify(tag.name)}
def dataset_maintainer(self):
"""May return a CWUser entity corresponding to the maintainer of
"""May return (name, email) information about the maintainer of
dataset-like entity.
"""
return None
return None, None
class CKANResourceAdapter(EntityAdapter):
......
......@@ -9,7 +9,14 @@ class CWDatasetCKANDatasetAdapter(CKANDatasetAdapter):
def dataset_maintainer(self):
if self.entity.maintainer:
return self.entity.maintainer[0]
user = self.entity.maintainer[0]
if user.primary_email:
email = user.primary_email[0].address
else:
email = None
return user.dc_long_title(), email
else:
return None, None
class CWDatasetResourceCKANResourceAdapter(FileCKANResourceAdapter):
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment