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.
*
* @example
* this.constantsService.get('OpenSlidesSettings').subscribe(constant => {
* console.log(constant);
* });
* ```ts
* this.constantsService.get('OpenSlidesSettings').subscribe(constant => {
* console.log(constant);
* });
* ```
*/
@Injectable({
providedIn: 'root'
@ -50,7 +52,7 @@ export class ConstantsService extends OpenSlidesComponent {
super();
// The hook for recieving constants.
websocketService.getOberservable<Constants>('constantsResponse').subscribe(constants => {
websocketService.getOberservable<Constants>('constants').subscribe(constants => {
this.constants = constants;
if (this.pending) {
// 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.
websocketService.connectEvent.subscribe(() => {
if (!this.websocketOpen && this.pending) {
this.websocketService.send('constantsRequest', {});
this.websocketService.send('constants', {});
}
this.websocketOpen = true;
});
@ -83,7 +85,7 @@ export class ConstantsService extends OpenSlidesComponent {
this.pending = true;
// if the connection is open, we directly can send the request.
if (this.websocketOpen) {
this.websocketService.send('constantsRequest', {});
this.websocketService.send('constants', {});
}
}
if (!this.pendingSubject[key]) {

View File

@ -72,6 +72,13 @@ export class LoginComponent extends BaseComponent implements OnInit, OnDestroy {
*/
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
*
@ -106,9 +113,12 @@ export class LoginComponent extends BaseComponent implements OnInit, OnDestroy {
super.setTitle('Login');
this.http.get<any>(environment.urlPrefix + '/users/login/', {}).subscribe(response => {
this.installationNotice = this.matSnackBar.open(response.info_text, this.translate.instant('OK'), {
duration: 5000
});
if (response.info_text) {
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)
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

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.auth import anonymous_is_enabled, has_perm
from ..utils.autoupdate import inform_changed_data, inform_deleted_data
from ..utils.constants import get_constants
from ..utils.plugins import (
get_plugin_description,
get_plugin_license,
@ -48,7 +49,6 @@ from .models import (
ProjectorMessage,
Tag,
)
from ..utils.constants import get_constants
# Special Django views

View File

@ -453,6 +453,8 @@ class UserLoginView(APIView):
password='<strong>admin</strong>')
else:
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:
# self.request.method == 'POST'
context['user_id'] = self.user.pk