maint: squash migrations into one

This commit is contained in:
stupidcomputer 2024-07-23 23:51:37 -05:00
parent 4931c8ac94
commit 601ffd44c8
11 changed files with 20 additions and 215 deletions

View File

@ -1,39 +0,0 @@
# 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

@ -1,19 +0,0 @@
# 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

@ -1,23 +0,0 @@
# 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

@ -1,21 +0,0 @@
# 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

@ -1,19 +0,0 @@
# 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

@ -1,17 +0,0 @@
# 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

@ -1,24 +0,0 @@
# 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

@ -1,26 +0,0 @@
# 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

@ -1,26 +0,0 @@
# 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,6 +44,16 @@ class Country(models.Model):
our_name = __class__.__name__
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 Meta:
verbose_name = "Book"
@ -94,9 +104,18 @@ class LegislationBook(models.Model):
# handle that gracefully
text["country"] = text["country"].replace(" 2", "")
text["country"] = InstantiateIfNone(Country, text["country"])
sponsors = text["sponsors"].split(', ')
sponsors = [InstantiateIfNone(Sponsor, i) for i in sponsors]
del text["sponsors"]
text = LegislativeText(**text, from_book=self)
text.save()
for sponsor in sponsors:
text.upgraded_sponsors.add(sponsor)
def __str__(self):
return "{}".format(self.name)
@ -130,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.CharField(max_length=256)
sponsors = models.ManyToManyField(Sponsor)
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)