Compare commits

..

No commits in common. "2a6e42da9c5264ecefdba1cceb1093dbd8482903" and "4931c8ac94c8a5e3f050731d3691bcd220ef776c" have entirely different histories.

18 changed files with 218 additions and 41 deletions

Binary file not shown.

Binary file not shown.

View File

@ -14,7 +14,6 @@ to_register = [
[models.LegislationClassification], [models.LegislationClassification],
[models.School], [models.School],
[models.Country], [models.Country],
[models.Sponsor],
] ]
for i in to_register: for i in to_register:
admin.site.register(*i) admin.site.register(*i)

View File

@ -0,0 +1,39 @@
# Generated by Django 4.2.12 on 2024-06-19 06:53
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
initial = True
dependencies = [
]
operations = [
migrations.CreateModel(
name='LegislationBook',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('conference_type', models.CharField(choices=[('M', 'Middle School'), ('H', 'High School')], default='H', max_length=1)),
('pdf', models.FileField(upload_to='uploads/')),
('name', models.CharField(max_length=256)),
('import_strategy', models.CharField(max_length=128)),
],
),
migrations.CreateModel(
name='LegislativeText',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('assembly', models.CharField(choices=[('RGA', 'Red General Assembly'), ('BGA', 'Blue General Assembly'), ('WGA', 'White General Assembly'), ('RHB', 'Red House'), ('BHB', 'Blue House'), ('WHB', 'White House'), ('RSB', 'Red Senate'), ('BSB', 'Blue Senate'), ('WSB', 'White Senate'), ('SEN', 'Senate'), ('HOU', 'House'), ('GEN', 'General Assembly')], default='GEN', max_length=3)),
('text', models.TextField()),
('year', models.IntegerField()),
('committee', models.IntegerField()),
('docket_order', models.IntegerField()),
('school', models.CharField(max_length=256)),
('sponsors', models.CharField(max_length=256)),
('from_book', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='explorer.legislationbook')),
],
),
]

View File

@ -0,0 +1,19 @@
# Generated by Django 4.2.12 on 2024-06-19 07:22
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('explorer', '0001_initial'),
]
operations = [
migrations.AddField(
model_name='legislativetext',
name='legislation_title',
field=models.CharField(default='Sample title', max_length=512),
preserve_default=False,
),
]

View File

@ -0,0 +1,23 @@
# Generated by Django 4.2.12 on 2024-06-19 17:36
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('explorer', '0002_legislativetext_legislation_title'),
]
operations = [
migrations.AddField(
model_name='legislationbook',
name='has_performed_export',
field=models.BooleanField(default=False),
),
migrations.AlterField(
model_name='legislationbook',
name='import_strategy',
field=models.CharField(choices=[('HSYIGBookParser', 'High School YIG Book Parser 1'), ('HSMUNBookParser', 'High School MUN Book Parser 1')], default='HSYIGBookParser', max_length=128),
),
]

View File

@ -0,0 +1,21 @@
# Generated by Django 4.2.12 on 2024-06-28 20:53
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('explorer', '0003_legislationbook_has_performed_export_and_more'),
]
operations = [
migrations.CreateModel(
name='LegislationClassification',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('name', models.CharField(help_text='Name of this classification.', max_length=256)),
('text_to_match', models.CharField(help_text='a comma seperated list of keywords to include in the classification. spaces and dashes are discluded.', max_length=256)),
],
),
]

View File

@ -0,0 +1,19 @@
# Generated by Django 4.2.12 on 2024-06-28 21:07
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('explorer', '0004_legislationclassification'),
]
operations = [
migrations.AddField(
model_name='legislationclassification',
name='obvious_change',
field=models.CharField(default='test', help_text='Name of this classification.', max_length=256),
preserve_default=False,
),
]

View File

@ -0,0 +1,17 @@
# Generated by Django 4.2.12 on 2024-06-28 21:08
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
('explorer', '0005_legislationclassification_obvious_change'),
]
operations = [
migrations.RemoveField(
model_name='legislationclassification',
name='obvious_change',
),
]

View File

@ -0,0 +1,24 @@
# Generated by Django 4.2.12 on 2024-06-30 03:14
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('explorer', '0006_remove_legislationclassification_obvious_change'),
]
operations = [
migrations.AddField(
model_name='legislativetext',
name='category',
field=models.CharField(default='', max_length=256),
preserve_default=False,
),
migrations.AddField(
model_name='legislativetext',
name='country',
field=models.CharField(blank=True, max_length=512, null=True),
),
]

View File

@ -0,0 +1,26 @@
# Generated by Django 4.2.12 on 2024-06-30 03:57
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
dependencies = [
('explorer', '0007_legislativetext_category_legislativetext_country'),
]
operations = [
migrations.CreateModel(
name='School',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('name', models.CharField(max_length=256)),
],
),
migrations.AlterField(
model_name='legislativetext',
name='school',
field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, to='explorer.school'),
),
]

View File

