Add sections progress plugin
This commit is contained in:
parent
bde9bf6000
commit
f83a193916
4 changed files with 18 additions and 9 deletions
|
|
@ -354,6 +354,15 @@ class GovernmentPlanSection(models.Model):
|
||||||
def get_absolute_domain_url(self):
|
def get_absolute_domain_url(self):
|
||||||
return settings.SITE_URL + self.get_absolute_url()
|
return settings.SITE_URL + self.get_absolute_url()
|
||||||
|
|
||||||
|
def get_plans(self):
|
||||||
|
return (
|
||||||
|
GovernmentPlan.objects.filter(
|
||||||
|
categories__in=self.categories.all(), government=self.government
|
||||||
|
)
|
||||||
|
.distinct()
|
||||||
|
.order_by("title")
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
if CMSPlugin:
|
if CMSPlugin:
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
{% load thumbnail %}
|
{% load thumbnail %}
|
||||||
|
{% load govplan %}
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
{% for section in sections %}
|
{% for section in sections %}
|
||||||
|
|
@ -27,7 +28,7 @@
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
<div class="flex-grow-1 tight-margin p-3 p-md-4 cms-plugin cms-plugin-87888">
|
<div class="flex-grow-1 tight-margin p-3 p-md-4 cms-plugin cms-plugin-87888">
|
||||||
progress bar
|
{% get_section_progress section %}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -35,3 +35,8 @@ def get_plan_progress(object_list):
|
||||||
|
|
||||||
value, label
|
value, label
|
||||||
return {"count": len(object_list), "sections": sections}
|
return {"count": len(object_list), "sections": sections}
|
||||||
|
|
||||||
|
|
||||||
|
@register.inclusion_tag("froide_govplan/plugins/progress.html")
|
||||||
|
def get_section_progress(section):
|
||||||
|
return {"object_list": section.get_plans()}
|
||||||
|
|
|
||||||
|
|
@ -27,13 +27,7 @@ class GovPlanSectionDetailView(GovernmentMixin, DetailView):
|
||||||
|
|
||||||
def get_context_data(self, **kwargs):
|
def get_context_data(self, **kwargs):
|
||||||
context = super().get_context_data(**kwargs)
|
context = super().get_context_data(**kwargs)
|
||||||
context["plans"] = (
|
context["plans"] = self.context["object"].get_plans()
|
||||||
GovernmentPlan.objects.filter(
|
|
||||||
categories__in=self.object.categories.all(), government=self.government
|
|
||||||
)
|
|
||||||
.distinct()
|
|
||||||
.order_by("title")
|
|
||||||
)
|
|
||||||
return context
|
return context
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue