From 65fc0cd9d3e04d9219133d3daad07705b43ca414 Mon Sep 17 00:00:00 2001 From: Daniel Gray Date: Mon, 8 Apr 2024 08:18:46 +0200 Subject: [PATCH] Updated Language in the models Updated schema changes Changed language to plural updated models and tests --- Makefile | 8 +++++++- app/general/migrations/0001_initial.py | 5 ++--- app/general/models.py | 1 + app/general/tests/tests_projects.py | 7 ++++++- app/users/migrations/0001_initial.py | 2 -- 5 files changed, 16 insertions(+), 7 deletions(-) diff --git a/Makefile b/Makefile index 62a57a83..06e52de3 100644 --- a/Makefile +++ b/Makefile @@ -14,7 +14,13 @@ list: @echo "create-super-user - Create a superuser" @echo "docker-stop-all - Stop all running containers" @echo "load-fixtures - Load fixtures" - + @echo "create-schema - Create a schema" + @echo "test - Run tests" + @echo "ruff-check - Run ruff check" + @echo "ruff-format - Run ruff format" + @echo "ruff-fix - Run ruff check --fix" + @echo "pre-commit-install - Install pre-commit" + @echo "dev-quick-install - Run all the necessary commands to start the project" up: clear diff --git a/app/general/migrations/0001_initial.py b/app/general/migrations/0001_initial.py index 66665c47..3facdcfc 100644 --- a/app/general/migrations/0001_initial.py +++ b/app/general/migrations/0001_initial.py @@ -1,5 +1,3 @@ -# Generated by Django 5.0.2 on 2024-04-03 09:12 - import django.db.models.deletion from django.db import migrations, models @@ -48,7 +46,8 @@ class Migration(migrations.Migration): ('start_date', models.DateField(blank=True, null=True)), ('end_date', models.DateField(blank=True, null=True)), ('institution', models.ForeignKey(blank=True, on_delete=django.db.models.deletion.CASCADE, to='general.institution', verbose_name='institution')), - ('subjects', models.ManyToManyField(to='general.subject', blank=True)), + ('languages', models.ManyToManyField(blank=True, to='general.language')), + ('subjects', models.ManyToManyField(blank=True, to='general.subject')), ], ), ] diff --git a/app/general/models.py b/app/general/models.py index fb5ccfa6..624dcda9 100644 --- a/app/general/models.py +++ b/app/general/models.py @@ -11,6 +11,7 @@ class Project(models.Model): "Institution", on_delete=models.CASCADE, blank=True, verbose_name="institution" ) subjects = models.ManyToManyField("Subject", blank=True) + languages = models.ManyToManyField("Language", blank=True) def __str__(self): return self.name diff --git a/app/general/tests/tests_projects.py b/app/general/tests/tests_projects.py index 3baf88bb..e593ed90 100644 --- a/app/general/tests/tests_projects.py +++ b/app/general/tests/tests_projects.py @@ -3,13 +3,14 @@ from django.test import TestCase -from general.models import Institution, Project, Subject +from general.models import Institution, Language, Project, Subject class TestProjects(TestCase): def setUp(self): self.institution = Institution.objects.create(name="Test Institution") self.subject = Subject.objects.create(name="Test Subject") + self.language = Language.objects.create(name="Test Language", iso_code="TL") self.project = Project.objects.create( name="Test Project", url="http://test.com", @@ -19,6 +20,7 @@ def setUp(self): institution=self.institution, ) self.project.subjects.add(self.subject) + self.project.languages.add(self.language) def test_project_creation(self): self.assertTrue(isinstance(self.project, Project)) @@ -53,6 +55,9 @@ def test_project_institution(self): def test_project_subject(self): self.assertTrue(self.project.subjects.filter(name="Test Subject").exists()) + def test_project_language(self): + self.assertTrue(self.project.languages.filter(name="Test Language").exists()) + def test_str(self): self.assertEqual(str(self.project), "Test Project") diff --git a/app/users/migrations/0001_initial.py b/app/users/migrations/0001_initial.py index 6d24d17c..4e27c840 100644 --- a/app/users/migrations/0001_initial.py +++ b/app/users/migrations/0001_initial.py @@ -1,5 +1,3 @@ -# Generated by Django 5.0.2 on 2024-03-19 08:51 - import django.contrib.auth.models import django.contrib.auth.validators import django.db.models.deletion