Compare commits
No commits in common. "4d5d3f50a1493e6fd5dad7c8dd6fd602c7e3bd3a" and "d713f4106d7e76bf98ae20fe59b6f3cbfe50d3b4" have entirely different histories.
4d5d3f50a1
...
d713f4106d
|
@ -136,10 +136,6 @@ class LegislationBook(models.Model):
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return "{}".format(self.name)
|
return "{}".format(self.name)
|
||||||
|
|
||||||
def get_absolute_url(self):
|
|
||||||
our_name = __class__.__name__
|
|
||||||
return reverse("{}.detail".format(our_name), kwargs={"model_id": self.id})
|
|
||||||
|
|
||||||
class LegislativeText(models.Model):
|
class LegislativeText(models.Model):
|
||||||
class Meta:
|
class Meta:
|
||||||
verbose_name = "Legislation"
|
verbose_name = "Legislation"
|
||||||
|
@ -224,11 +220,4 @@ class LegislationClassification(models.Model):
|
||||||
our_name = __class__.__name__
|
our_name = __class__.__name__
|
||||||
return reverse("{}.detail".format(our_name), kwargs={"model_id": self.id})
|
return reverse("{}.detail".format(our_name), kwargs={"model_id": self.id})
|
||||||
|
|
||||||
models_in_index = [
|
models_in_index = [LegislationClassification, School, Country, Sponsor, Category]
|
||||||
LegislationClassification,
|
|
||||||
School,
|
|
||||||
Country,
|
|
||||||
Sponsor,
|
|
||||||
Category,
|
|
||||||
LegislationBook
|
|
||||||
]
|
|
|
@ -1,38 +0,0 @@
|
||||||
{% comment %}
|
|
||||||
This is a component -- I'm only using this because:
|
|
||||||
1. I'm too lazy to install django-components, and
|
|
||||||
2. This is the only time a component is necessary, so it doesn't make
|
|
||||||
any sense to take on an extra dependancy.
|
|
||||||
{% endcomment %}
|
|
||||||
<div class="legcomponent">
|
|
||||||
<a href="/explorer/legislation/{{ legislation.id }}"><h2 class="legtitle">{{ legislation.legislation_title }}</h2></a>
|
|
||||||
|
|
||||||
<div class="legmetadata">
|
|
||||||
<p>
|
|
||||||
<i>{{ legislation.assembly }}/{{ legislation.committee }}/{{ legislation.docket_order }}</i>
|
|
||||||
|
|
||||||
·
|
|
||||||
|
|
||||||
{% for sponsor in legislation.sponsors.all %}
|
|
||||||
<a href="/explorer/sponsors/{{ sponsor.id }}">{{ sponsor.name }}</a>{% if not forloop.last %}, {% endif %}
|
|
||||||
{% endfor %}
|
|
||||||
|
|
||||||
·
|
|
||||||
|
|
||||||
<a href="/explorer/schools/{{ legislation.school.id }}">{{ legislation.school }}</a>
|
|
||||||
|
|
||||||
·
|
|
||||||
|
|
||||||
{% if legislation.country %}
|
|
||||||
<a href="/explorer/countries/{{ legislation.country.id }}"></a>
|
|
||||||
|
|
||||||
·
|
|
||||||
{% endif %}
|
|
||||||
<a href="/explorer/categories/{{ legislation.category.id }}">{{ legislation.category }}</a>
|
|
||||||
|
|
||||||
·
|
|
||||||
|
|
||||||
<a href="/explorer/conference/{{ legislation.from_book.id }}">{{ legislation.from_book.name }}</a>
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
|
@ -6,12 +6,10 @@
|
||||||
<div class="boxed">
|
<div class="boxed">
|
||||||
<h1>{{ result_name }}</h1>
|
<h1>{{ result_name }}</h1>
|
||||||
|
|
||||||
{% autoescape off %}
|
|
||||||
<ul>
|
<ul>
|
||||||
{% for text in legislation %}
|
{% for text in legislation %}
|
||||||
{{ text }}
|
<li><a href="/explorer/legislation/{{ text.id }}">{{ text.legislation_title }}</a></li>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</ul>
|
</ul>
|
||||||
{% endautoescape %}
|
|
||||||
</div>
|
</div>
|
||||||
{% endblock content %}
|
{% endblock content %}
|
||||||
|
|
|
@ -7,6 +7,7 @@ urlpatterns = [
|
||||||
path("all/", views.all, name="all"),
|
path("all/", views.all, name="all"),
|
||||||
path("stats/", views.stats, name="stats"),
|
path("stats/", views.stats, name="stats"),
|
||||||
path("legislation/<int:legislation_id>/", views.view_legislation, name="viewleg"),
|
path("legislation/<int:legislation_id>/", views.view_legislation, name="viewleg"),
|
||||||
|
path("conference/<int:conference_id>/", views.view_conference, name="viewconf"),
|
||||||
path("topics/<int:model_id>/", views.get_all_classified_by_id, name="LegislationClassification.detail"),
|
path("topics/<int:model_id>/", views.get_all_classified_by_id, name="LegislationClassification.detail"),
|
||||||
path("topics/", views.get_all_classifications, name="LegislationClassification"),
|
path("topics/", views.get_all_classifications, name="LegislationClassification"),
|
||||||
path("search/", views.handle_search, name="search_legislation"),
|
path("search/", views.handle_search, name="search_legislation"),
|
||||||
|
@ -16,11 +17,9 @@ urlpatterns = [
|
||||||
path("countries/<int:model_id>/", views.get_all_by_country, name="Country.detail"),
|
path("countries/<int:model_id>/", views.get_all_by_country, name="Country.detail"),
|
||||||
path("sponsors/<int:model_id>/", views.get_all_by_sponsor, name="Sponsor.detail"),
|
path("sponsors/<int:model_id>/", views.get_all_by_sponsor, name="Sponsor.detail"),
|
||||||
path("categories/<int:model_id>/", views.get_all_by_category, name="Category.detail"),
|
path("categories/<int:model_id>/", views.get_all_by_category, name="Category.detail"),
|
||||||
path("conference/<int:model_id>/", views.get_all_by_conference, name="LegislationBook.detail"),
|
|
||||||
path("schools/", views.get_all_schools, name="School"),
|
path("schools/", views.get_all_schools, name="School"),
|
||||||
path("countries/", views.get_all_countries, name="Country"),
|
path("countries/", views.get_all_countries, name="Country"),
|
||||||
path("groups/", views.return_groups, name="Groups"),
|
path("groups/", views.return_groups, name="Groups"),
|
||||||
path("sponsors/", views.get_all_sponsors, name="Sponsor"),
|
path("sponsors/", views.get_all_sponsors, name="Sponsor"),
|
||||||
path("categories/", views.get_all_categories, name="Category"),
|
path("categories/", views.get_all_categories, name="Category"),
|
||||||
path("conference/", views.get_all_conferences, name="LegislationBook"),
|
|
||||||
]
|
]
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
from django.shortcuts import get_object_or_404, render
|
from django.shortcuts import get_object_or_404, render
|
||||||
from django.template.loader import render_to_string
|
|
||||||
from django.urls import reverse
|
from django.urls import reverse
|
||||||
from django.http import HttpResponse
|
from django.http import HttpResponse
|
||||||
|
|
||||||
|
@ -35,11 +34,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 = {
|
||||||
|
@ -98,11 +92,9 @@ def get_all_classified_by_id(request, model_id):
|
||||||
def get_all_by_x(model):
|
def get_all_by_x(model):
|
||||||
def wrapped(request, model_id):
|
def wrapped(request, model_id):
|
||||||
instance = get_object_or_404(model, pk=model_id)
|
instance = get_object_or_404(model, pk=model_id)
|
||||||
legislation = instance.legislativetext_set.all()
|
|
||||||
legislation = [legislation_to_html(i) for i in legislation]
|
|
||||||
return render(request, "explorer/results.html", {
|
return render(request, "explorer/results.html", {
|
||||||
"result_name": "All legislation by {}".format(instance.name),
|
"result_name": "All legislation by {}".format(instance.name),
|
||||||
"legislation": legislation
|
"legislation": instance.legislativetext_set.all()
|
||||||
})
|
})
|
||||||
|
|
||||||
return wrapped
|
return wrapped
|
||||||
|
@ -152,28 +144,24 @@ def handle_search(request):
|
||||||
sponsor_results = f(sponsors__name__icontains=query)
|
sponsor_results = f(sponsors__name__icontains=query)
|
||||||
country_results = f(country__name__icontains=query)
|
country_results = f(country__name__icontains=query)
|
||||||
|
|
||||||
results = text_results.union(
|
|
||||||
|
return render(request, "explorer/results.html", {
|
||||||
|
"result_name": "Results for search term '{}'".format(query),
|
||||||
|
"legislation": text_results.union(
|
||||||
title_results,
|
title_results,
|
||||||
school_results,
|
school_results,
|
||||||
sponsor_results,
|
sponsor_results,
|
||||||
country_results
|
country_results
|
||||||
)
|
)
|
||||||
results = [legislation_to_html(i) for i in results]
|
|
||||||
|
|
||||||
return render(request, "explorer/results.html", {
|
|
||||||
"result_name": "Results for search term '{}'".format(query),
|
|
||||||
"legislation": results
|
|
||||||
})
|
})
|
||||||
|
|
||||||
get_all_by_school = get_all_by_x(School)
|
get_all_by_school = get_all_by_x(School)
|
||||||
get_all_by_country = get_all_by_x(Country)
|
get_all_by_country = get_all_by_x(Country)
|
||||||
get_all_by_sponsor = get_all_by_x(Sponsor)
|
get_all_by_sponsor = get_all_by_x(Sponsor)
|
||||||
get_all_by_category = get_all_by_x(Category)
|
get_all_by_category = get_all_by_x(Category)
|
||||||
get_all_by_conference = get_all_by_x(LegislationBook)
|
|
||||||
|
|
||||||
get_all_schools = get_all_xs(School)
|
get_all_schools = get_all_xs(School)
|
||||||
get_all_countries = get_all_xs(Country)
|
get_all_countries = get_all_xs(Country)
|
||||||
get_all_sponsors = get_all_xs(Sponsor)
|
get_all_sponsors = get_all_xs(Sponsor)
|
||||||
get_all_categories = get_all_xs(Category)
|
get_all_categories = get_all_xs(Category)
|
||||||
get_all_classifications = get_all_xs(LegislationClassification)
|
get_all_classifications = get_all_xs(LegislationClassification)
|
||||||
get_all_conferences = get_all_xs(LegislationBook)
|
|
Loading…
Reference in New Issue