diff --git a/.gitignore b/.gitignore index dd54617..28c5001 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,4 @@ __pycache__ db.sqlite3 media +uploads/ diff --git a/franklincce/explorer/admin.py b/franklincce/explorer/admin.py index 8c38f3f..2462c9e 100644 --- a/franklincce/explorer/admin.py +++ b/franklincce/explorer/admin.py @@ -1,3 +1,6 @@ from django.contrib import admin -# Register your models here. +from .models import LegislativeText, LegislationBook + +admin.site.register(LegislativeText) +admin.site.register(LegislationBook) diff --git a/franklincce/explorer/migrations/0001_initial.py b/franklincce/explorer/migrations/0001_initial.py new file mode 100644 index 0000000..40722dc --- /dev/null +++ b/franklincce/explorer/migrations/0001_initial.py @@ -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')), + ], + ), + ] diff --git a/franklincce/explorer/migrations/0002_legislativetext_legislation_title.py b/franklincce/explorer/migrations/0002_legislativetext_legislation_title.py new file mode 100644 index 0000000..27ad0bc --- /dev/null +++ b/franklincce/explorer/migrations/0002_legislativetext_legislation_title.py @@ -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, + ), + ] diff --git a/franklincce/explorer/models.py b/franklincce/explorer/models.py index 71a8362..e8e30c5 100644 --- a/franklincce/explorer/models.py +++ b/franklincce/explorer/models.py @@ -1,3 +1,55 @@ from django.db import models +from django.utils.translation import gettext_lazy as _ -# Create your models here. +class LegislationBook(models.Model): + class ConferenceType(models.TextChoices): + MIDDLE = "M", _("Middle School") + HIGH = "H", _("High School") + + conference_type = models.CharField( + max_length=1, + choices=ConferenceType.choices, + default=ConferenceType.HIGH, + ) + pdf = models.FileField(upload_to="uploads/") + name = models.CharField(max_length=256) + import_strategy = models.CharField(max_length=128) + + def __str__(self): + return "{}".format(self.name) + +class LegislativeText(models.Model): + class Assemblies(models.TextChoices): + RGA = "RGA", _("Red General Assembly") + BGA = "BGA", _("Blue General Assembly") + WGA = "WGA", _("White General Assembly") + RHB = "RHB", _("Red House") + BHB = "BHB", _("Blue House") + WHB = "WHB", _("White House") + RSB = "RSB", _("Red Senate") + BSB = "BSB", _("Blue Senate") + WSB = "WSB", _("White Senate") + SEN = "SEN", _("Senate") + HOU = "HOU", _("House") + GEN = "GEN", _("General Assembly") + + assembly = models.CharField( + max_length=3, + choices=Assemblies.choices, + default=Assemblies.GEN + ) + 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(LegislationBook, on_delete=models.CASCADE) + legislation_title = models.CharField(max_length=512) + + def __str__(self): + return "{}/{}-{}".format( + self.assembly, + self.committee, + self.docket_order, + ) diff --git a/franklincce/explorer/templates/explorer/import.html b/franklincce/explorer/templates/explorer/import.html new file mode 100644 index 0000000..8d32763 --- /dev/null +++ b/franklincce/explorer/templates/explorer/import.html @@ -0,0 +1,10 @@ +
+ +{% if just_imported %} +thanks for the import! +{% endif %} diff --git a/franklincce/explorer/templates/explorer/index.html b/franklincce/explorer/templates/explorer/index.html new file mode 100644 index 0000000..8c8a495 --- /dev/null +++ b/franklincce/explorer/templates/explorer/index.html @@ -0,0 +1,9 @@ +{% if legislative_texts %} +No texts available
+{% endif %} diff --git a/franklincce/explorer/templates/explorer/legislation.html b/franklincce/explorer/templates/explorer/legislation.html new file mode 100644 index 0000000..a5bb810 --- /dev/null +++ b/franklincce/explorer/templates/explorer/legislation.html @@ -0,0 +1,9 @@ +Sponsored by {{ legislation.sponsors }} of {{ legislation.school }}
+ ++ {{ legislation.text }} +diff --git a/franklincce/explorer/urls.py b/franklincce/explorer/urls.py new file mode 100644 index 0000000..3487de4 --- /dev/null +++ b/franklincce/explorer/urls.py @@ -0,0 +1,9 @@ +from django.urls import path + +from . import views + +urlpatterns = [ + path("", views.index, name="index"), + path("legislation/