Merge pull request #1647 from normanjaeckel/ServerTime

Added API view for server time.
This commit is contained in:
Oskar Hahn 2015-09-24 21:35:55 +02:00
commit 0c9d4b2627
3 changed files with 15 additions and 4 deletions

View File

@ -34,9 +34,6 @@ class Clock(ProjectorElement):
""" """
name = 'core/clock' name = 'core/clock'
def get_context(self):
return {'server_time': now().timestamp()}
class Countdown(ProjectorElement): class Countdown(ProjectorElement):
""" """
@ -80,7 +77,6 @@ class Countdown(ProjectorElement):
def get_context(self): def get_context(self):
self.validate_config(self.config_entry) self.validate_config(self.config_entry)
return {'server_time': now().timestamp()}
@classmethod @classmethod
def validate_config(cls, config_data): def validate_config(cls, config_data):

View File

@ -8,6 +8,10 @@ urlpatterns = patterns(
views.UrlPatternsView.as_view(), views.UrlPatternsView.as_view(),
name='core_url_patterns'), name='core_url_patterns'),
url(r'^core/servertime/$',
views.ServerTime.as_view(),
name='core_servertime'),
url(r'^core/version/$', url(r'^core/version/$',
views.VersionView.as_view(), views.VersionView.as_view(),
name='core_version'), name='core_version'),

View File

@ -9,6 +9,7 @@ from django.contrib.staticfiles import finders
from django.core.urlresolvers import get_resolver from django.core.urlresolvers import get_resolver
from django.db.models import F from django.db.models import F
from django.http import Http404, HttpResponse from django.http import Http404, HttpResponse
from django.utils.timezone import now
from openslides import __version__ as version from openslides import __version__ as version
from openslides.utils import views as utils_views from openslides.utils import views as utils_views
@ -529,6 +530,16 @@ class UrlPatternsView(utils_views.APIView):
return result 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): class VersionView(utils_views.APIView):
""" """
Returns a dictionary with the OpenSlides version and the version of all Returns a dictionary with the OpenSlides version and the version of all