Merge pull request #5322 from FinnStutzenstein/delete-all-speakers

delete all speakers of all lists of speakers
This commit is contained in:
Emanuel Schütze 2020-04-24 12:25:49 +02:00 committed by GitHub
commit 2057150076
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 25 additions and 1 deletions

View File

@ -97,7 +97,7 @@
"karma-jasmine": "~3.1.1",
"karma-jasmine-html-reporter": "^1.4.0",
"npm-license-crawler": "^0.2.1",
"prettier": "^2.0.2",
"prettier": "^2.0.5",
"protractor": "^5.4.3",
"resize-observer-polyfill": "^1.5.1",
"ts-node": "~8.8.1",

View File

@ -220,6 +220,10 @@ export class ListOfSpeakersRepositoryService extends BaseHasContentObjectReposit
await this.httpService.put(restUrl, { speaker: speaker.id });
}
public async deleteAllSpeakersOfAllListsOfSpeakers(): Promise<void> {
await this.httpService.post('/rest/agenda/list-of-speakers/delete_all_speakers/');
}
/**
* Helper function get the url to the speaker rest address
*

View File

@ -121,6 +121,11 @@
<span>{{ 'Import' | translate }}</span>
</button>
<mat-divider></mat-divider>
<button mat-menu-item *osPerms="'agenda.can_manage'" class="red-warning-text" (click)="deleteAllSpeakersOfAllListsOfSpeakers()">
<mat-icon>delete</mat-icon>
<span>{{ 'Delete all speakers' | translate }}</span>
</button>
<mat-divider></mat-divider>
<!-- Settings -->
<button mat-menu-item *osPerms="'core.can_manage_config'" routerLink="/settings/agenda">
<mat-icon>settings</mat-icon>

View File

@ -342,4 +342,12 @@ export class AgendaListComponent extends BaseListViewComponent<ViewItem> impleme
return result;
}
}
public async deleteAllSpeakersOfAllListsOfSpeakers(): Promise<void> {
const title = this.translate.instant('Are you sure you want to clear all speakers of all lists of speakers?');
const content = this.translate.instant('All lists of speakers will be cleared and are empty afterwards.');
if (await this.promptService.open(title, content)) {
this.listOfSpeakersRepo.deleteAllSpeakersOfAllListsOfSpeakers().catch(this.raiseError);
}
}
}

View File

@ -296,6 +296,7 @@ class ListOfSpeakersViewSet(
"speak",
"sort_speakers",
"readd_last_speaker",
"delete_all_speakers",
):
result = has_perm(
self.request.user, "agenda.can_see_list_of_speakers"
@ -554,3 +555,9 @@ class ListOfSpeakersViewSet(
last_speaker.save()
return Response()
@list_route(methods=["post"])
def delete_all_speakers(self, request):
Speaker.objects.all().delete()
inform_changed_data(ListOfSpeakers.objects.all())
return Response()