diff --git a/franklincce/explorer/templates/explorer/index.html b/franklincce/explorer/templates/explorer/index.html index 268679e..dba8f76 100644 --- a/franklincce/explorer/templates/explorer/index.html +++ b/franklincce/explorer/templates/explorer/index.html @@ -9,12 +9,14 @@

Some randomly selected legislation

- {% if legislative_texts %} + {% if legislation %} + {% autoescape off %} + {% endautoescape %} {% else %}

No texts available. If you're the admin, you need to add some texts with the admin interface.

{% endif %} diff --git a/franklincce/explorer/views.py b/franklincce/explorer/views.py index 28c9077..150be9f 100644 --- a/franklincce/explorer/views.py +++ b/franklincce/explorer/views.py @@ -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 = {