Skip to content

Commit

Permalink
Merge branch 'okfde:main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
tyliec authored Mar 7, 2024
2 parents 58bd144 + f59bdb3 commit 2e69542
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 14 deletions.
38 changes: 27 additions & 11 deletions froide/foirequest/forms/message.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from django import forms
from django.conf import settings
from django.db import transaction
from django.template import Context, Template
from django.template.loader import render_to_string
from django.utils import timezone
from django.utils.translation import gettext_lazy as _
Expand Down Expand Up @@ -122,17 +123,32 @@ def get_send_message_form(*args, **kwargs):
if foirequest.is_overdue() and foirequest.awaits_response():
days = (timezone.now() - foirequest.due_date).days + 1
first_message = foirequest.messages[0]
message = render_to_string(
select_foirequest_template(
foirequest, "foirequest/emails/overdue_reply.txt"
),
{
"due": ngettext_lazy("%(count)s day", "%(count)s days", days)
% {"count": days},
"foirequest": foirequest,
"first_message": first_message,
},
)

context = {
"due": ngettext_lazy("%(count)s day", "%(count)s days", days)
% {"count": days},
"foirequest": foirequest,
"first_message": first_message,
}

message = None

if foirequest.law.overdue_reply:
template_str = "{top}{body}{bottom}{footer}".format(
top="{% autoescape off %}",
body=foirequest.law.overdue_reply,
bottom="{% endautoescape %}",
footer='\r\n{% include "foirequest/emails/overdue_reply_footer.txt" %}',
)
message = Template(template_str).render(Context(context))
if not message:
message = render_to_string(
select_foirequest_template(
foirequest, "foirequest/emails/overdue_reply.txt"
),
context,
)

else:
message = get_default_initial_message(foirequest.user)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,5 @@ Please update me on the status of my request as soon as possible.

Sincerely yours,
{{ name }}{% endblocktrans %}

{% translate "-------- Forwarded Message --------" %}
{{ first_message.get_quoted_message }}{% endautoescape %}
{% endautoescape %}
{% include "foirequest/emails/overdue_reply_footer.txt" %}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{% load i18n %}{% autoescape off%}
{% translate "-------- Forwarded Message --------" %}
{{ first_message.get_quoted_message }}
{% endautoescape %}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Generated by Django 4.2.4 on 2024-03-04 13:28

from django.db import migrations, models


class Migration(migrations.Migration):
dependencies = [
("publicbody", "0045_jurisdiction_last_modified_at"),
]

operations = [
migrations.AddField(
model_name="foilawtranslation",
name="overdue_reply",
field=models.TextField(blank=True, verbose_name="overdue reply"),
),
]
1 change: 1 addition & 0 deletions froide/publicbody/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ class FoiLaw(TranslatableModel):
letter_start=models.TextField(_("Start of Letter"), blank=True),
letter_end=models.TextField(_("End of Letter"), blank=True),
refusal_reasons=models.TextField(_("refusal reasons"), blank=True),
overdue_reply=models.TextField(_("overdue reply"), blank=True),
)

created = models.DateField(_("Creation Date"), blank=True, null=True)
Expand Down

0 comments on commit 2e69542

Please sign in to comment.