From 88162dd1e9daa3ee1c47af60779b779b8307e2d1 Mon Sep 17 00:00:00 2001 From: FinnStutzenstein Date: Wed, 17 Jul 2019 09:50:24 +0200 Subject: [PATCH] Little fixes - Fixed bug for deleted candidates - Prevent deleting group 1 and 2 - Creation of topics --- .../components/topic-detail/topic-detail.component.ts | 8 ++++++-- .../users/components/group-list/group-list.component.html | 4 ++-- .../users/components/group-list/group-list.component.ts | 7 +++++++ openslides/assignments/serializers.py | 3 +++ 4 files changed, 18 insertions(+), 4 deletions(-) diff --git a/client/src/app/site/topics/components/topic-detail/topic-detail.component.ts b/client/src/app/site/topics/components/topic-detail/topic-detail.component.ts index f8f3bd738..4a83fbb86 100644 --- a/client/src/app/site/topics/components/topic-detail/topic-detail.component.ts +++ b/client/src/app/site/topics/components/topic-detail/topic-detail.component.ts @@ -5,13 +5,13 @@ import { Title, DomSanitizer, SafeHtml } from '@angular/platform-browser'; import { MatSnackBar } from '@angular/material/snack-bar'; import { TranslateService } from '@ngx-translate/core'; +import { BehaviorSubject } from 'rxjs'; import { BaseViewComponent } from 'app/site/base/base-view'; import { PromptService } from 'app/core/ui-services/prompt.service'; import { TopicRepositoryService } from 'app/core/repositories/topics/topic-repository.service'; import { ViewTopic } from '../../models/view-topic'; import { OperatorService } from 'app/core/core-services/operator.service'; -import { BehaviorSubject } from 'rxjs'; import { ItemVisibilityChoices } from 'app/shared/models/agenda/item'; import { CreateTopic } from '../../models/create-topic'; import { Topic } from 'app/shared/models/topics/topic'; @@ -110,7 +110,11 @@ export class TopicDetailComponent extends BaseViewComponent { * Save a new topic as agenda item */ public async saveTopic(): Promise { - if (this.newTopic && this.topicForm.valid) { + if (!this.topicForm.valid) { + return; + } + + if (this.newTopic) { if (!this.topicForm.value.agenda_parent_id) { delete this.topicForm.value.agenda_parent_id; } diff --git a/client/src/app/site/users/components/group-list/group-list.component.html b/client/src/app/site/users/components/group-list/group-list.component.html index a722ce873..3a0a55461 100644 --- a/client/src/app/site/users/components/group-list/group-list.component.html +++ b/client/src/app/site/users/components/group-list/group-list.component.html @@ -85,8 +85,8 @@ - diff --git a/client/src/app/site/users/components/group-list/group-list.component.ts b/client/src/app/site/users/components/group-list/group-list.component.ts index 104d61024..47abe526c 100644 --- a/client/src/app/site/users/components/group-list/group-list.component.ts +++ b/client/src/app/site/users/components/group-list/group-list.component.ts @@ -149,6 +149,13 @@ export class GroupListComponent extends BaseViewComponent implements OnInit { this.selectedGroup = null; } + /** + * Prevent deleting group 1 and 2 (default and admin) + */ + public canDeleteGroup(group: ViewGroup): boolean { + return group.id !== 1 && group.id !== 2; + } + /** * Triggers when a permission was toggled * @param viewGroup diff --git a/openslides/assignments/serializers.py b/openslides/assignments/serializers.py index a89bef308..126d80776 100644 --- a/openslides/assignments/serializers.py +++ b/openslides/assignments/serializers.py @@ -76,7 +76,10 @@ class AssignmentOptionSerializer(ModelSerializer): def get_is_elected(self, obj): """ Returns the election status of the candidate of this option. + If the candidate is None (e.g. deleted) the result is False. """ + if not obj.candidate: + return False return obj.poll.assignment.is_elected(obj.candidate)