Merge pull request #4858 from FinnStutzenstein/littleFixes

Little fixes
This commit is contained in:
Sean 2019-07-17 13:54:54 +02:00 committed by GitHub
commit 450819c035
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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 { MatSnackBar } from '@angular/material/snack-bar';
import { TranslateService } from '@ngx-translate/core'; import { TranslateService } from '@ngx-translate/core';
import { BehaviorSubject } from 'rxjs';
import { BaseViewComponent } from 'app/site/base/base-view'; import { BaseViewComponent } from 'app/site/base/base-view';
import { PromptService } from 'app/core/ui-services/prompt.service'; import { PromptService } from 'app/core/ui-services/prompt.service';
import { TopicRepositoryService } from 'app/core/repositories/topics/topic-repository.service'; import { TopicRepositoryService } from 'app/core/repositories/topics/topic-repository.service';
import { ViewTopic } from '../../models/view-topic'; import { ViewTopic } from '../../models/view-topic';
import { OperatorService } from 'app/core/core-services/operator.service'; import { OperatorService } from 'app/core/core-services/operator.service';
import { BehaviorSubject } from 'rxjs';
import { ItemVisibilityChoices } from 'app/shared/models/agenda/item'; import { ItemVisibilityChoices } from 'app/shared/models/agenda/item';
import { CreateTopic } from '../../models/create-topic'; import { CreateTopic } from '../../models/create-topic';
import { Topic } from 'app/shared/models/topics/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 * Save a new topic as agenda item
*/ */
public async saveTopic(): Promise<void> { 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) { if (!this.topicForm.value.agenda_parent_id) {
delete 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()"> <button type="button" mat-button (click)="cancelEditing()">
<span translate>Cancel</span> <span translate>Cancel</span>
</button> </button>
<button *ngIf="selectedGroup" type="button" mat-icon-button color="warn" (click)="deleteSelectedGroup()"> <button *ngIf="selectedGroup" [disabled]="!canDeleteGroup(selectedGroup)" type="button" mat-button color="warn" (click)="deleteSelectedGroup()">
<mat-icon>delete</mat-icon> <span translate>Delete</span>
</button> </button>
</div> </div>
</ng-template> </ng-template>

View File

@ -149,6 +149,13 @@ export class GroupListComponent extends BaseViewComponent implements OnInit {
this.selectedGroup = null; 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 * Triggers when a permission was toggled
* @param viewGroup * @param viewGroup

View File

@ -76,7 +76,10 @@ class AssignmentOptionSerializer(ModelSerializer):
def get_is_elected(self, obj): def get_is_elected(self, obj):
""" """
Returns the election status of the candidate of this option. 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) return obj.poll.assignment.is_elected(obj.candidate)