Merge pull request #4145 from ostcar/logged_in_users

logged in users
This commit is contained in:
Oskar Hahn 2019-01-19 18:00:47 +01:00 committed by GitHub
commit df85e01b16
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 18 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
@ -545,21 +545,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

@ -105,31 +105,14 @@ def test_project_view(client):
assert projector.elements_preview == [[{"name": "topics/topic", "id": 3}]]
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):