def public_api(request, username, id_string):
"""
Returns public information about the form as JSON
"""
xform = get_object_or_404(XForm,
user__username__iexact=username,
id_string__iexact=id_string)
_DATETIME_FORMAT = '%Y-%m-%d %H:%M:%S'
exports = {'username': xform.user.username,
'id_string': xform.id_string,
'bamboo_dataset': xform.bamboo_dataset,
'shared': xform.shared,
'shared_data': xform.shared_data,
'downloadable': xform.downloadable,
'title': xform.title,
'date_created': xform.date_created.strftime(_DATETIME_FORMAT),
'date_modified': xform.date_modified.strftime(_DATETIME_FORMAT),
'uuid': xform.uuid,
}
response_text = json.dumps(exports)
return HttpResponse(response_text, content_type='application/json')
评论列表
文章目录