From 2a6e42da9c5264ecefdba1cceb1093dbd8482903 Mon Sep 17 00:00:00 2001 From: stupidcomputer Date: Wed, 24 Jul 2024 00:13:30 -0500 Subject: [PATCH] to squash --- franklincce/explorer/admin.py | 1 + franklincce/explorer/models.py | 6 +++--- franklincce/explorer/templates/explorer/by_group.html | 1 + .../explorer/templates/explorer/legislation.html | 7 ++++++- franklincce/explorer/urls.py | 4 +++- franklincce/explorer/views.py | 11 ++++++++++- 6 files changed, 24 insertions(+), 6 deletions(-) diff --git a/franklincce/explorer/admin.py b/franklincce/explorer/admin.py index 441718f..a034f2f 100644 --- a/franklincce/explorer/admin.py +++ b/franklincce/explorer/admin.py @@ -14,6 +14,7 @@ to_register = [ [models.LegislationClassification], [models.School], [models.Country], + [models.Sponsor], ] for i in to_register: admin.site.register(*i) \ No newline at end of file diff --git a/franklincce/explorer/models.py b/franklincce/explorer/models.py index 7423be2..6bdbfa5 100644 --- a/franklincce/explorer/models.py +++ b/franklincce/explorer/models.py @@ -106,7 +106,7 @@ class LegislationBook(models.Model): text["country"] = InstantiateIfNone(Country, text["country"]) sponsors = text["sponsors"].split(', ') - sponsors = [InstantiateIfNone(Sponsor, i) for i in sponsors] + sponsors = [InstantiateIfNone(Sponsor, sponsor) for sponsor in sponsors] del text["sponsors"] @@ -114,7 +114,7 @@ class LegislationBook(models.Model): text.save() for sponsor in sponsors: - text.upgraded_sponsors.add(sponsor) + text.sponsors.add(sponsor) def __str__(self): return "{}".format(self.name) @@ -149,7 +149,7 @@ class LegislativeText(models.Model): category = models.CharField(max_length=256) docket_order = models.IntegerField() school = models.ForeignKey(School, on_delete=models.CASCADE) - sponsors = models.ManyToManyField(Sponsor) + sponsors = models.ManyToManyField(Sponsor, blank=True) from_book = models.ForeignKey(LegislationBook, on_delete=models.CASCADE) legislation_title = models.CharField(max_length=512) country = models.ForeignKey(Country, on_delete=models.CASCADE, null=True) diff --git a/franklincce/explorer/templates/explorer/by_group.html b/franklincce/explorer/templates/explorer/by_group.html index d13530b..7a79121 100644 --- a/franklincce/explorer/templates/explorer/by_group.html +++ b/franklincce/explorer/templates/explorer/by_group.html @@ -10,6 +10,7 @@
  • By country
  • By school
  • By topic
  • +
  • By sponsor
  • {% endblock content %} \ No newline at end of file diff --git a/franklincce/explorer/templates/explorer/legislation.html b/franklincce/explorer/templates/explorer/legislation.html index 3be8e6f..dea6ba9 100644 --- a/franklincce/explorer/templates/explorer/legislation.html +++ b/franklincce/explorer/templates/explorer/legislation.html @@ -13,7 +13,12 @@

    {{ legislation.assembly }}/{{ legislation.committee }}/{{ legislation.docket_order }}

    -

    Sponsored by {{ legislation.sponsors }} of {{ legislation.school }}

    +

    Sponsored by + {% for sponsor in legislation.sponsors.all %} + {{ sponsor.name }}{% if not forloop.last %}, {% endif %} + {% endfor %} + + of {{ legislation.school }}

    {% if legislation.country %}

    The delegates above represented the Delegation of {{ legislation.country }}.

    diff --git a/franklincce/explorer/urls.py b/franklincce/explorer/urls.py index d4850fb..c334dba 100644 --- a/franklincce/explorer/urls.py +++ b/franklincce/explorer/urls.py @@ -14,7 +14,9 @@ urlpatterns = [ # these are named weirdly -- see models.py School and Country definitions path("schools//", views.get_all_by_school, name="School.detail"), path("countries//", views.get_all_by_country, name="Country.detail"), + path("sponsors//", views.get_all_by_sponsor, name="Sponsor.detail"), path("schools/", views.get_all_schools, name="School"), 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="Sponsors") ] diff --git a/franklincce/explorer/views.py b/franklincce/explorer/views.py index 58b3875..f468e39 100644 --- a/franklincce/explorer/views.py +++ b/franklincce/explorer/views.py @@ -1,7 +1,14 @@ from django.shortcuts import get_object_or_404, render from django.http import HttpResponse -from .models import LegislativeText, LegislationBook, LegislationClassification, School, Country +from .models import ( + LegislativeText, + LegislationBook, + LegislationClassification, + School, + Country, + Sponsor +) from random import sample @@ -112,7 +119,9 @@ def return_groups(request): get_all_by_school = get_all_by_x(School) get_all_by_country = get_all_by_x(Country) +get_all_by_sponsor = get_all_by_x(Sponsor) get_all_schools = get_all_xs(School) get_all_countries = get_all_xs(Country) +get_all_sponsors = get_all_xs(Sponsor) get_all_classifications = get_all_xs(LegislationClassification) \ No newline at end of file