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.
 
 

34 lines
1.2 KiB

from django.db import models
from django.utils.translation import gettext_lazy as _
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',
verbose_name=_('Student')
)
course = models.ForeignKey(
Course,
on_delete=models.CASCADE,
related_name='participants',
verbose_name=_('Course')
)
is_active = models.BooleanField(default=True, verbose_name=_('Is Active'))
joined_date = models.DateTimeField(auto_now_add=True, verbose_name=_('Joined Date'))
unread_messages_count = models.IntegerField(default=0, verbose_name=_('Unread Messages Count'))
class Meta:
unique_together = ('student', 'course')
verbose_name = _('Participant')
verbose_name_plural = _('Participants')
indexes = [
models.Index(fields=['student']),
models.Index(fields=['course']),
models.Index(fields=['joined_date']),
models.Index(fields=['student', 'course']),
]