Skip to content

Commit

Permalink
feat(core/api): new submission file download endpoint (#855)
Browse files Browse the repository at this point in the history
  • Loading branch information
Davidmattei authored Mar 30, 2024
1 parent dd8370a commit b349cbd
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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\":[]}]"
}
13 changes: 12 additions & 1 deletion skeleton/routes.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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}' }
Expand Down Expand Up @@ -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
Expand Down
19 changes: 19 additions & 0 deletions skeleton/template/sso/test_sso.html.twig
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{% extends '@EMSCH/template/base/base.html.twig' %}

{% block headtitle %}SSO Test{% endblock %}

{% block body %}
<div class="d-flex justify-content-center align-items-center mt-5">
<div class="w-25">
<div class="card">
<div class="card-header">
SSO Test
</div>
<div class="card-body">
<p>Welcome {{ app.user.userIdentifier }}</p>
<a href="{{ path('emsch_logout') }}" class="btn btn-primary">Logout</a>
</div>
</div>
</div>
</div>
{% endblock body %}
19 changes: 10 additions & 9 deletions skeleton/template_ems/submission/form_example_files.twig
Original file line number Diff line number Diff line change
Expand Up @@ -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 %}
{{- "[email protected]" -}}
{% 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') %}
Expand All @@ -70,8 +66,13 @@
{% if files|length > 0 %}
<p>Files:</p>
<ul>
{% for file in files %}
<li>{{ file.originalName }}</li>
{% for index, file in files %}
{% set submissionFile = submission.files[index] %}
<li>
<a href="{{ "#{skeletonUrl}/form/#{submission.id}/attachment/#{submissionFile.id}" }}">
{{ file.originalName }}
</a>
</li>
{% endfor %}
</ul>
{% endif %}
Expand Down

0 comments on commit b349cbd

Please sign in to comment.