diff --git a/src/open_inwoner/accounts/templates/accounts/inbox.html b/src/open_inwoner/accounts/templates/accounts/inbox.html index 1a929dcbb8..37ffb3b8ac 100644 --- a/src/open_inwoner/accounts/templates/accounts/inbox.html +++ b/src/open_inwoner/accounts/templates/accounts/inbox.html @@ -39,6 +39,6 @@

{% trans 'Mijn berichten' %}

{% block content %} {% if conversation_messages or other_user %} - {% messages conversation_messages request.user form other_user.get_full_name status %} + {% messages message_list=conversation_messages me=request.user form=form other_user=other_user status=status %} {% endif %} {% endblock %} diff --git a/src/open_inwoner/accounts/views/inbox.py b/src/open_inwoner/accounts/views/inbox.py index 7843b968d7..78e1f465cc 100644 --- a/src/open_inwoner/accounts/views/inbox.py +++ b/src/open_inwoner/accounts/views/inbox.py @@ -121,7 +121,6 @@ def get_initial(self): def get_form_kwargs(self): kwargs = super().get_form_kwargs() kwargs["user"] = self.request.user - return kwargs def form_valid(self, form): diff --git a/src/open_inwoner/components/templates/components/Messages/Messages.html b/src/open_inwoner/components/templates/components/Messages/Messages.html index eb14186ad0..4a32399b6c 100644 --- a/src/open_inwoner/components/templates/components/Messages/Messages.html +++ b/src/open_inwoner/components/templates/components/Messages/Messages.html @@ -1,4 +1,4 @@ -{% load button_tags form_tags messages_tags %} +{% load i18n button_tags form_tags messages_tags %}
@@ -37,18 +37,21 @@

{{ day.text }}

{% endfor %} - {% render_form id="message-form" form=form method="POST" enctype="multipart/form-data" %} - {% csrf_token %} - {% hidden form.receiver %} -
- {% textarea form.content %} -
- {% input form.file icon="attach_file" no_label=True no_help=True extra_classes="message-file" %} - {% button class="emoji-button" icon="tag_faces" text=_('Selecteer emoji') hide_text=True type="button" %} + {% if other_user.is_active %} + {% render_form id="message-form" form=form method="POST" enctype="multipart/form-data" %} + {% csrf_token %} + {% hidden form.receiver %} +
+ {% textarea form.content %} +
+ {% input form.file icon="attach_file" no_label=True no_help=True extra_classes="message-file" %} + {% button class="emoji-button" icon="tag_faces" text=_('Selecteer emoji') hide_text=True type="button" %} +
-
- {% form_actions primary_text=_("Verzenden") primary_icon='arrow_forward' %} - {% endrender_form %} - + {% form_actions primary_text=_("Verzenden") primary_icon='arrow_forward' %} + {% endrender_form %} + {% else %} +

{% trans "De gebruiker is inactief. Het is niet mogelijk een bericht te sturen." %}

