Skip to content

Commit

Permalink
Fix namespace and add column description to daiquiri.tap.renderers
Browse files Browse the repository at this point in the history
  • Loading branch information
jochenklar committed May 14, 2018
1 parent 29ed7f7 commit b315131
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
19 changes: 14 additions & 5 deletions daiquiri/tap/renderers.py
Expand Up @@ -54,15 +54,16 @@ class TablesetRenderer(XMLRenderer):
def render_document(self, data, accepted_media_type=None, renderer_context=None):
self.start('vosi:tableset', {
'xmlns:vosi': 'http://www.ivoa.net/xml/VOSITables/v1.0',
'xmlns:vod': 'http://www.ivoa.net/xml/VODataService/v1.1',
'xmlns:vs': 'http://www.ivoa.net/xml/VODataService/v1.1',
'xmlns:xsi': 'http://www.w3.org/2001/XMLSchema-instance',
'xsi:schemaLocation': 'http://www.ivoa.net/xml/VODataService/v1.1 http://www.ivoa.net/xml/VOSITables/v1.0'
})

for schema in data:
self.start('schema')
self.node('name', {}, schema['name'])
self.node('description', {}, schema['description'])
if schema['description']:
self.node('description', {}, schema['description'])

for table in schema['tables']:
table_attr = {}
Expand All @@ -75,13 +76,21 @@ def render_document(self, data, accepted_media_type=None, renderer_context=None)

self.start('table', table_attr)
self.node('name', {}, table['name'])
self.node('description', {}, table['description'])

if table['description']:
self.node('description', {}, table['description'])

for column in table['columns']:
self.start('column', {'std': 'true'} if column['std'] else {})
self.node('name', {}, column['name'])
if column['unit']: self.node('unit', {}, column['unit'])
if column['ucd']: self.node('ucd', {}, column['ucd'])

if column['description']:
self.node('description', {}, column['description'])
if column['unit']:
self.node('unit', {}, column['unit'])
if column['ucd']:
self.node('ucd', {}, column['ucd'])

self.node('dataType', {'xsi:type': 'vs:VOTableType'}, column['datatype'])
for key in ['indexed', 'principal']:
if key in column and column[key]:
Expand Down
1 change: 1 addition & 0 deletions daiquiri/tap/serializers.py
Expand Up @@ -11,6 +11,7 @@ class Meta:
model = Column
fields = (
'name',
'description',
'datatype',
'ucd',
'unit',
Expand Down

0 comments on commit b315131

Please sign in to comment.