diff --git a/openslides/core/projector.py b/openslides/core/projector.py index 7efbc65f9..a6ecf28ff 100644 --- a/openslides/core/projector.py +++ b/openslides/core/projector.py @@ -34,9 +34,6 @@ class Clock(ProjectorElement): """ name = 'core/clock' - def get_context(self): - return {'server_time': now().timestamp()} - class Countdown(ProjectorElement): """ @@ -80,7 +77,6 @@ class Countdown(ProjectorElement): def get_context(self): self.validate_config(self.config_entry) - return {'server_time': now().timestamp()} @classmethod def validate_config(cls, config_data): diff --git a/openslides/core/urls.py b/openslides/core/urls.py index 3abb6dd9a..ce5ba7f5a 100644 --- a/openslides/core/urls.py +++ b/openslides/core/urls.py @@ -8,6 +8,10 @@ urlpatterns = patterns( views.UrlPatternsView.as_view(), name='core_url_patterns'), + url(r'^core/servertime/$', + views.ServerTime.as_view(), + name='core_servertime'), + url(r'^core/version/$', views.VersionView.as_view(), name='core_version'), diff --git a/openslides/core/views.py b/openslides/core/views.py index b80ab3660..85289b9f5 100644 --- a/openslides/core/views.py +++ b/openslides/core/views.py @@ -9,6 +9,7 @@ from django.contrib.staticfiles import finders from django.core.urlresolvers import get_resolver from django.db.models import F from django.http import Http404, HttpResponse +from django.utils.timezone import now from openslides import __version__ as version from openslides.utils import views as utils_views @@ -529,6 +530,16 @@ class UrlPatternsView(utils_views.APIView): return result +class ServerTime(utils_views.APIView): + """ + Returns the server time as UNIX timestamp. + """ + http_method_names = ['get'] + + def get_context_data(self, **context): + return now().timestamp() + + class VersionView(utils_views.APIView): """ Returns a dictionary with the OpenSlides version and the version of all