diff --git a/courses/models.py b/courses/models.py index 665f6c1..9914fc1 100644 --- a/courses/models.py +++ b/courses/models.py @@ -20,6 +20,9 @@ class Meta: managed = True #auto creates tables db_table = 'Courses' + def __str__(self): + return self.course_title + ' - ' + self.course_title + #Algorithm Specific Models diff --git a/preferences/models.py b/preferences/models.py index e04b8b5..331e697 100644 --- a/preferences/models.py +++ b/preferences/models.py @@ -30,6 +30,10 @@ class SabbaticalLength(models.TextChoices): preferred_non_teaching_semester = models.CharField(max_length=10, blank=True, default='') preferred_courses_per_semester = models.JSONField(default=dict) preferred_course_day_spreads = ArrayField(models.CharField(max_length=5, blank=False), default=list) + + def __str__(self): + return self.professor.first_name + ' ' + self.professor.last_name + class Meta: managed = True #auto creates tables diff --git a/schedule/Schedule_models.py b/schedule/Schedule_models.py index 8c4804e..619f584 100644 --- a/schedule/Schedule_models.py +++ b/schedule/Schedule_models.py @@ -38,11 +38,13 @@ class A_CourseSection(models.Model): capacity = models.PositiveIntegerField(default=0) timeSlots = models.ManyToManyField(A_TimeSlot, related_name='courseSections') #to associate multiple TimeSlot objects - '''def __str__(self): + def __str__(self): related_timeSlots = [str(slot) for slot in self.timeSlots.all()] - prof = str(self.professor['name']) if not None else 'null' - return 'Professor: ' + prof + ', Capacity: ' + str(self.capacity) + ', TimeSlots: ' + f'{" ".join(related_timeSlots)}' - ''' + id_str = '#' + str(self.id) + ') ' + if self.professor is not None and len(related_timeSlots) != 0: + return id_str + 'Professor: ' + str(self.professor['name']) + ', Capacity: ' + str(self.capacity) + ', TimeSlots: ' + f'{" ".join(related_timeSlots)}' + + return id_str + 'A_Coursection(capacity: ' + str(self.capacity) + ')' '''PRIMARY KEY: code''' @@ -53,7 +55,7 @@ class A_Course(models.Model): yearRequired = models.PositiveIntegerField() def __str__(self): - return str(self.code) + return str(self.code) + ' - ' + str(self.title) #one instance of this class should represent a single Course & CourseSection pair diff --git a/users/models.py b/users/models.py index be6abf3..495328f 100644 --- a/users/models.py +++ b/users/models.py @@ -41,6 +41,10 @@ class Meta: managed = True #auto creates tables db_table = 'appuser' + + def __str__(self): + return self.user.first_name + ' ' + self.user.last_name + ' (' + self.user.username + '@uvic.ca)' + # Use Django signals to delete User instance when AppUser is deleted. Based on: https://stackoverflow.com/a/12754229 @receiver(post_delete, sender=AppUser) def post_delete_user(sender, instance, **kwargs):