Skip to content

Commit

Permalink
Updated Language in the models
Browse files Browse the repository at this point in the history
Updated schema changes

Changed language to plural

updated models and tests
  • Loading branch information
daniel-gray-tangent committed Apr 9, 2024
1 parent 6d704e4 commit 65fc0cd
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 7 deletions.
8 changes: 7 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 2 additions & 3 deletions app/general/migrations/0001_initial.py
Original file line number Diff line number Diff line change
@@ -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

Expand Down Expand Up @@ -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')),
],
),
]
1 change: 1 addition & 0 deletions app/general/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 6 additions & 1 deletion app/general/tests/tests_projects.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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))
Expand Down Expand Up @@ -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")

Expand Down
2 changes: 0 additions & 2 deletions app/users/migrations/0001_initial.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down

0 comments on commit 65fc0cd

Please sign in to comment.