X-Git-Url: https://git.mdrn.pl/wolnelektury.git/blobdiff_plain/6280673f35e13e75e81c5b7821bd2a44a1831eab..357027375ff8867f42ca34bcbfb5a78b5b185fc3:/src/api/helpers.py?ds=sidebyside diff --git a/src/api/helpers.py b/src/api/helpers.py new file mode 100644 index 000000000..62578e7c3 --- /dev/null +++ b/src/api/helpers.py @@ -0,0 +1,16 @@ +# -*- coding: utf-8 -*- +# This file is part of Wolnelektury, licensed under GNU Affero GPLv3 or later. +# Copyright © Fundacja Nowoczesna Polska. See NOTICE for more information. +# +from time import mktime +from piston.resource import Resource + +def timestamp(dtime): + "converts a datetime.datetime object to a timestamp int" + return int(mktime(dtime.timetuple())) + +class CsrfExemptResource(Resource): + """A Custom Resource that is csrf exempt""" + def __init__(self, handler, authentication=None): + super(CsrfExemptResource, self).__init__(handler, authentication) + self.csrf_exempt = getattr(self.handler, 'csrf_exempt', True)