Add basic model
This commit is contained in:
parent
0ac51bb9f6
commit
f8d00040f6
|
|
@ -0,0 +1,43 @@
|
||||||
|
# Generated by Django 3.2.13 on 2022-10-14 07:33
|
||||||
|
|
||||||
|
from django.conf import settings
|
||||||
|
from django.db import migrations, models
|
||||||
|
import django.db.models.deletion
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
|
||||||
|
('course', '0001_initial'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.CreateModel(
|
||||||
|
name='CourseSession',
|
||||||
|
fields=[
|
||||||
|
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||||
|
('created_at', models.DateTimeField(auto_now_add=True)),
|
||||||
|
('updated_at', models.DateTimeField(auto_now=True)),
|
||||||
|
('title', models.TextField()),
|
||||||
|
('start_date', models.DateField(blank=True, null=True)),
|
||||||
|
('end_date', models.DateField(blank=True, null=True)),
|
||||||
|
('additional_json_data', models.JSONField(default=dict)),
|
||||||
|
('course', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='course.course')),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
migrations.CreateModel(
|
||||||
|
name='CourseSessionUser',
|
||||||
|
fields=[
|
||||||
|
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||||
|
('created_at', models.DateTimeField(auto_now_add=True)),
|
||||||
|
('updated_at', models.DateTimeField(auto_now=True)),
|
||||||
|
('course_session', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='course.coursesession')),
|
||||||
|
('user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
migrations.AddConstraint(
|
||||||
|
model_name='coursesessionuser',
|
||||||
|
constraint=models.UniqueConstraint(fields=('course_session', 'user'), name='course_session_user_unique_course_session_user'),
|
||||||
|
),
|
||||||
|
]
|
||||||
|
|
@ -81,3 +81,45 @@ class CourseCompletion(models.Model):
|
||||||
name="course_completion_unique_user_page_key",
|
name="course_completion_unique_user_page_key",
|
||||||
)
|
)
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
|
class CourseSession(models.Model):
|
||||||
|
"""
|
||||||
|
Die Durchführung eines Kurses
|
||||||
|
Benutzer die an eine CourseSession gehängt sind können diesen Lehrgang sehen
|
||||||
|
Das anhängen kann via CourseSessionUser oder "Schulklasse (TODO)" geschehen
|
||||||
|
"""
|
||||||
|
|
||||||
|
created_at = models.DateTimeField(auto_now_add=True)
|
||||||
|
updated_at = models.DateTimeField(auto_now=True)
|
||||||
|
|
||||||
|
course = models.ForeignKey("course.Course", on_delete=models.CASCADE)
|
||||||
|
title = models.TextField()
|
||||||
|
|
||||||
|
start_date = models.DateField(null=True, blank=True)
|
||||||
|
end_date = models.DateField(null=True, blank=True)
|
||||||
|
|
||||||
|
additional_json_data = models.JSONField(default=dict)
|
||||||
|
|
||||||
|
|
||||||
|
class CourseSessionUser(models.Model):
|
||||||
|
"""
|
||||||
|
Ein Benutzer der an einer CourseSession teilnimmt
|
||||||
|
"""
|
||||||
|
|
||||||
|
created_at = models.DateTimeField(auto_now_add=True)
|
||||||
|
updated_at = models.DateTimeField(auto_now=True)
|
||||||
|
|
||||||
|
course_session = models.ForeignKey("course.CourseSession", on_delete=models.CASCADE)
|
||||||
|
user = models.ForeignKey(User, on_delete=models.CASCADE)
|
||||||
|
|
||||||
|
class Meta:
|
||||||
|
constraints = [
|
||||||
|
UniqueConstraint(
|
||||||
|
fields=[
|
||||||
|
"course_session",
|
||||||
|
"user",
|
||||||
|
],
|
||||||
|
name="course_session_user_unique_course_session_user",
|
||||||
|
)
|
||||||
|
]
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue