Commit a9505a0c authored by abuddenberg's avatar abuddenberg
Browse files

Added support for transforming figure identifiers

parent f9e4b18e
...@@ -39,6 +39,7 @@ class Figure(Gcisbase): ...@@ -39,6 +39,7 @@ class Figure(Gcisbase):
] ]
_translations = { _translations = {
'what_is_the_figure_id': 'identifier',
'what_is_the_name_of_the_figure_as_listed_in_the_report': 'title', 'what_is_the_name_of_the_figure_as_listed_in_the_report': 'title',
'when_was_this_figure_created': 'create_dt' 'when_was_this_figure_created': 'create_dt'
} }
...@@ -54,6 +55,8 @@ class Figure(Gcisbase): ...@@ -54,6 +55,8 @@ class Figure(Gcisbase):
image_list = data.pop('images', None) image_list = data.pop('images', None)
self.images = [Image(image) for image in image_list] if image_list else None self.images = [Image(image) for image in image_list] if image_list else None
#Hack
self.identifier = self.identifier.replace('/figure/', '')
@property @property
...@@ -108,9 +111,9 @@ class Image(Gcisbase): ...@@ -108,9 +111,9 @@ class Image(Gcisbase):
self.identifier = self.identifier.replace('/image/', '') self.identifier = self.identifier.replace('/image/', '')
self.filepath = filepath self.filepath = filepath
def as_json(self): def as_json(self, indent=0):
out_fields = self._gcis_fields out_fields = self._gcis_fields
return json.dumps({f: self.__dict__[f] for f in out_fields}) return json.dumps({f: self.__dict__[f] for f in out_fields}, indent=indent)
def __str__(self): def __str__(self):
return 'Image: {id} {name}'.format(id=self.identifier, name=self.title) return 'Image: {id} {name}'.format(id=self.identifier, name=self.title)
Supports Markdown
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