From 4469f6d4d1efb34467ba65374ca685457ee907f0 Mon Sep 17 00:00:00 2001 From: Kara Engelhardt Date: Mon, 6 May 2024 17:45:19 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=A9=B9=20Do=20not=20send=20link=20users?= =?UTF-8?q?=20can't=20read=20in=20problem=20report=20resolution?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../templates/problem/email_problem_resolved.txt | 2 ++ froide/problem/utils.py | 12 ++++++++++++ 2 files changed, 14 insertions(+) diff --git a/froide/problem/templates/problem/email_problem_resolved.txt b/froide/problem/templates/problem/email_problem_resolved.txt index a12e95b48..1d7083057 100644 --- a/froide/problem/templates/problem/email_problem_resolved.txt +++ b/froide/problem/templates/problem/email_problem_resolved.txt @@ -5,10 +5,12 @@ {% blocktrans with title=title %}We have resolved the problem you reported on the request “{{ title }}”.{% endblocktrans %} {% endif %} {% if report.resolution %}{{ report.resolution }}{% endif %} +{% if can_read_request %} {% trans "You can go to the request here:" %} {{ url }} +{% endif %} {% blocktrans with site_name=site_name %} Cheers, {{ site_name }}{% endblocktrans %} diff --git a/froide/problem/utils.py b/froide/problem/utils.py index 9a3c211e6..39caa5bce 100644 --- a/froide/problem/utils.py +++ b/froide/problem/utils.py @@ -1,9 +1,12 @@ from django.conf import settings from django.core.mail import mail_managers from django.template.loader import render_to_string +from django.test import RequestFactory from django.urls import reverse from django.utils.translation import gettext_lazy as _ +from froide.foirequest.auth import can_read_foirequest + def inform_managers(report): admin_url = settings.SITE_URL + reverse( @@ -23,6 +26,14 @@ def inform_managers(report): ) +def can_read(user, foirequest): + request_factory = RequestFactory() + request = request_factory.get(foirequest.get_absolute_url()) + request.user = user + + can_read_foirequest(foirequest, request) + + def inform_user_problem_resolved(report): if report.auto_submitted or not report.user: return False @@ -39,6 +50,7 @@ def inform_user_problem_resolved(report): report.message.get_absolute_short_url() ), "site_name": settings.SITE_NAME, + "can_read_request": can_read(report.user, foirequest), }, )