Merge pull request #3505 from FinnStutzenstein/legalNotice

extended the legal notice page (fixes #3504)
This commit is contained in:
Norman Jäckel 2017-12-11 21:49:00 +01:00 committed by GitHub
commit 912876c895
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 85 additions and 11 deletions

View File

@ -1,3 +1,5 @@
__author__ = 'OpenSlides Team <support@openslides.org>' __author__ = 'OpenSlides Team <support@openslides.org>'
__description__ = 'Presentation and assembly system' __description__ = 'Presentation and assembly system'
__version__ = '2.1.2-dev' __version__ = '2.1.2-dev'
__license__ = 'MIT'
__url__ = 'https://openslides.org'

View File

@ -1111,6 +1111,8 @@ angular.module('OpenSlidesApp.core.site', [
function ($scope, $http) { function ($scope, $http) {
$http.get('/core/version/').then(function (success) { $http.get('/core/version/').then(function (success) {
$scope.core_version = success.data.openslides_version; $scope.core_version = success.data.openslides_version;
$scope.core_license = success.data.openslides_license;
$scope.core_url = success.data.openslides_url;
$scope.plugins = success.data.plugins; $scope.plugins = success.data.plugins;
}); });
} }

View File

@ -7,12 +7,26 @@
<div class="details"> <div class="details">
<div ng-bind-html="config('general_event_legal_notice') | translate"></div> <div ng-bind-html="config('general_event_legal_notice') | translate"></div>
<hr> <hr>
<p>OpenSlides {{ core_version }} <p>
<a ng-href="{{ core_url }}" target="_blank">
<strong>OpenSlides {{ core_version }}</strong>
</a>
(<translate>License</translate>: {{ core_license }})
</p>
<div ng-show="plugins.length"> <div ng-show="plugins.length">
<p translate>Installed plugins:</p> <p translate>Installed plugins:</p>
<ol> <ul>
<li ng-repeat="plugin in plugins"> <li ng-repeat="plugin in plugins">
{{ plugin.verbose_name }}: {{ plugin.version }} <a ng-if="plugin.url" ng-href="{{ plugin.url }}" target="_blank">
</ol> {{ plugin.verbose_name }} {{ plugin.version }}
</a>
<span ng-if="!plugin.url">
{{ plugin.verbose_name }} {{ plugin.version }}
</span>
<span ng-if="plugin.license">
(<translate>License</translate>: {{ plugin.license}})
</span>
</li>
</ul>
</div> </div>
</div> </div>

View File

@ -13,12 +13,16 @@ from django.utils.timezone import now
from django.utils.translation import ugettext as _ from django.utils.translation import ugettext as _
from mypy_extensions import TypedDict from mypy_extensions import TypedDict
from .. import __license__ as license
from .. import __url__ as url
from .. import __version__ as version from .. import __version__ as version
from ..utils import views as utils_views from ..utils import views as utils_views
from ..utils.auth import anonymous_is_enabled, has_perm from ..utils.auth import anonymous_is_enabled, has_perm
from ..utils.autoupdate import inform_changed_data, inform_deleted_data from ..utils.autoupdate import inform_changed_data, inform_deleted_data
from ..utils.plugins import ( from ..utils.plugins import (
get_plugin_description, get_plugin_description,
get_plugin_license,
get_plugin_url,
get_plugin_verbose_name, get_plugin_verbose_name,
get_plugin_version, get_plugin_version,
) )
@ -783,12 +787,22 @@ 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', {'openslides_version': str, 'plugins': List[Dict[str, str]]}) # noqa Result = TypedDict('Result', { # noqa
result = dict(openslides_version=version, plugins=[]) # type: Result 'openslides_version': str,
'openslides_license': str,
'openslides_url': str,
'plugins': List[Dict[str, str]]})
result = dict(
openslides_version=version,
openslides_license=license,
openslides_url=url,
plugins=[]) # type: Result
# Versions of plugins. # Versions of plugins.
for plugin in settings.INSTALLED_PLUGINS: for plugin in settings.INSTALLED_PLUGINS:
result['plugins'].append({ result['plugins'].append({
'verbose_name': get_plugin_verbose_name(plugin), 'verbose_name': get_plugin_verbose_name(plugin),
'description': get_plugin_description(plugin), 'description': get_plugin_description(plugin),
'version': get_plugin_version(plugin)}) 'version': get_plugin_version(plugin),
'license': get_plugin_license(plugin),
'url': get_plugin_url(plugin)})
return result return result

View File

@ -93,6 +93,38 @@ def get_plugin_version(plugin: str) -> str:
return version return version
def get_plugin_license(plugin: str) -> str:
"""
Returns the license string of a plugin. The plugin argument must be a
python dotted module path.
"""
plugin_app_config = apps.get_app_config(plugin)
try:
license = plugin_app_config.get_license()
except AttributeError:
try:
license = plugin_app_config.license
except AttributeError:
license = ''
return license
def get_plugin_url(plugin: str) -> str:
"""
Returns the url of a plugin. The plugin argument must be a
python dotted module path.
"""
plugin_app_config = apps.get_app_config(plugin)
try:
url = plugin_app_config.get_url()
except AttributeError:
try:
url = plugin_app_config.url
except AttributeError:
url = ''
return url
def get_plugin_urlpatterns(plugin: str) -> Any: def get_plugin_urlpatterns(plugin: str) -> Any:
""" """
Returns the urlpatterns object for a plugin. The plugin argument must be Returns the urlpatterns object for a plugin. The plugin argument must be

View File

@ -5,6 +5,8 @@ from setuptools import find_packages, setup
from openslides import __author__ as openslides_author from openslides import __author__ as openslides_author
from openslides import __description__ as openslides_description from openslides import __description__ as openslides_description
from openslides import __version__ as openslides_version from openslides import __version__ as openslides_version
from openslides import __license__ as openslides_license
from openslides import __url__ as openslides_url
with open('README.rst') as readme: with open('README.rst') as readme:
long_description = readme.read() long_description = readme.read()
@ -17,9 +19,9 @@ setup(
author=openslides_author, author=openslides_author,
author_email='support@openslides.org', author_email='support@openslides.org',
description=openslides_description, description=openslides_description,
license='MIT', license=openslides_license,
long_description=long_description, long_description=long_description,
url='https://openslides.org', url=openslides_url,
version=openslides_version, version=openslides_version,
classifiers=[ classifiers=[

View File

@ -5,6 +5,8 @@ from django.core.urlresolvers import reverse
from rest_framework import status from rest_framework import status
from rest_framework.test import APIClient from rest_framework.test import APIClient
from openslides import __license__ as license
from openslides import __url__ as url
from openslides import __version__ as version from openslides import __version__ as version
from openslides.core.config import ConfigVariable, config from openslides.core.config import ConfigVariable, config
from openslides.core.models import Projector from openslides.core.models import Projector
@ -71,10 +73,14 @@ class VersionView(TestCase):
response = self.client.get(reverse('core_version')) response = self.client.get(reverse('core_version'))
self.assertEqual(json.loads(response.content.decode()), { self.assertEqual(json.loads(response.content.decode()), {
'openslides_version': version, 'openslides_version': version,
'openslides_license': license,
'openslides_url': url,
'plugins': [ 'plugins': [
{'verbose_name': 'OpenSlides Test Plugin', {'verbose_name': 'OpenSlides Test Plugin',
'description': 'This is a test plugin for OpenSlides.', 'description': 'This is a test plugin for OpenSlides.',
'version': 'unknown'}]}) 'version': 'unknown',
'license': 'MIT',
'url': ''}]})
class WebclientJavaScriptView(TestCase): class WebclientJavaScriptView(TestCase):

View File

@ -1,4 +1,5 @@
__verbose_name__ = 'OpenSlides Test Plugin' __verbose_name__ = 'OpenSlides Test Plugin'
__description__ = 'This is a test plugin for OpenSlides.' __description__ = 'This is a test plugin for OpenSlides.'
__license__ = 'MIT'
default_app_config = 'tests.integration.test_plugin.apps.TestPluginAppConfig' default_app_config = 'tests.integration.test_plugin.apps.TestPluginAppConfig'

View File

@ -1,6 +1,6 @@
from django.apps import AppConfig from django.apps import AppConfig
from . import __description__, __verbose_name__ from . import __description__, __license__, __verbose_name__
class TestPluginAppConfig(AppConfig): class TestPluginAppConfig(AppConfig):
@ -11,3 +11,4 @@ class TestPluginAppConfig(AppConfig):
label = 'tests.integration.test_plugin' label = 'tests.integration.test_plugin'
verbose_name = __verbose_name__ verbose_name = __verbose_name__
description = __description__ description = __description__
license = __license__