verwaltungstracker/froide_govplan/views.py
2022-02-28 11:43:29 +01:00

20 lines
642 B
Python

from django.views.generic import DetailView
from .models import GovernmentPlan
class GovPlanDetailView(DetailView):
slug_url_kwarg = "plan"
template_name = "froide_govplan/detail.html"
def get_queryset(self):
if self.request.user.is_authenticated and self.request.user.is_staff:
return GovernmentPlan.objects.all()
return GovernmentPlan.objects.filter(public=True)
def get_context_data(self, **kwargs):
context = super().get_context_data(**kwargs)
context["updates"] = self.object.updates.filter(public=True).order_by(
"-timestamp"
)
return context