Added some needed string definitions for django admin and moved study groups to leaflet

This commit is contained in:
Keannu Bernasol 2023-07-10 17:20:15 +08:00
parent 54347f5e26
commit 8d9364274c
5 changed files with 15 additions and 2 deletions

View file

@ -19,6 +19,9 @@ class SubjectCourse(models.Model):
course = models.ForeignKey(
'courses.Course', on_delete=models.CASCADE, null=True)
def __str__(self):
return (self.subject + ' under course ' + self.course)
@receiver(post_migrate)
def populate_courses(sender, **kwargs):

View file

@ -16,3 +16,6 @@ class StudentStatus(models.Model):
timestamp = models.DateField(auto_now_add=True)
study_group = models.ManyToManyField(
'study_groups.StudyGroup', through='study_groups.StudyGroupMembership', blank=True)
def __str__(self):
return self.user.full_name

View file

@ -1,6 +1,7 @@
from django.contrib import admin
from .models import StudyGroup, StudyGroupMembership
from leaflet.admin import LeafletGeoAdmin
admin.site.register(StudyGroup)
admin.site.register(StudyGroup, LeafletGeoAdmin)
admin.site.register(StudyGroupMembership)

View file

@ -14,6 +14,9 @@ class StudyGroup(models.Model):
active = models.BooleanField(default=False)
timestamp = models.DateField(auto_now_add=True)
def __str__(self):
return self.name
class StudyGroupMembership(models.Model):
user = models.ForeignKey(
@ -22,4 +25,4 @@ class StudyGroupMembership(models.Model):
'study_groups.StudyGroup', on_delete=models.CASCADE)
def __str__(self):
return f'StudyGroupMembership: User={self.user_id}, StudyGroup={self.study_group_id}'
return f'StudyGroupMembership: User={self.user}, StudyGroup={self.study_group.name}'

View file

@ -9,3 +9,6 @@ class Message(models.Model):
study_group = models.ForeignKey(StudyGroup, on_delete=models.CASCADE)
message_content = models.TextField(max_length=1024)
timestamp = models.DateTimeField(auto_now_add=True)
def __str__(self):
return f'Message: User={self.user.full_name}, Study_group={self.study_group.name}, ID={self.id}'