moved privacy policy to users, adapt client

This commit is contained in:
FinnStutzenstein 2018-08-31 12:37:47 +02:00
parent 732de97ec2
commit ea71d0a942
5 changed files with 24 additions and 14 deletions

View File

@ -15,9 +15,11 @@ interface Constants {
* Get constants from the server. * Get constants from the server.
* *
* @example * @example
* this.constantsService.get('OpenSlidesSettings').subscribe(constant => { * ```ts
* console.log(constant); * this.constantsService.get('OpenSlidesSettings').subscribe(constant => {
* }); * console.log(constant);
* });
* ```
*/ */
@Injectable({ @Injectable({
providedIn: 'root' providedIn: 'root'
@ -50,7 +52,7 @@ export class ConstantsService extends OpenSlidesComponent {
super(); super();
// The hook for recieving constants. // The hook for recieving constants.
websocketService.getOberservable<Constants>('constantsResponse').subscribe(constants => { websocketService.getOberservable<Constants>('constants').subscribe(constants => {
this.constants = constants; this.constants = constants;
if (this.pending) { if (this.pending) {
// send constants to subscribers that await constants. // send constants to subscribers that await constants.
@ -64,7 +66,7 @@ export class ConstantsService extends OpenSlidesComponent {
// We can request constants, if the websocket connection opens. // We can request constants, if the websocket connection opens.
websocketService.connectEvent.subscribe(() => { websocketService.connectEvent.subscribe(() => {
if (!this.websocketOpen && this.pending) { if (!this.websocketOpen && this.pending) {
this.websocketService.send('constantsRequest', {}); this.websocketService.send('constants', {});
} }
this.websocketOpen = true; this.websocketOpen = true;
}); });
@ -83,7 +85,7 @@ export class ConstantsService extends OpenSlidesComponent {
this.pending = true; this.pending = true;
// if the connection is open, we directly can send the request. // if the connection is open, we directly can send the request.
if (this.websocketOpen) { if (this.websocketOpen) {
this.websocketService.send('constantsRequest', {}); this.websocketService.send('constants', {});
} }
} }
if (!this.pendingSubject[key]) { if (!this.pendingSubject[key]) {

View File

@ -72,6 +72,13 @@ export class LoginComponent extends BaseComponent implements OnInit, OnDestroy {
*/ */
public inProcess = false; public inProcess = false;
/**
* The provacy policy send by the server.
*
* TODO: give an option to show it during login.
*/
public privacyPolicy: string;
/** /**
* Constructor for the login component * Constructor for the login component
* *
@ -106,9 +113,12 @@ export class LoginComponent extends BaseComponent implements OnInit, OnDestroy {
super.setTitle('Login'); super.setTitle('Login');
this.http.get<any>(environment.urlPrefix + '/users/login/', {}).subscribe(response => { this.http.get<any>(environment.urlPrefix + '/users/login/', {}).subscribe(response => {
this.installationNotice = this.matSnackBar.open(response.info_text, this.translate.instant('OK'), { if (response.info_text) {
duration: 5000 this.installationNotice = this.matSnackBar.open(response.info_text, this.translate.instant('OK'), {
}); duration: 5000
});
}
this.privacyPolicy = response.privacy_policy;
}); });
} }

View File

@ -121,10 +121,6 @@ class CoreAppConfig(AppConfig):
config_groups[-1]['subgroups'][-1]['items'].append(config_variable.data) config_groups[-1]['subgroups'][-1]['items'].append(config_variable.data)
constants['OpenSlidesConfigVariables'] = config_groups constants['OpenSlidesConfigVariables'] = config_groups
# 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).
constants['PrivacyPolicy'] = config['general_event_privacy_policy']
return constants return constants

View File

@ -15,6 +15,7 @@ from .. import __license__ as license, __url__ as url, __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.constants import get_constants
from ..utils.plugins import ( from ..utils.plugins import (
get_plugin_description, get_plugin_description,
get_plugin_license, get_plugin_license,
@ -48,7 +49,6 @@ from .models import (
ProjectorMessage, ProjectorMessage,
Tag, Tag,
) )
from ..utils.constants import get_constants
# Special Django views # Special Django views

View File

@ -453,6 +453,8 @@ class UserLoginView(APIView):
password='<strong>admin</strong>') password='<strong>admin</strong>')
else: else:
context['info_text'] = '' context['info_text'] = ''
# Add the privacy policy, so the client can display it even, it is not logged in.
context['privacy_policy'] = config['general_event_privacy_policy']
else: else:
# self.request.method == 'POST' # self.request.method == 'POST'
context['user_id'] = self.user.pk context['user_id'] = self.user.pk