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):
|
||||
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:
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
{% load thumbnail %}
|
||||
{% load govplan %}
|
||||
|
||||
<style>
|
||||
{% for section in sections %}
|
||||
|
|
@ -27,11 +28,11 @@
|
|||
{% endif %}
|
||||
</div>
|
||||
<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>
|
||||
</a>
|
||||
</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -35,3 +35,8 @@ def get_plan_progress(object_list):
|
|||
|
||||
value, label
|
||||
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):
|
||||
context = super().get_context_data(**kwargs)
|
||||
context["plans"] = (
|
||||
GovernmentPlan.objects.filter(
|
||||
categories__in=self.object.categories.all(), government=self.government
|
||||
)
|
||||
.distinct()
|
||||
.order_by("title")
|
||||
)
|
||||
context["plans"] = self.context["object"].get_plans()
|
||||
return context
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue