You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
31 lines
879 B
31 lines
879 B
|
|
from django.db import models
|
|
|
|
|
|
from apps.account.models import StudentUser, User
|
|
from apps.course.models import Course
|
|
|
|
|
|
class Participant(models.Model):
|
|
student = models.ForeignKey(
|
|
StudentUser,
|
|
on_delete=models.CASCADE,
|
|
related_name='participated_courses'
|
|
)
|
|
course = models.ForeignKey(
|
|
Course,
|
|
on_delete=models.CASCADE,
|
|
related_name='participants'
|
|
)
|
|
is_active = models.BooleanField(default=True)
|
|
joined_date = models.DateTimeField(auto_now_add=True)
|
|
unread_messages_count = models.IntegerField(default=0)
|
|
|
|
class Meta:
|
|
unique_together = ('student', 'course')
|
|
indexes = [
|
|
models.Index(fields=['student']),
|
|
models.Index(fields=['course']),
|
|
models.Index(fields=['joined_date']),
|
|
models.Index(fields=['student', 'course']),
|
|
]
|