json export of commissions
This commit is contained in:
parent
5fdf268fc4
commit
bbd17ecaa2
|
@ -26,6 +26,13 @@
|
|||
permission="zope2.View"
|
||||
/>
|
||||
|
||||
<browser:page
|
||||
for="themis.datatypes.commission.ICommission"
|
||||
name="json"
|
||||
class=".views.CommissionJson"
|
||||
permission="zope2.View"
|
||||
/>
|
||||
|
||||
<!-- Register an extension profile to make the product installable -->
|
||||
<genericsetup:registerProfile
|
||||
name="default"
|
||||
|
|
|
@ -40,3 +40,17 @@ class DeputyPhoto(BrowserView):
|
|||
self.context.picture.contentType)
|
||||
return self.context.picture.data
|
||||
|
||||
class CommissionJson(BrowserView):
|
||||
def __call__(self):
|
||||
import themis.importexport.utils
|
||||
d = {}
|
||||
for k in ('title', 'active', 'president', 'vicepresidents', 'members',
|
||||
'substitutes', 'competences', 'ministries'):
|
||||
if not hasattr(self.context, k):
|
||||
continue
|
||||
v = getattr(self.context, k)
|
||||
d[k] = themis.importexport.utils.convert(v)
|
||||
|
||||
self.request.response.setHeader('Content-type', 'application/json')
|
||||
return json.dumps(d)
|
||||
|
||||
|
|
Reference in New Issue