logged in users

This commit is contained in:
Oskar Hahn 2019-01-19 17:42:18 +01:00
parent b03538e564
commit 5ca2012c44
3 changed files with 19 additions and 42 deletions

View File

@ -1,6 +1,6 @@
import datetime import datetime
import os import os
from typing import Any, Dict, List from typing import Any, Dict
from django.conf import settings from django.conf import settings
from django.contrib.staticfiles import finders from django.contrib.staticfiles import finders
@ -10,9 +10,9 @@ from django.http import Http404, HttpResponse
from django.utils.timezone import now from django.utils.timezone import now
from django.views import static from django.views import static
from django.views.generic.base import View from django.views.generic.base import View
from mypy_extensions import TypedDict
from .. import __license__ as license, __url__ as url, __version__ as version from .. import __license__ as license, __url__ as url, __version__ as version
from ..users.models import User
from ..utils import views as utils_views from ..utils import views as utils_views
from ..utils.arguments import arguments from ..utils.arguments import arguments
from ..utils.auth import GROUP_ADMIN_PK, anonymous_is_enabled, has_perm, in_some_groups from ..utils.auth import GROUP_ADMIN_PK, anonymous_is_enabled, has_perm, in_some_groups
@ -512,21 +512,13 @@ class VersionView(utils_views.APIView):
http_method_names = ["get"] http_method_names = ["get"]
def get_context_data(self, **context): def get_context_data(self, **context):
Result = TypedDict( result: Dict[str, Any] = {
"Result", "openslides_version": version,
{ "openslides_license": license,
"openslides_version": str, "openslides_url": url,
"openslides_license": str, "plugins": [],
"openslides_url": str, "no_name_yet_users": User.objects.filter(last_login__isnull=False).count(),
"plugins": List[Dict[str, str]], }
},
)
result: Result = dict(
openslides_version=version,
openslides_license=license,
openslides_url=url,
plugins=[],
)
# Versions of plugins. # Versions of plugins.
for plugin in settings.INSTALLED_PLUGINS: for plugin in settings.INSTALLED_PLUGINS:
result["plugins"].append( result["plugins"].append(

View File

@ -114,6 +114,7 @@ if use_redis:
'host': '127.0.0.1', 'host': '127.0.0.1',
'post': 6379, 'post': 6379,
'db': 0, 'db': 0,
"prefix": "session"
} }

View File

@ -1,5 +1,6 @@
import json import json
import pytest
from django.urls import reverse from django.urls import reverse
from rest_framework import status from rest_framework import status
from rest_framework.test import APIClient from rest_framework.test import APIClient
@ -68,31 +69,14 @@ class ProjectorAPI(TestCase):
self.assertEqual(response.status_code, 400) self.assertEqual(response.status_code, 400)
class VersionView(TestCase): @pytest.mark.django_db(transaction=False)
""" def test_get(client):
Tests the version info view. client.login(username="admin", password="admin")
""" response = client.get(reverse("core_version"))
values = json.loads(response.content.decode())
def test_get(self): assert values["openslides_version"] == version
self.client.login(username="admin", password="admin") assert values["openslides_license"] == license
response = self.client.get(reverse("core_version")) assert values["openslides_url"] == url
self.assertEqual(
json.loads(response.content.decode()),
{
"openslides_version": version,
"openslides_license": license,
"openslides_url": url,
"plugins": [
{
"verbose_name": "OpenSlides Test Plugin",
"description": "This is a test plugin for OpenSlides.",
"version": "unknown",
"license": "MIT",
"url": "",
}
],
},
)
class ConfigViewSet(TestCase): class ConfigViewSet(TestCase):