From 26d168110fc969f027f523045e29a214d2a78097 Mon Sep 17 00:00:00 2001 From: FinnStutzenstein Date: Fri, 22 Jun 2018 14:39:29 +0200 Subject: [PATCH] make the privacy policy available for non logged in users (closes #3757) --- .gitignore | 3 +++ openslides/core/apps.py | 8 +++++++- .../static/templates/core/login-form.html | 1 + .../static/templates/privacypolicydialog.html | 9 +++++++++ openslides/users/static/js/users/site.js | 20 +++++++++++++++++++ tests/unit/core/test_views.py | 1 + 6 files changed, 41 insertions(+), 1 deletion(-) create mode 100644 openslides/core/static/templates/privacypolicydialog.html diff --git a/.gitignore b/.gitignore index 29a6676c3..e6c181a27 100644 --- a/.gitignore +++ b/.gitignore @@ -35,3 +35,6 @@ openslides_* # Mypy cache for typechecking .mypy_cache + +# Development of a new client. Easier to switch branches with this entry +client/* diff --git a/openslides/core/apps.py b/openslides/core/apps.py index 4bdf42b00..2a3a885d6 100644 --- a/openslides/core/apps.py +++ b/openslides/core/apps.py @@ -115,7 +115,13 @@ class CoreAppConfig(AppConfig): 'name': 'OpenSlidesConfigVariables', 'value': config_groups} - return [client_settings, config_variables] + # Send the privacy policy to the client. A user should view them, even he is + # not logged in (so does not have the config values yet). + privacy_policy = { + 'name': 'PrivacyPolicy', + 'value': config['general_event_privacy_policy']} + + return [client_settings, config_variables, privacy_policy] def call_save_default_values(**kwargs): diff --git a/openslides/core/static/templates/core/login-form.html b/openslides/core/static/templates/core/login-form.html index 5cb168d9f..c33858d59 100644 --- a/openslides/core/static/templates/core/login-form.html +++ b/openslides/core/static/templates/core/login-form.html @@ -25,5 +25,6 @@ + Privacy policy diff --git a/openslides/core/static/templates/privacypolicydialog.html b/openslides/core/static/templates/privacypolicydialog.html new file mode 100644 index 000000000..a314af267 --- /dev/null +++ b/openslides/core/static/templates/privacypolicydialog.html @@ -0,0 +1,9 @@ +

Privacy policy

+
+
+ The event manager hasn't set up a privacy policy yet. +
+ + diff --git a/openslides/users/static/js/users/site.js b/openslides/users/static/js/users/site.js index b2eecd8eb..6f158b7a6 100644 --- a/openslides/users/static/js/users/site.js +++ b/openslides/users/static/js/users/site.js @@ -1778,6 +1778,26 @@ angular.module('OpenSlidesApp.users.site', [ $scope.closeThisDialog(); $state.go('home'); }; + // quick fix, that we cannot change the state to the main privacy + // policy view. Display it in a dialog.. + $scope.openPrivacyPolicyDialog = function () { + ngDialog.open({ + template: 'static/templates/privacypolicydialog.html', + className: 'ngdialog-theme-default wide-form', + controller: 'PrivacyPolicyDialogCtrl', + showClose: true, + closeByEscape: true, + closeByDocument: true, + }); + }; + } +]) + +.controller('PrivacyPolicyDialogCtrl', [ + '$scope', + 'PrivacyPolicy', + function ($scope, PrivacyPolicy) { + $scope.privacyPolicy = PrivacyPolicy; } ]) diff --git a/tests/unit/core/test_views.py b/tests/unit/core/test_views.py index 5b14362e9..ec91e3e45 100644 --- a/tests/unit/core/test_views.py +++ b/tests/unit/core/test_views.py @@ -173,6 +173,7 @@ class WebclientJavaScriptView(TestCase): @patch('openslides.core.config.config') @patch('django.contrib.auth.models.Permission.objects.all') def test_permissions_as_constant(self, mock_permissions_all, mock_config): + mock_config.__getitem__.return_value = '' self.view_instance = views.WebclientJavaScriptView() self.view_instance.request = self.request response = self.view_instance.get(realm='site')