Skip to content

Commit

Permalink
Fixed Swagger for zip archive API.
Browse files Browse the repository at this point in the history
  • Loading branch information
susanodd committed Oct 21, 2024
1 parent 557faf7 commit e2181b5
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 5 deletions.
27 changes: 22 additions & 5 deletions docs/signbank-api.json
Original file line number Diff line number Diff line change
Expand Up @@ -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 `<dataset_acronym>/<language_code_3char>/<annotation_text>.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":
{
Expand Down
2 changes: 2 additions & 0 deletions signbank/dictionary/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -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<datasetid>\d+)/(?P<glossid>\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<datasetid>\d+)/$',
signbank.dictionary.views.test_abstract_machine_zip, name='test_abstract_machine_zip'),


re_path(r'restore_gloss/(?P<glossid>\d+)/$',
Expand Down
24 changes: 24 additions & 0 deletions signbank/dictionary/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
})

0 comments on commit e2181b5

Please sign in to comment.