+ {% endif %}
diff --git a/src/open_inwoner/components/templatetags/messages_tags.py b/src/open_inwoner/components/templatetags/messages_tags.py index fce0ea0c2e..c356eb43b5 100644 --- a/src/open_inwoner/components/templatetags/messages_tags.py +++ b/src/open_inwoner/components/templatetags/messages_tags.py @@ -17,24 +17,25 @@ def messages( message_list: MessageQuerySet, me: User, form: Form, - subject: str, + other_user: str, status: str, ): """ Generate all messages in a conversation and shows the form to add a new message Usage: - {% messages message_list=messages me=request.user form=message_form subject="this is the subject" status="open" %} + {% messages message_list=messages me=request.user form=message_form other_user=other_user status="open" %} Variables: + message_list: Message[] | a list of messages that needs to be displayed. + me: User | currently loggedin user. + form: Form | a django form. - + subject: string | The title that will be displayed above the messages. + + other_user: User | The user that we will be messaging. + status: string | The status below the subject. Extra context: - days: set | the message_list grouped by date. + - subject: string | The title that will be displayed above the messages. """ def get_dates(message_list: MessageQuerySet) -> List[datetime.date]: @@ -80,7 +81,8 @@ def get_messages_by_date(message_list: MessageQuerySet) -> List[dict]: "form": form, "me": me, "status": status, - "subject": subject, + "other_user": other_user, + "subject": other_user.get_full_name(), } diff --git a/src/open_inwoner/components/tests/test_messages.py b/src/open_inwoner/components/tests/test_messages.py index ff46f14f79..0e571b9c30 100644 --- a/src/open_inwoner/components/tests/test_messages.py +++ b/src/open_inwoner/components/tests/test_messages.py @@ -19,31 +19,31 @@ def setUp(self) -> None: self.me = UserFactory.create( first_name="My", last_name="User", email="myuser@example.com" ) - other_user = UserFactory.create( + self.other_user = UserFactory.create( first_name="Other", last_name="User", email="otheruser@example.com" ) self.message_1 = MessageFactory.create( sender=self.me, - receiver=other_user, + receiver=self.other_user, created_on=timezone.now() - datetime.timedelta(days=2), content="Lorem ipsum.", ) self.message_2 = MessageFactory.create( sender=self.me, - receiver=other_user, + receiver=self.other_user, created_on=timezone.now() - datetime.timedelta(days=1), content="Dolor sit amet.", ) self.message_3 = MessageFactory.create( - sender=other_user, + sender=self.other_user, receiver=self.me, created_on=timezone.now(), content="Consectetur adipiscing elit.", ) self.message_4 = MessageFactory.create( sender=self.me, - receiver=other_user, + receiver=self.other_user, created_on=timezone.now() - datetime.timedelta(hours=2), content="Maecenas dignissim felis nec purus viverra.", ) @@ -54,7 +54,7 @@ def setUp(self) -> None: "message_list": message_queryset, "me": self.me, "form": InboxForm(user=self.me), - "subject": "Lorem ipsum.", + "other_user": self.other_user, "status": "Dolor sit amet.", } @@ -64,7 +64,7 @@ def test_render(self): "message_list": [], "me": self.me, "form": InboxForm(user=self.me), - "subject": "Lorem ipsum.", + "other_user": self.other_user, "status": "Dolor sit amet.", } ) @@ -133,7 +133,9 @@ def test_subject(self): Tests that: - Header renders the correct subject. """ - self.assertTextContent(".messages__header .h4", "Lorem ipsum.", self.config) + self.assertTextContent( + ".messages__header .h4", self.other_user.get_full_name(), self.config + ) def test_status(self): """ diff --git a/src/open_inwoner/pdc/migrations/0038_alter_category_highlighted.py b/src/open_inwoner/pdc/migrations/0038_alter_category_highlighted.py new file mode 100644 index 0000000000..94bfce50d3 --- /dev/null +++ b/src/open_inwoner/pdc/migrations/0038_alter_category_highlighted.py @@ -0,0 +1,22 @@ +# Generated by Django 3.2.13 on 2022-06-01 08:30 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ("pdc", "0037_category_highlighted"), + ] + + operations = [ + migrations.AlterField( + model_name="category", + name="highlighted", + field=models.BooleanField( + default=False, + help_text="Wether the category should be highlighted or not.", + verbose_name="Highlighted", + ), + ), + ] diff --git a/src/open_inwoner/scss/components/Button/Button.scss b/src/open_inwoner/scss/components/Button/Button.scss index 3fe4fcc0e9..1b16606988 100644 --- a/src/open_inwoner/scss/components/Button/Button.scss +++ b/src/open_inwoner/scss/components/Button/Button.scss @@ -125,6 +125,8 @@ } &--disabled { + background-color: var(--color-gray) !important; + border-color: var(--color-gray) !important; color: var(--color-gray-light); pointer-events: none; cursor: default;