Skip to content

Commit dbaac2d

Browse files
committed
✨ [#1797] Show filename(s) in success msg for document upload
1 parent 61361c6 commit dbaac2d

File tree

5 files changed

+41
-8
lines changed

5 files changed

+41
-8
lines changed

src/open_inwoner/cms/cases/views/status.py

+14-4
Original file line numberDiff line numberDiff line change
@@ -391,12 +391,22 @@ def handle_document_upload(self, request, form):
391391
filename=file.name,
392392
),
393393
)
394+
395+
# TODO implement `created_documents` properly when uploading of multiple
396+
# docs is implemented
397+
created_documents = [created_document]
398+
success_message = (
399+
_(
400+
"Wij hebben **{num_uploaded} bestand(en)** succesvol geüpload:"
401+
).format(num_uploaded=len(created_documents))
402+
+ "\n\n"
403+
+ "\n".join(f"- {doc['titel']}" for doc in created_documents)
404+
)
394405
messages.add_message(
395-
request,
406+
self.request,
396407
messages.SUCCESS,
397-
_("{filename} has been successfully uploaded").format(
398-
filename=file.name
399-
),
408+
success_message,
409+
extra_tags="as_markdown",
400410
)
401411

402412
return HttpResponseClientRedirect(

src/open_inwoner/components/templates/components/Notification/Notification.html

+6-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
{% load i18n button_tags icon_tags button_tags icon_tags %}
1+
{% load i18n ssd_tags button_tags icon_tags button_tags icon_tags %}
22
<div class="notification{% if contents %} notification--contents{% endif %}{% if type %} notification--{{ type }}{% endif %}{% if compact %} notification--compact{% endif %} {% if ctx %}notification--{{ ctx }}{% endif %}">
33
{% if not icon == False %}
44
<div class="notification__icon">
@@ -13,7 +13,11 @@
1313
{% if contents %}
1414
{{ contents }}
1515
{% else %}
16-
<p class="p p--compact">{{ message }}</p>
16+
{% if as_markdown %}
17+
{{ message|markdown|safe }}
18+
{% else %}
19+
<p class="p p--compact">{{ message }}</p>
20+
{% endif %}
1721
{% endif %}
1822
</div>
1923

Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1-
{% load notification_tags %}
1+
{% load notification_tags string_tags %}
22

33
<div class="notifications">
44
{% for message in messages %}
5-
{% notification icon=message.icon type=message.level_tag message=message.message closable=True compact=compact %}
5+
{% with is_markdown=message.extra_tags|is_substring:"as_markdown" %}
6+
{% notification icon=message.icon type=message.level_tag message=message.message as_markdown=is_markdown closable=True compact=compact %}
7+
{% endwith %}
68
{% endfor %}
79
</div>

src/open_inwoner/components/templatetags/string_tags.py

+9
Original file line numberDiff line numberDiff line change
@@ -29,3 +29,12 @@ def optional_paragraph(optional_text: str) -> str:
2929
optional_text=linebreaksbr(optional_text)
3030
)
3131
)
32+
33+
34+
@register.filter
35+
def is_substring(arg1, arg2):
36+
"""check if arg2 is a substring of arg1"""
37+
if not arg1:
38+
return False
39+
40+
return arg2 in arg1

src/open_inwoner/scss/components/Notification/_Notification.scss

+8
Original file line numberDiff line numberDiff line change
@@ -92,4 +92,12 @@
9292
position: inherit;
9393
}
9494
}
95+
96+
& &__content {
97+
margin-top: 0.15em;
98+
99+
& * {
100+
margin: 0;
101+
}
102+
}
95103
}

0 commit comments

Comments
 (0)