mirror of
https://github.com/lemeow125/StudE-Backend.git
synced 2024-11-17 06:19:24 +08:00
Added some needed string definitions for django admin and moved study groups to leaflet
This commit is contained in:
parent
54347f5e26
commit
8d9364274c
5 changed files with 15 additions and 2 deletions
|
@ -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):
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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}'
|
||||
|
|
|
@ -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}'
|
||||
|
|
Loading…
Reference in a new issue