From b349cbdae306d2d76b2e19ea85d14d41eab4b712 Mon Sep 17 00:00:00 2001 From: David mattei Date: Sat, 30 Mar 2024 07:30:03 +0100 Subject: [PATCH] feat(core/api): new submission file download endpoint (#855) --- .../c58f67d7-0c75-45fa-b4ec-46bc27eda055.json | 2 +- skeleton/routes.yaml | 13 ++++++++++++- skeleton/template/sso/test_sso.html.twig | 19 +++++++++++++++++++ .../submission/form_example_files.twig | 19 ++++++++++--------- 4 files changed, 42 insertions(+), 11 deletions(-) create mode 100644 skeleton/template/sso/test_sso.html.twig diff --git a/configs/document/form_instance/c58f67d7-0c75-45fa-b4ec-46bc27eda055.json b/configs/document/form_instance/c58f67d7-0c75-45fa-b4ec-46bc27eda055.json index c87533f..1026a1e 100644 --- a/configs/document/form_instance/c58f67d7-0c75-45fa-b4ec-46bc27eda055.json +++ b/configs/document/form_instance/c58f67d7-0c75-45fa-b4ec-46bc27eda055.json @@ -3,5 +3,5 @@ "form_template": "@EMSCH/template/form/bootstrap_4_with_visibility.html.twig", "label": "Example files", "name": "example-files", - "submissions": "[{\"id\":\"0b46b35d-2007-4921-9864-b68c101e7085\",\"label\":\"admin form submission (HttpHandler)\",\"type\":\"submission\",\"object\":{\"label\":\"admin form submission (HttpHandler)\",\"name\":\"admin form submission\",\"type\":\"EMS\\\\SubmissionBundle\\\\Handler\\\\HttpHandler\",\"endpoint\":\"{{- block('http_admin_api_form_endpoint', '@EMSCH/template_ems/submission/form_example_files.twig') -}}\",\"message\":\"{%- block requestBody -%}\\r\\n {{- block('http_admin_api_form_request_body', '@EMSCH/template_ems/submission/form_example_files.twig') -}}\\r\\n{%- endblock -%}\\r\\n\\r\\n{%- block handleResponseExtra -%}\\r\\n {{- block('http_admin_api_form_handle_response_extra', '@EMSCH/template_ems/submission/form_example_files.twig') -}}\\r\\n{%- endblock -%}\"},\"children\":[]},{\"id\":\"a75ffd41-7377-435c-be2f-f8356c8852f7\",\"label\":\"email (EmailHandler)\",\"type\":\"submission\",\"object\":{\"label\":\"email (EmailHandler)\",\"name\":\"email\",\"type\":\"EMS\\\\SubmissionBundle\\\\Handler\\\\EmailHandler\",\"endpoint\":\"{{- block('email_endpoint', '@EMSCH/template_ems/submission/form_example_files.twig') -}}\",\"message\":\"{{- block('email_message', '@EMSCH/template_ems/submission/form_example_files.twig') -}}\"},\"children\":[]}]" + "submissions": "[{\"id\":\"0b46b35d-2007-4921-9864-b68c101e7085\",\"label\":\"admin form submission (HttpHandler)\",\"type\":\"submission\",\"object\":{\"label\":\"admin form submission (HttpHandler)\",\"name\":\"admin form submission\",\"type\":\"EMS\\\\SubmissionBundle\\\\Handler\\\\HttpHandler\",\"endpoint\":\"{{- block('http_admin_api_form_endpoint', '@EMSCH/template_ems/submission/form_example_files.twig') -}}\",\"message\":\"{%- block requestBody -%}\\r\\n {{- block('http_admin_api_form_request_body', '@EMSCH/template_ems/submission/form_example_files.twig') -}}\\r\\n{%- endblock -%}\"},\"children\":[]},{\"id\":\"a75ffd41-7377-435c-be2f-f8356c8852f7\",\"label\":\"email (EmailHandler)\",\"type\":\"submission\",\"object\":{\"label\":\"email (EmailHandler)\",\"name\":\"email\",\"type\":\"EMS\\\\SubmissionBundle\\\\Handler\\\\EmailHandler\",\"endpoint\":\"{{- block('email_endpoint', '@EMSCH/template_ems/submission/form_example_files.twig') -}}\",\"message\":\"{{- block('email_message', '@EMSCH/template_ems/submission/form_example_files.twig') -}}\"},\"children\":[]}]" } \ No newline at end of file diff --git a/skeleton/routes.yaml b/skeleton/routes.yaml index abe9d99..11be90d 100644 --- a/skeleton/routes.yaml +++ b/skeleton/routes.yaml @@ -56,6 +56,17 @@ google_verification: config: path: google559a317bdba2ec40.html template_static: template/seo/google.html.twig +emsch_sso_test: + config: + path: '/sso/test' + defaults: { _authenticated: true } + template_static: template/sso/test_sso.html.twig +emsch_api_form_attachment: + config: + path: '/form/{submissionId}/attachment/{submissionFileId}' + defaults: { apiName: backend, _authenticated: true } + controller: 'emsch.controller.api::getSubmissionFile' + requirements: { submissionId: .*, submissionFileId: .* } emsch_publication: config: path: { en: 'publications/{slug}', fr: 'fr/publications/{slug}', nl: 'nl/publicaties/{slug}', de: 'de/publikation/{slug}' } @@ -111,7 +122,7 @@ emsch_news_details: emsch_path: config: path: { fr: '/fr/{path}', nl: '/nl/{path}' } - requirements: { path: '^(?!(fr/|nl/|de/|_wdt/|_profiler/|_error/|metric|file/)(.*$)?).+' } + requirements: { path: '^(?!(fr/|nl/|de/|_wdt/|_profiler/|_error/|metric|file|saml/)(.*$)?).+' } defaults: { path: home } query: '{"query":{"bool":{"must":[{"nested":{"path":"paths","query":{"term":{"paths.path":"%path%"}}}},{"nested":{"path":"paths","query":{"term":{"paths.locale":"%_locale%"}}}},{"terms":{"_contenttype":["section"]}}]}},"size":1}' template_static: template/structure/by_path.html.twig diff --git a/skeleton/template/sso/test_sso.html.twig b/skeleton/template/sso/test_sso.html.twig new file mode 100644 index 0000000..78eb802 --- /dev/null +++ b/skeleton/template/sso/test_sso.html.twig @@ -0,0 +1,19 @@ +{% extends '@EMSCH/template/base/base.html.twig' %} + +{% block headtitle %}SSO Test{% endblock %} + +{% block body %} +
+
+
+
+ SSO Test +
+
+

Welcome {{ app.user.userIdentifier }}

+ Logout +
+
+
+
+{% endblock body %} diff --git a/skeleton/template_ems/submission/form_example_files.twig b/skeleton/template_ems/submission/form_example_files.twig index b3031a5..e16daf3 100644 --- a/skeleton/template_ems/submission/form_example_files.twig +++ b/skeleton/template_ems/submission/form_example_files.twig @@ -38,19 +38,15 @@ {{- message|json_encode|raw -}} {% endblock http_admin_api_form_request_body %} -{% block http_admin_api_form_handle_response_extra %} - {%- set extra = { - 'uid': (response.getHttpResponseContentJSON.submission_id) - } -%} - {{- extra|json_encode|raw -}} -{% endblock http_admin_api_form_handle_response_extra %} - {% block email_endpoint %} {{- "no-reply@elasticms.be" -}} {% endblock email_endpoint %} {% block email_message %} {% apply spaceless %} + {% set skeletonUrl = app.request.server.all['SKELETON_URL']|default('https://demo-admin.elasticms.eu') %} + {% set submission = responses[0].getHttpResponseContentJSON.submission %} + {% set data = [] %} {% set elements = config.elements %} {% for name, value in formData.raw|filter((v, k) => k != 'files') %} @@ -70,8 +66,13 @@ {% if files|length > 0 %}

Files:

{% endif %}