2024-06-19 05:41:13 -05:00
|
|
|
from django.shortcuts import get_object_or_404, render
|
|
|
|
from django.http import HttpResponse
|
2024-06-19 01:29:05 -05:00
|
|
|
|
2024-06-19 05:41:13 -05:00
|
|
|
from .models import LegislativeText, LegislationBook
|
|
|
|
|
2024-06-21 03:02:03 -05:00
|
|
|
from random import sample
|
|
|
|
|
2024-06-19 05:41:13 -05:00
|
|
|
def index(request):
|
2024-06-21 03:02:03 -05:00
|
|
|
legislative_texts = list(LegislativeText.objects.all())
|
|
|
|
legislative_texts = sample(legislative_texts, 5)
|
2024-06-19 05:41:13 -05:00
|
|
|
context = {
|
|
|
|
"legislative_texts": legislative_texts,
|
|
|
|
}
|
|
|
|
return render(request, "explorer/index.html", context)
|
|
|
|
|
2024-06-21 03:02:03 -05:00
|
|
|
def all(request):
|
|
|
|
legislative_texts = list(LegislativeText.objects.all())
|
|
|
|
context = {
|
|
|
|
"legislative_texts": legislative_texts,
|
|
|
|
}
|
|
|
|
return render(request, "explorer/all.html", context)
|
|
|
|
|
2024-06-19 05:41:13 -05:00
|
|
|
def view_legislation(request, legislation_id):
|
|
|
|
legislation = get_object_or_404(LegislativeText, pk=legislation_id)
|
|
|
|
context = {
|
|
|
|
"legislation": legislation,
|
2024-06-21 03:02:03 -05:00
|
|
|
"lines": legislation.get_lines()
|
2024-06-19 05:41:13 -05:00
|
|
|
}
|
|
|
|
return render(request, "explorer/legislation.html", context)
|