From e2181b5ec00953c61e5e67415044b937e12cc830 Mon Sep 17 00:00:00 2001 From: susanodd Date: Mon, 21 Oct 2024 15:08:41 +0200 Subject: [PATCH] Fixed Swagger for zip archive API. --- docs/signbank-api.json | 27 ++++++++++++++++++++++----- signbank/dictionary/urls.py | 2 ++ signbank/dictionary/views.py | 24 ++++++++++++++++++++++++ 3 files changed, 48 insertions(+), 5 deletions(-) diff --git a/docs/signbank-api.json b/docs/signbank-api.json index 20480106a..8390fef92 100644 --- a/docs/signbank-api.json +++ b/docs/signbank-api.json @@ -992,20 +992,37 @@ { "type": "string" } - }, + } + ], + "requestBody": + { + "content": { +<<<<<<< Updated upstream "name": "file", "in": "query", "description": "The URL of the zip file to upload. The file path must include an IP address from the other computer. The zip file archive has the structure `//.mp4`. For dataset NGT, this looks like `NGT/nld/OLIFANT.mp4`, and for an English language, this looks like: `ASL/eng/FINGERSPELLING.mp4`. The videos need to be in `mp4` format. It is recommended to use the English gloss annotation for languages with UTF-8 characters or symbols because of file naming and storage. For example, right-to-left languages flip the order of the extension to the left. Because Signbank is multilingual, not using English in these cases may not work as expected because all the files are stored in the same file system, albeit in separate folders.", "required": true, "schema": +======= + "application/json": +>>>>>>> Stashed changes { - "type": "string", - "format": "uri" + "schema": + { + "type": "object", + "properties": + { + "File": + { + "type": "base64-encoded file" + } + } + } } } - ], - "responses": + }, + "responses": { "200": { diff --git a/signbank/dictionary/urls.py b/signbank/dictionary/urls.py index 3d424755b..ca5bd2346 100755 --- a/signbank/dictionary/urls.py +++ b/signbank/dictionary/urls.py @@ -232,6 +232,8 @@ signbank.gloss_update.api_delete_annotated_sentence, name='api_delete_annotated_sentence'), re_path(r'get_annotated_sentences_of_gloss/(?P\d+)/(?P\d+)/$', signbank.api_interface.get_annotated_sentences_of_gloss_json, name='get_annotated_sentences_of_gloss_json'), + re_path(r'test_abstract_machine_zip/(?P\d+)/$', + signbank.dictionary.views.test_abstract_machine_zip, name='test_abstract_machine_zip'), re_path(r'restore_gloss/(?P\d+)/$', diff --git a/signbank/dictionary/views.py b/signbank/dictionary/views.py index a3682a0ca..eaae8c3d7 100644 --- a/signbank/dictionary/views.py +++ b/signbank/dictionary/views.py @@ -3044,3 +3044,27 @@ def test_am_update_gloss(request, datasetid, glossid): 'USE_REGULAR_EXPRESSIONS': settings.USE_REGULAR_EXPRESSIONS, 'SHOW_DATASET_INTERFACE_OPTIONS': settings.SHOW_DATASET_INTERFACE_OPTIONS }) + +def test_abstract_machine_zip(request, datasetid): + # used to test api method since PyCharm runserver does not support CORS + dataset_id = int(datasetid) + dataset = Dataset.objects.filter(id=dataset_id).first() + selected_datasets = get_selected_datasets_for_user(request.user) + dataset_languages = get_dataset_languages(selected_datasets) + if not dataset or not (request.user.is_staff or request.user.is_superuser): + translated_message = _('You do not have permission to use the test command.') + return render(request, 'dictionary/warning.html', + {'warning': translated_message, + 'dataset_languages': dataset_languages, + 'selected_datasets': selected_datasets, + 'SHOW_DATASET_INTERFACE_OPTIONS': SHOW_DATASET_INTERFACE_OPTIONS}) + + language_2chars = [str(language.language_code_2char) for language in dataset.translation_languages.all()] + return render(request, 'dictionary/virtual_machine_test_zip_archive_local.html', + {'selected_datasets': selected_datasets, + 'dataset': dataset, + 'language_2chars': language_2chars, + 'dataset_languages': dataset_languages, + 'USE_REGULAR_EXPRESSIONS': settings.USE_REGULAR_EXPRESSIONS, + 'SHOW_DATASET_INTERFACE_OPTIONS': settings.SHOW_DATASET_INTERFACE_OPTIONS + })