implemented database following the DCM
This commit is contained in:
parent
4af6af5c99
commit
82a862a142
13 changed files with 161 additions and 10 deletions
3
.gitignore
vendored
3
.gitignore
vendored
|
@ -1,2 +1,3 @@
|
|||
.idea/
|
||||
Palto/db.sqlite3
|
||||
venv/
|
||||
db.sqlite3
|
||||
|
|
|
@ -16,8 +16,5 @@ RUN pip install -r requirements.txt
|
|||
# Expose the port on which your Django application will run
|
||||
EXPOSE 80
|
||||
|
||||
# Set the working directory in the Django application
|
||||
WORKDIR ./Palto
|
||||
|
||||
# Start the Django application
|
||||
ENTRYPOINT ["python", "manage.py", "runserver_plus", "0.0.0.0:80"]
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
from django.apps import AppConfig
|
||||
|
||||
|
||||
class UserConfig(AppConfig):
|
||||
class PaltoConfig(AppConfig):
|
||||
default_auto_field = 'django.db.models.BigAutoField'
|
||||
name = "User"
|
||||
name = "Palto.Palto"
|
||||
label = "Palto"
|
83
Palto/Palto/migrations/0001_initial.py
Normal file
83
Palto/Palto/migrations/0001_initial.py
Normal file
|
@ -0,0 +1,83 @@
|
|||
# Generated by Django 4.2.7 on 2023-11-27 10:56
|
||||
|
||||
from django.conf import settings
|
||||
from django.db import migrations, models
|
||||
import django.db.models.deletion
|
||||
import uuid
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
initial = True
|
||||
|
||||
dependencies = [
|
||||
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.CreateModel(
|
||||
name='Absence',
|
||||
fields=[
|
||||
('id', models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False)),
|
||||
('message', models.TextField()),
|
||||
('student', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='absent_sessions', to=settings.AUTH_USER_MODEL)),
|
||||
],
|
||||
),
|
||||
migrations.CreateModel(
|
||||
name='TeachingUnit',
|
||||
fields=[
|
||||
('id', models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False)),
|
||||
('name', models.CharField(max_length=32)),
|
||||
('managers', models.ManyToManyField(related_name='managed_teaching_units', to=settings.AUTH_USER_MODEL)),
|
||||
],
|
||||
),
|
||||
migrations.CreateModel(
|
||||
name='TeachingSession',
|
||||
fields=[
|
||||
('id', models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False)),
|
||||
('start', models.DateTimeField()),
|
||||
('duration', models.DurationField()),
|
||||
('teacher', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='taught_sessions', to=settings.AUTH_USER_MODEL)),
|
||||
],
|
||||
),
|
||||
migrations.CreateModel(
|
||||
name='StudentGroup',
|
||||
fields=[
|
||||
('id', models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False)),
|
||||
('name', models.CharField(max_length=32)),
|
||||
('students', models.ManyToManyField(related_name='student_groups', to=settings.AUTH_USER_MODEL)),
|
||||
],
|
||||
),
|
||||
migrations.CreateModel(
|
||||
name='StudentCard',
|
||||
fields=[
|
||||
('id', models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False)),
|
||||
('uid', models.BinaryField(max_length=7)),
|
||||
('owner', models.ManyToManyField(related_name='student_cards', to=settings.AUTH_USER_MODEL)),
|
||||
],
|
||||
),
|
||||
migrations.CreateModel(
|
||||
name='Department',
|
||||
fields=[
|
||||
('id', models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False)),
|
||||
('name', models.CharField(max_length=32)),
|
||||
('managers', models.ManyToManyField(related_name='managed_departments', to=settings.AUTH_USER_MODEL)),
|
||||
],
|
||||
),
|
||||
migrations.CreateModel(
|
||||
name='Attendance',
|
||||
fields=[
|
||||
('id', models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False)),
|
||||
('date', models.DateTimeField()),
|
||||
('student', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='attended_sessions', to=settings.AUTH_USER_MODEL)),
|
||||
],
|
||||
),
|
||||
migrations.CreateModel(
|
||||
name='AbsenceAttachment',
|
||||
fields=[
|
||||
('id', models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False)),
|
||||
('content', models.FileField(upload_to='')),
|
||||
('absence', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='attachments', to='Palto.absence')),
|
||||
],
|
||||
),
|
||||
]
|
69
Palto/Palto/models.py
Normal file
69
Palto/Palto/models.py
Normal file
|
@ -0,0 +1,69 @@
|
|||
import uuid
|
||||
from datetime import datetime, timedelta
|
||||
|
||||
from django.contrib.auth import get_user_model
|
||||
from django.db import models
|
||||
|
||||
|
||||
# Create your models here.
|
||||
class Department(models.Model):
|
||||
id: uuid.UUID = models.UUIDField(default=uuid.uuid4, primary_key=True, editable=False, max_length=36)
|
||||
name: str = models.CharField(max_length=32)
|
||||
|
||||
managers = models.ManyToManyField(to=get_user_model(), related_name="managed_departments")
|
||||
teachers = models.ManyToManyField(to=get_user_model(), related_name="taught_departments")
|
||||
students = models.ManyToManyField(to=get_user_model(), related_name="study_departments")
|
||||
|
||||
|
||||
class StudentGroup(models.Model):
|
||||
id: uuid.UUID = models.UUIDField(default=uuid.uuid4, primary_key=True, editable=False, max_length=36)
|
||||
name: str = models.CharField(max_length=32)
|
||||
|
||||
students = models.ManyToManyField(to=get_user_model(), related_name="student_groups")
|
||||
|
||||
|
||||
class TeachingUnit(models.Model):
|
||||
id: uuid.UUID = models.UUIDField(default=uuid.uuid4, primary_key=True, editable=False, max_length=36)
|
||||
name: str = models.CharField(max_length=32)
|
||||
|
||||
student_groups = models.ManyToManyField(to=StudentGroup, related_name="taught_units")
|
||||
|
||||
|
||||
class StudentCard(models.Model):
|
||||
id: uuid.UUID = models.UUIDField(default=uuid.uuid4, primary_key=True, editable=False, max_length=36)
|
||||
uid: bytes = models.BinaryField(max_length=7)
|
||||
|
||||
owner = models.ManyToManyField(to=get_user_model(), related_name="student_cards")
|
||||
|
||||
|
||||
class TeachingSession(models.Model):
|
||||
id: uuid.UUID = models.UUIDField(default=uuid.uuid4, primary_key=True, editable=False, max_length=36)
|
||||
start: datetime = models.DateTimeField()
|
||||
duration: timedelta = models.DurationField()
|
||||
|
||||
teacher = models.ForeignKey(to=get_user_model(), on_delete=models.CASCADE, related_name="taught_sessions")
|
||||
|
||||
@property
|
||||
def end(self) -> datetime:
|
||||
return self.start + self.duration
|
||||
|
||||
|
||||
class Attendance(models.Model):
|
||||
id: uuid.UUID = models.UUIDField(default=uuid.uuid4, primary_key=True, editable=False, max_length=36)
|
||||
date: datetime = models.DateTimeField()
|
||||
|
||||
student = models.ForeignKey(to=get_user_model(), on_delete=models.CASCADE, related_name="attended_sessions")
|
||||
|
||||
|
||||
class Absence(models.Model):
|
||||
id: uuid.UUID = models.UUIDField(default=uuid.uuid4, primary_key=True, editable=False, max_length=36)
|
||||
message: str = models.TextField()
|
||||
|
||||
student = models.ForeignKey(to=get_user_model(), on_delete=models.CASCADE, related_name="absent_sessions")
|
||||
|
||||
|
||||
class AbsenceAttachment(models.Model):
|
||||
id: uuid.UUID = models.UUIDField(default=uuid.uuid4, primary_key=True, editable=False, max_length=36)
|
||||
content = models.FileField()
|
||||
|
||||
absence = models.ForeignKey(to=Absence, on_delete=models.CASCADE, related_name="attachments")
|
|
@ -1,3 +0,0 @@
|
|||
from django.db import models
|
||||
|
||||
# Create your models here.
|
|
@ -51,7 +51,7 @@ INSTALLED_APPS = [
|
|||
"debug_toolbar",
|
||||
'django_extensions',
|
||||
|
||||
"Palto.apps.User.apps",
|
||||
"Palto.Palto",
|
||||
]
|
||||
|
||||
MIDDLEWARE = [
|
||||
|
@ -147,3 +147,6 @@ REST_FRAMEWORK = {
|
|||
'rest_framework.permissions.DjangoModelPermissionsOrAnonReadOnly'
|
||||
]
|
||||
}
|
||||
|
||||
# User
|
||||
AUTH_USER_MODEL = "Palto.models.User"
|
||||
|
|
Loading…
Reference in a new issue