Little fixes

- Fixed bug for deleted candidates
- Prevent deleting group 1 and 2
- Creation of topics
This commit is contained in:
FinnStutzenstein 2019-07-17 09:50:24 +02:00
parent 51130da791
commit 88162dd1e9
4 changed files with 18 additions and 4 deletions

View File

@ -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<void> {
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;
}

View File

@ -85,8 +85,8 @@
<button type="button" mat-button (click)="cancelEditing()">
<span translate>Cancel</span>
</button>
<button *ngIf="selectedGroup" type="button" mat-icon-button color="warn" (click)="deleteSelectedGroup()">
<mat-icon>delete</mat-icon>
<button *ngIf="selectedGroup" [disabled]="!canDeleteGroup(selectedGroup)" type="button" mat-button color="warn" (click)="deleteSelectedGroup()">
<span translate>Delete</span>
</button>
</div>
</ng-template>

View File

@ -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

View File

@ -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)