Add a stable url for deputy photo, and use it in json output
This commit is contained in:
parent
c1feae1cdd
commit
dee8c2622b
|
@ -19,6 +19,12 @@
|
|||
permission="zope2.View"
|
||||
/>
|
||||
|
||||
<browser:page
|
||||
for="themis.datatypes.deputy.IDeputy"
|
||||
name="photo"
|
||||
class=".views.DeputyPhoto"
|
||||
permission="zope2.View"
|
||||
/>
|
||||
|
||||
<!-- Register an extension profile to make the product installable -->
|
||||
<genericsetup:registerProfile
|
||||
|
|
|
@ -13,11 +13,12 @@ class DeputyJson(BrowserView):
|
|||
'district': self.context.district,
|
||||
'birthplace': self.context.birthplace,
|
||||
'bio': self.context.bio,
|
||||
'picture': None, #XXX: link to picture
|
||||
'website': self.context.website,
|
||||
'degrees': self.context.degrees,
|
||||
'mandates': self.context.mandates,
|
||||
}
|
||||
if self.context.picture:
|
||||
d['picture'] = self.context.absolute_url() + '/photo'
|
||||
if self.context.birthdate:
|
||||
d['birthdate'] = self.context.birthdate.strftime('%Y-%m-%d')
|
||||
if self.context.private_address:
|
||||
|
@ -29,3 +30,10 @@ class DeputyJson(BrowserView):
|
|||
|
||||
self.request.response.setHeader('Content-type', 'application/json')
|
||||
return json.dumps(d)
|
||||
|
||||
class DeputyPhoto(BrowserView):
|
||||
def __call__(self):
|
||||
self.request.response.setHeader('Content-type',
|
||||
self.context.picture.contentType)
|
||||
return self.context.picture.data
|
||||
|
||||
|
|
Reference in New Issue