Use active flag to show notices, disable follow, request, send update feature

This commit is contained in:
Stefan Wehrmeyer 2025-01-27 14:21:28 +01:00
parent 68e48a04e8
commit f176380761
4 changed files with 225 additions and 221 deletions

View file

@ -2,7 +2,6 @@ from datetime import datetime
from typing import Iterator from typing import Iterator
from django.utils.translation import gettext_lazy as _ from django.utils.translation import gettext_lazy as _
from froide.follow.configuration import FollowConfiguration from froide.follow.configuration import FollowConfiguration
from froide.helper.notifications import Notification, TemplatedEvent from froide.helper.notifications import Notification, TemplatedEvent
@ -35,7 +34,11 @@ class GovernmentPlanFollowConfiguration(FollowConfiguration):
return GovernmentPlan.objects.all() return GovernmentPlan.objects.all()
def can_follow(self, content_object, user, request=None): def can_follow(self, content_object, user, request=None):
return content_object.public or not has_limited_access(user) return (
content_object.government.active
and content_object.public
or not has_limited_access(user)
)
def get_batch_updates( def get_batch_updates(
self, start: datetime, end: datetime self, start: datetime, end: datetime

View file

@ -1,6 +1,6 @@
{% extends "froide_govplan/base.html" %} {% extends "froide_govplan/base.html" %}
{% load i18n %}
{% load i18n %} {# TODO: i18n for all strings #} {# TODO: i18n for all strings #}
{% load markup %} {% load markup %}
{% load cms_tags %} {% load cms_tags %}
{% load follow_tags %} {% load follow_tags %}
@ -8,43 +8,37 @@
{% load form_helper %} {% load form_helper %}
{% load content_helper %} {% load content_helper %}
{% load thumbnail %} {% load thumbnail %}
{% block title %}
{% block title %}{{ object.title }}{% endblock title %} {{ object.title }}
{% endblock title %}
{% block meta %} {% block meta %}
{% include "snippets/meta.html" %} {% include "snippets/meta.html" %}
{% endblock meta %} {% endblock meta %}
{% block app_body %} {% block app_body %}
<div class="container mb-3"> <div class="container mb-3">
<div class="box-card border-yellow md:shadow-yellow bg-body mb-5"> <div class="box-card border-yellow md:shadow-yellow bg-body mb-5">
<div> <div>
<div class="flex-grow-1 tight-margin p-3 p-md-4 p-lg-5"> <div class="flex-grow-1 tight-margin p-3 p-md-4 p-lg-5">
<h1 class="mt-0 h3"> {% if not government.active %}
{{ object.title }} <div class="alert alert-info">Dieses Vorhaben gehörte zur {{ government.name }} und wird nicht mehr aktualisiert.</div>
</h1> {% endif %}
<h1 class="mt-0 h3">{{ object.title }}</h1>
<div class="d-md-flex my-4 align-items-center"> <div class="d-md-flex my-4 align-items-center">
<ul class="list-unstyled d-flex m-0"> <ul class="list-unstyled d-flex m-0">
<li> <li>
<span class="badge text-bg-{{ object.get_status_css }} me-2"> <span class="badge text-bg-{{ object.get_status_css }} me-2">{{ object.get_status_display }}</span>
{{ object.get_status_display }}
</span>
</li> </li>
{% for cat in object.categories.all %} {% for cat in object.categories.all %}
<li> <li>
<a href="{{ section.get_absolute_url }}" class="badge text-bg-light-subtle me-2"> <a href="{{ section.get_absolute_url }}"
{{ cat.name }} class="badge text-bg-light-subtle me-2">{{ cat.name }}</a>
</a>
</li> </li>
{% endfor %} {% endfor %}
</ul> </ul>
{% if government.active %}
<div class="ms-auto mt-2 mt-md-0"> <div class="ms-auto mt-2 mt-md-0">{% show_follow "govplan" object %}</div>
{% show_follow "govplan" object %} {% endif %}
</div> </div>
</div>
<div class="row"> <div class="row">
<div class="col col-12 col-md-7 col-lg-8 order-md-2 offset-lg-1"> <div class="col col-12 col-md-7 col-lg-8 order-md-2 offset-lg-1">
<dl> <dl>
@ -65,20 +59,19 @@
{% endif %} {% endif %}
</span> </span>
{% for ref in refs %} {% for ref in refs %}
<a href="{{ ref }}" class="badge text-bg-light me-2" target="_blank"> <a href="{{ ref }}" class="badge text-bg-light me-2" target="_blank">{{ forloop.counter }}</a>
{{ forloop.counter }}
</a>
{% endfor %} {% endfor %}
</p> </p>
{% endif %} {% endif %}
{% endwith %} {% endwith %}
{% endif %} {% endif %}
</dd> </dd>
{% if object.description %} {% if object.description %}
<div class="mt-3 mt-md-5"> <div class="mt-3 mt-md-5">
<dt>Unsere Einschätzung</dt> <dt>Unsere Einschätzung</dt>
<dd>{{ object.description | safe }}</dd> <dd>
{{ object.description | safe }}
</dd>
</div> </div>
{% endif %} {% endif %}
</dl> </dl>
@ -87,36 +80,36 @@
<dl> <dl>
{% if object.rating %} {% if object.rating %}
<dt>Bewertung</dt> <dt>Bewertung</dt>
<dd>{{ object.get_rating_display }}</dd> <dd>
{{ object.get_rating_display }}
</dd>
{% endif %} {% endif %}
{% if object.measure %} {% if object.measure %}
<dt>Art der Umsetzung</dt> <dt>Art der Umsetzung</dt>
<dd>{{ object.measure }}</dd> <dd>
{{ object.measure }}
</dd>
{% endif %} {% endif %}
{% if object.due_date %} {% if object.due_date %}
<dt>Frist</dt> <dt>Frist</dt>
<dd>{{ object.due_date|date:"SHORT_DATE_FORMAT" }}</dd> <dd>
{{ object.due_date|date:"SHORT_DATE_FORMAT" }}
</dd>
{% endif %} {% endif %}
{% if object.responsible_publicbody %} {% if object.responsible_publicbody %}
<dt>Federführung</dt> <dt>Federführung</dt>
<dd> <dd>
<a href="{{ object.responsible_publicbody.get_absolute_url }}"> <a href="{{ object.responsible_publicbody.get_absolute_url }}">{{ object.responsible_publicbody.name }}</a>
{{ object.responsible_publicbody.name }}
</a>
</dd> </dd>
{% endif %} {% endif %}
{% if object.responsible_publicbody %} {% if object.responsible_publicbody %}
{% if not object.has_recent_foirequest %} {% if not object.has_recent_foirequest and government.active %}
<p> <p>
<a href="{{ object.make_request_url }}" target="_blank" class="btn btn-outline-primary btn-sm"> <a href="{{ object.make_request_url }}"
Anfrage zum Vorhaben stellen target="_blank"
</a> class="btn btn-outline-primary btn-sm">Anfrage zum Vorhaben stellen</a>
</p> </p>
{% else %} {% elif object.has_recent_foirequest %}
{% with foirequest=object.get_recent_foirequest %} {% with foirequest=object.get_recent_foirequest %}
<dt>Anfrage</dt> <dt>Anfrage</dt>
<dd> <dd>
@ -125,16 +118,20 @@
{% endwith %} {% endwith %}
{% endif %} {% endif %}
{% endif %} {% endif %}
{% if object.organization %} {% if object.organization %}
<dt>Beobachtet von</dt> <dt>Beobachtet von</dt>
<dd> <dd>
<a href="{{ object.organization.website }}"> <a href="{{ object.organization.website }}">
{% if object.organization.logo %} {% if object.organization.logo %}
{% if object.organization.logo.url.lower|slice:"-4:" == ".svg" %} {% if object.organization.logo.url.lower|slice:"-4:" == ".svg" %}
<img src="{{ object.organization.logo.url }}" class="col-8 col-md-12 px-0" alt="{{ object.organization.name }}"> {# djlint:off H006 #}
<img src="{{ object.organization.logo.url }}"
class="col-8 col-md-12 px-0"
alt="{{ object.organization.name }}">
{% else %} {% else %}
<img src="{% thumbnail object.organization.logo 300x0 %}" class="col-8 col-md-12 px-0" alt="{{ object.organization.name }}"> <img src="{% thumbnail object.organization.logo 300x0 %}"
class="col-8 col-md-12 px-0"
alt="{{ object.organization.name }}">
{% endif %} {% endif %}
{% else %} {% else %}
{{ object.organization.name }} {{ object.organization.name }}
@ -148,10 +145,9 @@
</div> </div>
</div> </div>
</div> </div>
<div class="row"> <div class="row">
{% include "froide_govplan/plugins/updates.html" with wrapper_classes="col col-12 col-lg-6 d-flex mb-4" %} {% include "froide_govplan/plugins/updates.html" with wrapper_classes="col col-12 col-lg-6 d-flex mb-4" %}
{% if government.active %}
<div class="col col-12 col-lg-6 d-flex mb-4"> <div class="col col-12 col-lg-6 d-flex mb-4">
<div class="box-card border-gray shadow-gray"> <div class="box-card border-gray shadow-gray">
<div> <div>
@ -161,26 +157,30 @@
<div class="p-3 p-md-4"> <div class="p-3 p-md-4">
{% if request.user.is_authenticated %} {% if request.user.is_authenticated %}
<p>Gibt es Neuigkeiten zu diesem Vorhaben, die wir noch nicht erfasst haben?</p> <p>Gibt es Neuigkeiten zu diesem Vorhaben, die wir noch nicht erfasst haben?</p>
<button type="button" class="btn btn-outline-secondary" data-bs-toggle="modal" data-bs-target="#govplanupdate-proposal"> <button type="button"
Entwicklung melden class="btn btn-outline-secondary"
</button> data-bs-toggle="modal"
<div class="modal" data-teleport="body" tabindex="-1" role="dialog" id="govplanupdate-proposal"> data-bs-target="#govplanupdate-proposal">Entwicklung melden</button>
<div class="modal"
data-teleport="body"
tabindex="-1"
role="dialog"
id="govplanupdate-proposal">
<div class="modal-dialog modal-lg modal-dialog-centered" role="document"> <div class="modal-dialog modal-lg modal-dialog-centered" role="document">
<div class="modal-content"> <div class="modal-content">
<div class="modal-header"> <div class="modal-header">
<h5 class="modal-title"> <h5 class="modal-title">Neue Entwicklung melden</h5>
Neue Entwicklung melden <button type="button"
</h5> class="btn-close"
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="{% translate 'Close' %}"> data-bs-dismiss="modal"
</button> aria-label="{% translate "Close" %}"></button>
</div> </div>
<div class="modal-body"> <div class="modal-body">
<form method="post" action="{% url 'govplan:propose_planupdate' gov=object.government.slug plan=object.slug %}"> <form method="post"
action="{% url 'govplan:propose_planupdate' gov=object.government.slug plan=object.slug %}">
{% csrf_token %} {% csrf_token %}
{% render_form update_proposal_form %} {% render_form update_proposal_form %}
<button type="submit" class="btn btn-primary"> <button type="submit" class="btn btn-primary">Neue Entwicklung melden</button>
Neue Entwicklung melden
</button>
</form> </form>
</div> </div>
</div> </div>
@ -193,6 +193,7 @@
</div> </div>
</div> </div>
</div> </div>
{% endif %}
</div> </div>
</div> </div>
{% endblock app_body %} {% endblock app_body %}

View file

@ -1,17 +1,15 @@
{% extends "froide_govplan/base.html" %} {% extends "froide_govplan/base.html" %}
{% load i18n %} {% load i18n %}
{% load markup %} {% load markup %}
{% load cms_tags %} {% load cms_tags %}
{% load follow_tags %} {% load follow_tags %}
{% load thumbnail %} {% load thumbnail %}
{% block title %}
{% block title %}{{ object.title }}{% endblock %} {{ object.title }}
{% endblock title %}
{% block meta %} {% block meta %}
{% include "snippets/meta.html" %} {% include "snippets/meta.html" %}
{% endblock %} {% endblock meta %}
{% block app_body %} {% block app_body %}
<div class="container"> <div class="container">
<div class="row justify-content-center mb-5"> <div class="row justify-content-center mb-5">
@ -19,10 +17,12 @@
<div class="box-card border-yellow md:shadow-yellow bg-body p-3 p-md-4 p-lg-5 tight-margin"> <div class="box-card border-yellow md:shadow-yellow bg-body p-3 p-md-4 p-lg-5 tight-margin">
<div class="row mx-0"> <div class="row mx-0">
<div class="col col-12 col-md-12 ps-0 tight-margin"> <div class="col col-12 col-md-12 ps-0 tight-margin">
<h1 class="mt-0 h2"> {% if not government.active %}
{{ object.title }} <div class="alert alert-info">
</h1> Dieser Themenbereich gehörte zur {{ government.name }} und wird nicht mehr aktualisiert.
</div>
{% endif %}
<h1 class="mt-0 h2">{{ object.title }}</h1>
<p> <p>
{% blocktranslate with section=object.title %} {% blocktranslate with section=object.title %}
Here you can find all plans of the section “{{ section }}”, which the coalition constituted in their agreement. On the curresponding detail pages, you'll get more information, stay up to date with news or submit changes. Here you can find all plans of the section “{{ section }}”, which the coalition constituted in their agreement. On the curresponding detail pages, you'll get more information, stay up to date with news or submit changes.
@ -30,7 +30,6 @@
</p> </p>
</div> </div>
</div> </div>
<div class="mt-5"> <div class="mt-5">
{% include "froide_govplan/plugins/progress_row.html" with object_list=plans %} {% include "froide_govplan/plugins/progress_row.html" with object_list=plans %}
<p class="small text-body-secondary mt-3 no-hyphens"> <p class="small text-body-secondary mt-3 no-hyphens">
@ -45,7 +44,6 @@
</div> </div>
</div> </div>
</div> </div>
{% include "froide_govplan/plugins/card_cols.html" with object_list=plans %} {% include "froide_govplan/plugins/card_cols.html" with object_list=plans %}
</div> </div>
{% endblock app_body %} {% endblock app_body %}

View file

@ -109,7 +109,9 @@ class GovPlanProposeUpdateView(GovernmentMixin, LoginRequiredMixin, UpdateView):
return redirect(self.object) return redirect(self.object)
def get_queryset(self): def get_queryset(self):
qs = GovernmentPlan.objects.filter(government=self.government) qs = GovernmentPlan.objects.filter(
government=self.government, government__active=True
)
if self.request.user.is_authenticated and self.request.user.is_staff: if self.request.user.is_authenticated and self.request.user.is_staff:
return qs return qs
return qs.filter(public=True) return qs.filter(public=True)