@ -0,0 +1,26 @@
# Generated by Django 4.2.12 on 2024-06-30 04:26
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
dependencies = [
('explorer', '0008_school_alter_legislativetext_school'),
]
operations = [
migrations.CreateModel(
name='Country',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('name', models.CharField(max_length=256)),
],
),
migrations.AlterField(
model_name='legislativetext',
name='country',
field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.CASCADE, to='explorer.country'),
),
]

View File

@ -44,16 +44,6 @@ class Country(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})
class Sponsor(models.Model):
name = models.CharField(max_length=256)
def __str__(self):
return self.name
def get_absolute_url(self):
our_name = __class__.__name__
return reverse("{}.detail".format(our_name), kwargs={"model_id": self.id})
class LegislationBook(models.Model): class LegislationBook(models.Model):
class Meta: class Meta:
verbose_name = "Book" verbose_name = "Book"
@ -104,18 +94,9 @@ class LegislationBook(models.Model):
# handle that gracefully # handle that gracefully
text["country"] = text["country"].replace(" 2", "") text["country"] = text["country"].replace(" 2", "")
text["country"] = InstantiateIfNone(Country, text["country"]) text["country"] = InstantiateIfNone(Country, text["country"])
sponsors = text["sponsors"].split(', ')
sponsors = [InstantiateIfNone(Sponsor, sponsor) for sponsor in sponsors]
del text["sponsors"]
text = LegislativeText(**text, from_book=self) text = LegislativeText(**text, from_book=self)
text.save() text.save()
for sponsor in sponsors:
text.sponsors.add(sponsor)
def __str__(self): def __str__(self):
return "{}".format(self.name) return "{}".format(self.name)
@ -149,7 +130,7 @@ class LegislativeText(models.Model):
category = models.CharField(max_length=256) category = models.CharField(max_length=256)
docket_order = models.IntegerField() docket_order = models.IntegerField()
school = models.ForeignKey(School, on_delete=models.CASCADE) school = models.ForeignKey(School, on_delete=models.CASCADE)
sponsors = models.ManyToManyField(Sponsor, blank=True) sponsors = models.CharField(max_length=256)
from_book = models.ForeignKey(LegislationBook, on_delete=models.CASCADE) from_book = models.ForeignKey(LegislationBook, on_delete=models.CASCADE)
legislation_title = models.CharField(max_length=512) legislation_title = models.CharField(max_length=512)
country = models.ForeignKey(Country, on_delete=models.CASCADE, null=True) country = models.ForeignKey(Country, on_delete=models.CASCADE, null=True)

View File

@ -10,7 +10,6 @@
<li><a href="/explorer/countries/">By country</a></li> <li><a href="/explorer/countries/">By country</a></li>
<li><a href="/explorer/schools/">By school</a></li> <li><a href="/explorer/schools/">By school</a></li>
<li><a href="/explorer/topics/">By topic</a></li> <li><a href="/explorer/topics/">By topic</a></li>
<li><a href="/explorer/sponsors/">By sponsor</a></li>
</ul> </ul>
</div> </div>
{% endblock content %} {% endblock content %}

View File

@ -13,12 +13,7 @@
<p><i>{{ legislation.assembly }}/{{ legislation.committee }}/{{ legislation.docket_order }}</i></p> <p><i>{{ legislation.assembly }}/{{ legislation.committee }}/{{ legislation.docket_order }}</i></p>
<p>Sponsored by <p>Sponsored by {{ legislation.sponsors }} of <a href="/explorer/schools/{{ legislation.school.id }}">{{ legislation.school }}</a></p>
{% for sponsor in legislation.sponsors.all %}
<a href="/explorer/sponsors/{{ sponsor.id }}">{{ sponsor.name }}</a>{% if not forloop.last %}, {% endif %}
{% endfor %}
of <a href="/explorer/schools/{{ legislation.school.id }}">{{ legislation.school }}</a></p>
{% if legislation.country %} {% if legislation.country %}
<p>The delegates above represented the <a href="/explorer/countries/{{ legislation.country.id }}">Delegation of {{ legislation.country }}</a>.</p> <p>The delegates above represented the <a href="/explorer/countries/{{ legislation.country.id }}">Delegation of {{ legislation.country }}</a>.</p>

View File

@ -14,9 +14,7 @@ urlpatterns = [
# these are named weirdly -- see models.py School and Country definitions # these are named weirdly -- see models.py School and Country definitions
path("schools/<int:model_id>/", views.get_all_by_school, name="School.detail"), path("schools/<int:model_id>/", views.get_all_by_school, name="School.detail"),
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("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="Sponsors")
] ]

View File

@ -1,14 +1,7 @@
from django.shortcuts import get_object_or_404, render from django.shortcuts import get_object_or_404, render
from django.http import HttpResponse from django.http import HttpResponse
from .models import ( from .models import LegislativeText, LegislationBook, LegislationClassification, School, Country
LegislativeText,
LegislationBook,
LegislationClassification,
School,
Country,
Sponsor
)
from random import sample from random import sample
@ -119,9 +112,7 @@ def return_groups(request):
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_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_classifications = get_all_xs(LegislationClassification) get_all_classifications = get_all_xs(LegislationClassification)