fix: use the new bill template on index

This commit is contained in:
stupidcomputer 2024-07-30 20:10:38 -05:00
parent fad0b668fa
commit 48a70fb637
2 changed files with 16 additions and 9 deletions

View File

@ -9,12 +9,14 @@
<h2>Some randomly selected legislation</h2>
{% if legislative_texts %}
{% if legislation %}
{% autoescape off %}
<ul>
{% for text in legislative_texts %}
<li><a href="{% url 'viewleg' text.id %}">{{ text.legislation_title }}</a></li>
{% for text in legislation %}
{{ text }}
{% endfor %}
</ul>
{% endautoescape %}
{% else %}
<p>No texts available. If you're the admin, you need to add some texts with the admin interface.</p>
{% endif %}

View File

@ -16,6 +16,11 @@ from .models import (
from random import sample
def legislation_to_html(legislation):
return render_to_string("explorer/comp_legislation.html", {
"legislation": legislation,
})
def index(request):
legislative_texts = list(LegislativeText.objects.all())
try:
@ -23,8 +28,13 @@ def index(request):
except ValueError:
# there's not enough texts, so just return nothing
legislative_texts = []
legislative_texts = [
legislation_to_html(text) for text in legislative_texts
]
context = {
"legislative_texts": legislative_texts,
"legislation": legislative_texts,
}
return render(request, "explorer/index.html", context)
@ -35,11 +45,6 @@ def all(request):
}
return render(request, "explorer/all.html", context)
def legislation_to_html(legislation):
return render_to_string("explorer/comp_legislation.html", {
"legislation": legislation,
})
def view_legislation(request, legislation_id):
legislation = get_object_or_404(LegislativeText, pk=legislation_id)
context = {