Skip to content
Snippets Groups Projects
Commit 66ecf7cd authored by jan.bednarik's avatar jan.bednarik
Browse files

Timezones in API

parent 7535ed6c
No related branches found
No related tags found
1 merge request!33Timezones in API
Pipeline #16924 passed
import pytz
from django.http import JsonResponse
from django.views.generic import TemplateView, View
......@@ -21,6 +22,16 @@ class IndexView(TemplateView):
def election_as_dict(election):
voting_start_at = (
election.voting_start_at.replace(tzinfo=pytz.UTC)
if election.voting_start_at
else None
)
voting_end_at = (
election.voting_end_at.replace(tzinfo=pytz.UTC)
if election.voting_end_at
else None
)
return {
"name": election.name,
"uuid": election.uuid,
......@@ -29,8 +40,8 @@ def election_as_dict(election):
"created_at": election.created_at,
"voting_has_started": election.voting_has_started(),
"voting_has_stopped": election.voting_has_stopped(),
"voting_start_at": election.voting_start_at,
"voting_end_at": election.voting_end_at,
"voting_start_at": voting_start_at,
"voting_end_at": voting_end_at,
}
......
manage.py 100644 → 100755
File mode changed from 100644 to 100755
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment