2023-06-27 21:12:03 +08:00
|
|
|
from django.db import models
|
|
|
|
from subjects.models import Subject
|
2023-07-09 19:00:47 +08:00
|
|
|
from django.contrib.gis.db import models as gis_models
|
|
|
|
from django.contrib.gis.geos import Point
|
2023-06-27 21:12:03 +08:00
|
|
|
# Create your models here.
|
|
|
|
|
|
|
|
|
|
|
|
class StudyGroup(models.Model):
|
2023-06-28 00:49:11 +08:00
|
|
|
name = models.CharField(max_length=48)
|
2023-06-27 21:12:03 +08:00
|
|
|
users = models.ManyToManyField(
|
|
|
|
'student_status.StudentStatus', through='StudyGroupMembership')
|
2023-07-14 23:55:54 +08:00
|
|
|
location = gis_models.PointField(blank=True, null=True, srid=4326)
|
2023-06-27 21:12:03 +08:00
|
|
|
subject = models.ForeignKey(Subject, on_delete=models.CASCADE)
|
|
|
|
active = models.BooleanField(default=False)
|
|
|
|
timestamp = models.DateField(auto_now_add=True)
|
|
|
|
|
2023-07-10 17:20:15 +08:00
|
|
|
def __str__(self):
|
|
|
|
return self.name
|
|
|
|
|
2023-06-27 21:12:03 +08:00
|
|
|
|
|
|
|
class StudyGroupMembership(models.Model):
|
|
|
|
user = models.ForeignKey(
|
|
|
|
'student_status.StudentStatus', on_delete=models.CASCADE)
|
|
|
|
study_group = models.ForeignKey(
|
|
|
|
'study_groups.StudyGroup', on_delete=models.CASCADE)
|
2023-06-28 00:49:11 +08:00
|
|
|
|
|
|
|
def __str__(self):
|
2023-07-10 17:20:15 +08:00
|
|
|
return f'StudyGroupMembership: User={self.user}, StudyGroup={self.study_group.name}'
|