fix: use the new bill template on index
This commit is contained in:
parent
fad0b668fa
commit
48a70fb637
|
@ -9,12 +9,14 @@
|
||||||
|
|
||||||
<h2>Some randomly selected legislation</h2>
|
<h2>Some randomly selected legislation</h2>
|
||||||
|
|
||||||
{% if legislative_texts %}
|
{% if legislation %}
|
||||||
|
{% autoescape off %}
|
||||||
<ul>
|
<ul>
|
||||||
{% for text in legislative_texts %}
|
{% for text in legislation %}
|
||||||
<li><a href="{% url 'viewleg' text.id %}">{{ text.legislation_title }}</a></li>
|
{{ text }}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</ul>
|
</ul>
|
||||||
|
{% endautoescape %}
|
||||||
{% else %}
|
{% else %}
|
||||||
<p>No texts available. If you're the admin, you need to add some texts with the admin interface.</p>
|
<p>No texts available. If you're the admin, you need to add some texts with the admin interface.</p>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
|
@ -16,6 +16,11 @@ from .models import (
|
||||||
|
|
||||||
from random import sample
|
from random import sample
|
||||||
|
|
||||||
|
def legislation_to_html(legislation):
|
||||||
|
return render_to_string("explorer/comp_legislation.html", {
|
||||||
|
"legislation": legislation,
|
||||||
|
})
|
||||||
|
|
||||||
def index(request):
|
def index(request):
|
||||||
legislative_texts = list(LegislativeText.objects.all())
|
legislative_texts = list(LegislativeText.objects.all())
|
||||||
try:
|
try:
|
||||||
|
@ -23,8 +28,13 @@ def index(request):
|
||||||
except ValueError:
|
except ValueError:
|
||||||
# there's not enough texts, so just return nothing
|
# there's not enough texts, so just return nothing
|
||||||
legislative_texts = []
|
legislative_texts = []
|
||||||
|
|
||||||
|
legislative_texts = [
|
||||||
|
legislation_to_html(text) for text in legislative_texts
|
||||||
|
]
|
||||||
|
|
||||||
context = {
|
context = {
|
||||||
"legislative_texts": legislative_texts,
|
"legislation": legislative_texts,
|
||||||
}
|
}
|
||||||
return render(request, "explorer/index.html", context)
|
return render(request, "explorer/index.html", context)
|
||||||
|
|
||||||
|
@ -35,11 +45,6 @@ def all(request):
|
||||||
}
|
}
|
||||||
return render(request, "explorer/all.html", context)
|
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):
|
def view_legislation(request, legislation_id):
|
||||||
legislation = get_object_or_404(LegislativeText, pk=legislation_id)
|
legislation = get_object_or_404(LegislativeText, pk=legislation_id)
|
||||||
context = {
|
context = {
|
||||||
|
|
Loading…
Reference in New Issue