Merge pull request #6120 from FinnStutzenstein/os4export

OS4 export
This commit is contained in:
Emanuel Schütze 2021-06-24 21:40:28 +02:00 committed by GitHub
commit 0322436cf5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 1783 additions and 1 deletions

View File

@ -3,6 +3,7 @@ import { MatSnackBar } from '@angular/material/snack-bar';
import { Title } from '@angular/platform-browser';
import { TranslateService } from '@ngx-translate/core';
import { environment } from 'environments/environment.prod';
import { DataStoreService } from 'app/core/core-services/data-store.service';
import { OpenSlidesService } from 'app/core/core-services/openslides.service';

View File

@ -47,4 +47,8 @@
<mat-icon>undo</mat-icon>
<span>{{ 'Reset to factory defaults' | translate }}</span>
</button>
<button *ngIf="isSuperAdmin" mat-menu-item (click)="exportToOS4()">
<mat-icon>archive</mat-icon>
<span>{{ 'Export to OpenSlides4' | translate }}</span>
</button>
</mat-menu>

View File

@ -2,9 +2,13 @@ import { Component, OnInit } from '@angular/core';
import { Title } from '@angular/platform-browser';
import { TranslateService } from '@ngx-translate/core';
import { environment } from 'environments/environment.prod';
import { BaseComponent } from 'app/base.component';
import { HttpService } from 'app/core/core-services/http.service';
import { OperatorService } from 'app/core/core-services/operator.service';
import { ConfigRepositoryService } from 'app/core/repositories/config/config-repository.service';
import { FileExportService } from 'app/core/ui-services/file-export.service';
import { PromptService } from 'app/core/ui-services/prompt.service';
/**
@ -22,11 +26,18 @@ export class ConfigOverviewComponent extends BaseComponent implements OnInit {
protected titleService: Title,
protected translate: TranslateService,
public repo: ConfigRepositoryService,
private promptDialog: PromptService
private promptDialog: PromptService,
private http: HttpService,
private exporter: FileExportService,
private operator: OperatorService
) {
super(titleService, translate);
}
public isSuperAdmin(): boolean {
return this.operator.isSuperAdmin;
}
/**
* Sets the title, inits the table and calls the repo
*/
@ -49,4 +60,10 @@ export class ConfigOverviewComponent extends BaseComponent implements OnInit {
await this.repo.resetGroups(this.groups);
}
}
public async exportToOS4(): Promise<void> {
const data = await this.http.get<any>(environment.urlPrefix + '/core/os4-export/');
const json = JSON.stringify(data, null, 2);
this.exporter.saveFile(json, 'export.json', 'application/json');
}
}

File diff suppressed because it is too large Load Diff

View File

@ -13,4 +13,5 @@ urlpatterns = [
name="core_history_information",
),
url(r"^history/data/$", views.HistoryDataView.as_view(), name="core_history_data"),
url(r"^os4-export/$", views.OS4ExportView.as_view(), name="core_os4_export"),
]

View File

@ -40,6 +40,7 @@ from ..utils.rest_api import (
)
from .config import config
from .exceptions import ConfigError, ConfigNotFound
from .export import OS4Exporter, OS4ExporterException
from .models import (
ConfigStore,
Countdown,
@ -720,3 +721,20 @@ class HistoryDataView(utils_views.APIView):
collection: list(dataset[collection].values())
for collection in dataset.keys()
}
class OS4ExportView(utils_views.APIView):
"""
Returns the server time as UNIX timestamp.
"""
http_method_names = ["get"]
def get_context_data(self, **context):
if not in_some_groups(self.request.user.pk or 0, [GROUP_ADMIN_PK]):
self.permission_denied(self.request)
try:
return OS4Exporter().get_data()
except OS4ExporterException as e:
raise ValidationError({"detail": str(e)})

View File

@ -3,6 +3,7 @@ source = openslides
omit =
openslides/core/management/commands/*.py
openslides/users/management/commands/*.py
openslides/core/export.py
[coverage:html]
directory = personal_data/tmp/htmlcov