diff --git a/franklincce/explorer/admin.py b/franklincce/explorer/admin.py index 3e404c0..0c86b04 100644 --- a/franklincce/explorer/admin.py +++ b/franklincce/explorer/admin.py @@ -1,6 +1,6 @@ from django.contrib import admin -from .models import LegislativeText, LegislationBook +from explorer import models class LegislativeTextAdmin(admin.ModelAdmin): list_display = ('__str__', 'legislation_title', 'school') @@ -8,5 +8,11 @@ class LegislativeTextAdmin(admin.ModelAdmin): class LegislationBookAdmin(admin.ModelAdmin): exclude = ("has_performed_export",) -admin.site.register(LegislativeText, LegislativeTextAdmin) -admin.site.register(LegislationBook, LegislationBookAdmin) +to_register = [ + [models.LegislativeText, LegislativeTextAdmin], + [models.LegislationBook, LegislationBookAdmin], + [models.LegislationClassification] +] +for i in to_register: + admin.site.register(*i) + print(i) diff --git a/franklincce/explorer/migrations/0004_legislationclassification.py b/franklincce/explorer/migrations/0004_legislationclassification.py new file mode 100644 index 0000000..acd0d38 --- /dev/null +++ b/franklincce/explorer/migrations/0004_legislationclassification.py @@ -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)), + ], + ), + ] diff --git a/franklincce/explorer/migrations/0005_legislationclassification_obvious_change.py b/franklincce/explorer/migrations/0005_legislationclassification_obvious_change.py new file mode 100644 index 0000000..208a48c --- /dev/null +++ b/franklincce/explorer/migrations/0005_legislationclassification_obvious_change.py @@ -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, + ), + ] diff --git a/franklincce/explorer/migrations/0006_remove_legislationclassification_obvious_change.py b/franklincce/explorer/migrations/0006_remove_legislationclassification_obvious_change.py new file mode 100644 index 0000000..33b97cb --- /dev/null +++ b/franklincce/explorer/migrations/0006_remove_legislationclassification_obvious_change.py @@ -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', + ), + ] diff --git a/franklincce/explorer/models.py b/franklincce/explorer/models.py index 1357bb6..cd312ed 100644 --- a/franklincce/explorer/models.py +++ b/franklincce/explorer/models.py @@ -31,8 +31,6 @@ class LegislationBook(models.Model): has_performed_export = models.BooleanField(default=False) def save(self, **kwargs): - super().save(**kwargs) - if not self.has_performed_export: self.has_performed_export = True super().save(**kwargs) @@ -136,3 +134,13 @@ class LegislativeText(models.Model): if self.assembly in ["RGA", "BGA", "WGA", "GEN"]: return True return False + +class LegislationClassification(models.Model): + name = models.CharField(max_length=256, help_text="Name of this classification.") + text_to_match = models.CharField( + max_length=256, + help_text="a comma seperated list of keywords to include in the classification. spaces and dashes are discluded." + ) + + def __str__(self): + return "{}".format(self.name) diff --git a/franklincce/explorer/templates/explorer/classifications.html b/franklincce/explorer/templates/explorer/classifications.html new file mode 100644 index 0000000..96ddf1c --- /dev/null +++ b/franklincce/explorer/templates/explorer/classifications.html @@ -0,0 +1,15 @@ +{% extends "explorer/base.html" %} + +{% block content %} + + +