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 os
from typing import Any, Dict, List
from typing import Any, Dict
from django.conf import settings
from django.contrib.staticfiles import finders
@ -10,9 +10,9 @@ from django.http import Http404, HttpResponse
from django.utils.timezone import now
from django.views import static
from django.views.generic.base import View
from mypy_extensions import TypedDict
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.arguments import arguments
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"]
def get_context_data(self, **context):
Result = TypedDict(
"Result",
{
"openslides_version": str,
"openslides_license": str,
"openslides_url": str,
"plugins": List[Dict[str, str]],
},
)
result: Result = dict(
openslides_version=version,
openslides_license=license,
openslides_url=url,
plugins=[],
)
result: Dict[str, Any] = {
"openslides_version": version,
"openslides_license": license,
"openslides_url": url,
"plugins": [],
"no_name_yet_users": User.objects.filter(last_login__isnull=False).count(),
}
# Versions of plugins.
for plugin in settings.INSTALLED_PLUGINS:
result["plugins"].append(

View File

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

View File

@ -1,5 +1,6 @@
import json
import pytest
from django.urls import reverse
from rest_framework import status
from rest_framework.test import APIClient
@ -68,31 +69,14 @@ class ProjectorAPI(TestCase):
self.assertEqual(response.status_code, 400)
class VersionView(TestCase):
"""
Tests the version info view.
"""
def test_get(self):
self.client.login(username="admin", password="admin")
response = self.client.get(reverse("core_version"))
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": "",
}
],
},
)
@pytest.mark.django_db(transaction=False)
def test_get(client):
client.login(username="admin", password="admin")
response = client.get(reverse("core_version"))
values = json.loads(response.content.decode())
assert values["openslides_version"] == version
assert values["openslides_license"] == license
assert values["openslides_url"] == url
class ConfigViewSet(TestCase):