Add UI for instructors to add and edit classes

This commit is contained in:
2020-01-16 01:32:52 +00:00
parent 561e3f99d0
commit df0d83983d
10 changed files with 225 additions and 17 deletions

View File

@@ -73,6 +73,7 @@ class Session(models.Model):
old_instructor = models.TextField(blank=True, null=True)
datetime = models.DateTimeField(blank=True, null=True)
cost = models.DecimalField(max_digits=5, decimal_places=2)
max_students = models.IntegerField(blank=True, null=True)
class Training(models.Model):
user = models.ForeignKey(User, related_name='training', blank=True, null=True, on_delete=models.SET_NULL)

View File

@@ -236,6 +236,7 @@ class SessionSerializer(serializers.ModelSerializer):
class Meta:
model = models.Session
fields = '__all__'
read_only_fields = ['old_instructor']
def get_student_count(self, obj):
return len(obj.students.all())
def get_course_name(self, obj):