make topics a part of the system we've made
This commit is contained in:
parent
bfbea9e855
commit
281473262a
|
@ -168,8 +168,8 @@ class LegislativeText(models.Model):
|
|||
|
||||
class LegislationClassification(models.Model):
|
||||
class Meta:
|
||||
verbose_name = "Classification"
|
||||
verbose_name_plural = "Classifications"
|
||||
verbose_name = "Topic"
|
||||
verbose_name_plural = "Topics"
|
||||
|
||||
name = models.CharField(max_length=256, help_text="Name of this classification.")
|
||||
text_to_match = models.CharField(
|
||||
|
@ -179,3 +179,7 @@ class LegislationClassification(models.Model):
|
|||
|
||||
def __str__(self):
|
||||
return "{}".format(self.name)
|
||||
|
||||
def get_absolute_url(self):
|
||||
our_name = __class__.__name__
|
||||
return reverse("{}.detail".format(our_name), kwargs={"model_id": self.id})
|
|
@ -9,6 +9,7 @@
|
|||
<ul>
|
||||
<li><a href="/explorer/countries/">By country</a></li>
|
||||
<li><a href="/explorer/schools/">By school</a></li>
|
||||
<li><a href="/explorer/topics/">By topic</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
{% endblock content %}
|
|
@ -8,8 +8,8 @@ urlpatterns = [
|
|||
path("stats/", views.stats, name="stats"),
|
||||
path("legislation/<int:legislation_id>/", views.view_legislation, name="viewleg"),
|
||||
path("conference/<int:conference_id>/", views.view_conference, name="viewconf"),
|
||||
path("topics/<int:classification_id>/", views.get_all_classified_by_id, name="classificationview"),
|
||||
path("topics/", views.get_all_classifications, name="classificationsview"),
|
||||
path("topics/<int:model_id>/", views.get_all_classified_by_id, name="LegislationClassification.detail"),
|
||||
path("topics/", views.get_all_classifications, name="LegislationClassification"),
|
||||
|
||||
# these are named weirdly -- see models.py School and Country definitions
|
||||
path("schools/<int:model_id>/", views.get_all_by_school, name="School.detail"),
|
||||
|
|
|
@ -54,14 +54,8 @@ def stats(request):
|
|||
}
|
||||
return render(request, "explorer/stats.html", context)
|
||||
|
||||
def get_all_classifications(request):
|
||||
classifications = LegislationClassification.objects.all()
|
||||
return render(request, "explorer/classifications.html", {
|
||||
"classifications": classifications,
|
||||
})
|
||||
|
||||
def get_all_classified_by_id(request, classification_id):
|
||||
classification = get_object_or_404(LegislationClassification, pk=classification_id)
|
||||
def get_all_classified_by_id(request, model_id):
|
||||
classification = get_object_or_404(LegislationClassification, pk=model_id)
|
||||
# this is very expensive; make a way for this to be cached please?
|
||||
|
||||
all_texts = LegislativeText.objects.all()
|
||||
|
@ -116,4 +110,5 @@ get_all_by_school = get_all_by_x(School)
|
|||
get_all_by_country = get_all_by_x(Country)
|
||||
|
||||
get_all_schools = get_all_xs(School)
|
||||
get_all_countries = get_all_xs(Country)
|
||||
get_all_countries = get_all_xs(Country)
|
||||
get_all_classifications = get_all_xs(LegislationClassification)
|
Loading…
Reference in New Issue