From e50c1478be658a8093e85663151d0c79e1bed3ad Mon Sep 17 00:00:00 2001 From: Daniel Gray Date: Tue, 11 Jun 2024 10:35:09 +0200 Subject: [PATCH 1/2] added description input to documentfile and project - updated tests --- .../0008_documentfile_description_and_more.py | 39 +++++++++++++++++++ app/general/models.py | 2 + app/general/tests/test_document_admin_file.py | 4 ++ 3 files changed, 45 insertions(+) create mode 100644 app/general/migrations/0008_documentfile_description_and_more.py diff --git a/app/general/migrations/0008_documentfile_description_and_more.py b/app/general/migrations/0008_documentfile_description_and_more.py new file mode 100644 index 00000000..b6aa2fd4 --- /dev/null +++ b/app/general/migrations/0008_documentfile_description_and_more.py @@ -0,0 +1,39 @@ +# Generated by Django 5.0.2 on 2024-06-11 08:21 + +import django.db.models.deletion +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('general', '0007_alter_documentfile_options_and_more'), + ] + + operations = [ + migrations.AddField( + model_name='documentfile', + name='description', + field=models.TextField(blank=True, verbose_name='description'), + ), + migrations.AddField( + model_name='historicaldocumentfile', + name='description', + field=models.TextField(blank=True, verbose_name='description'), + ), + migrations.AddField( + model_name='historicalproject', + name='description', + field=models.TextField(blank=True, verbose_name='description'), + ), + migrations.AddField( + model_name='project', + name='description', + field=models.TextField(blank=True, verbose_name='description'), + ), + migrations.AlterField( + model_name='project', + name='institution', + field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='general.institution', verbose_name='institution'), + ), + ] diff --git a/app/general/models.py b/app/general/models.py index 010221bc..e2d23cdf 100644 --- a/app/general/models.py +++ b/app/general/models.py @@ -6,6 +6,7 @@ class Project(models.Model): name = models.CharField(max_length=200, verbose_name=_("name")) + description = models.TextField(blank=True, verbose_name=_("description")) url = models.URLField(max_length=200, blank=True, verbose_name=_("URL")) logo = models.ImageField(upload_to="projects/logos/", blank=True, verbose_name=_("logo")) start_date = models.DateField(blank=True, null=True, verbose_name=_("start date")) @@ -106,6 +107,7 @@ class DocumentFile(models.Model): file_type = "pdf" title = models.CharField(max_length=200, verbose_name=_("title")) + description = models.TextField(blank=True, verbose_name=_("description")) url = models.URLField(max_length=200, blank=True, verbose_name=_("URL")) uploaded_file = models.FileField( upload_to="documents/", diff --git a/app/general/tests/test_document_admin_file.py b/app/general/tests/test_document_admin_file.py index bd8cf6d8..76c8a5c8 100644 --- a/app/general/tests/test_document_admin_file.py +++ b/app/general/tests/test_document_admin_file.py @@ -30,6 +30,7 @@ def test_clean_without_url_and_file(self): "institution": Institution.objects.create(name="Test Institution"), "url": "", "uploaded_file": "", + "description": "Test description", } form = DocumentFileForm(tests_form) @@ -49,6 +50,7 @@ def test_clean_without_file(self): "url": "www.example.com", "uploaded_file": "", "document_data": "", + "description": "", } form = DocumentFileForm(tests_form) @@ -65,6 +67,7 @@ def test_clean_without_url(self): "url": "", "uploaded_file": self.file_mock, "document_data": "", + "description": "Test description", } form = DocumentFileForm(tests_form, files={"uploaded_file": self.file_mock}) @@ -81,6 +84,7 @@ def test_clean_with_large_file(self): "institution": Institution.objects.create(name="Test Institution 4"), "url": "", "uploaded_file": self.file_mock, + "description": "Test description", } form = DocumentFileForm(tests_form, files={"uploaded_file": self.file_mock}) From 9063aa39138d5249e85dca5a6ca7218c5ca4aefc Mon Sep 17 00:00:00 2001 From: Daniel Gray Date: Tue, 11 Jun 2024 15:01:42 +0200 Subject: [PATCH 2/2] fixed projects institution validation --- app/general/models.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/general/models.py b/app/general/models.py index e2d23cdf..0192530e 100644 --- a/app/general/models.py +++ b/app/general/models.py @@ -12,7 +12,7 @@ class Project(models.Model): start_date = models.DateField(blank=True, null=True, verbose_name=_("start date")) end_date = models.DateField(blank=True, null=True, verbose_name=_("end date")) institution = models.ForeignKey( - "Institution", on_delete=models.CASCADE, blank=True, verbose_name=_("institution") + "Institution", on_delete=models.CASCADE, blank=False, verbose_name=_("institution") ) subjects = models.ManyToManyField("Subject", blank=True, verbose_name=_("subjects")) languages = models.ManyToManyField("Language", blank=True, verbose_name=_("languages"))