# Path: materials/admin.py
# class MaterialInline(admin.StackedInline):
#     model = Material
# 
# Path: students/models.py
# class Class(models.Model):
#     CLASS_NUMBERS = (
#         (8, 8),
#         (9, 9),
#         (10, 10),
#         (11, 11),
#         (12, 12),
#     )
#     CLASS_NUMBER_VALIDATORS = [MinValueValidator(8), MaxValueValidator(12)]
# 
#     CLASS_LETTERS = (
#         ('A', 'A'),
#         ('B', 'B'),
#         ('V', 'V'),
#         ('G', 'G'),
#     )
# 
#     number = models.IntegerField(validators=CLASS_NUMBER_VALIDATORS, choices=CLASS_NUMBERS)
#     letter = models.CharField(max_length=1, choices=CLASS_LETTERS)
# 
#     def __str__(self):
#         return '{}{}'.format(self.number, self.letter)
# 
#     class Meta:
#         ordering = ['number', 'letter']
#         verbose_name_plural = 'classes'
# 
# class Subject(models.Model):
#     title = models.CharField(unique=True, max_length=50)
# 
#     def __str__(self):
#         return self.title
# 
#     class Meta:
#         ordering = ['title']
# 
# class Student(Account):
#     clazz = models.ForeignKey(Class, related_name='students', on_delete=models.CASCADE)
# 
#     def __str__(self):
#         return '{} ({})'.format(self.user.username, self.clazz)
# 
# class Teacher(Account):
#     subject = models.ForeignKey(Subject, related_name='teachers', on_delete=models.CASCADE)
# 
#     def __str__(self):
#         return '{} ({})'.format(self.user.username, self.subject)
# 
# class Grade(models.Model):
#     GRADE_VALIDATORS = [MinValueValidator(2), MaxValueValidator(6)]
# 
#     value = models.FloatField(validators=GRADE_VALIDATORS)
#     subject = models.ForeignKey(Subject, related_name='grades', on_delete=models.CASCADE)
#     student = models.ForeignKey(Student, related_name='grades', on_delete=models.CASCADE)
# 
#     def __str__(self):
#         return '{} - {} ({})'.format(self.student, self.subject, self.value)


from django.contrib import admin
from django.contrib.admin.decorators import register
from materials.admin import MaterialInline
from .models import Class, Subject, Student, Teacher, Grade




@register(Subject)
class SubjectAdmin(admin.ModelAdmin):
    list_display = ('id', 'title')
    inlines = [
        MaterialInline
    ]


class GradeInline(admin.TabularInline):
    model = Grade



# Path: materials/admin.py
# class MaterialInline(admin.StackedInline):
#     model = Material
# 
# Path: students/models.py
# class Class(models.Model):
#     CLASS_NUMBERS = (
#         (8, 8),
#         (9, 9),
#         (10, 10),
#         (11, 11),
#         (12, 12),
#     )
#     CLASS_NUMBER_VALIDATORS = [MinValueValidator(8), MaxValueValidator(12)]
# 
#     CLASS_LETTERS = (
#         ('A', 'A'),
#         ('B', 'B'),
#         ('V', 'V'),
#         ('G', 'G'),
#     )
# 
#     number = models.IntegerField(validators=CLASS_NUMBER_VALIDATORS, choices=CLASS_NUMBERS)
#     letter = models.CharField(max_length=1, choices=CLASS_LETTERS)
# 
#     def __str__(self):
#         return '{}{}'.format(self.number, self.letter)
# 
#     class Meta:
#         ordering = ['number', 'letter']
#         verbose_name_plural = 'classes'
# 
# class Subject(models.Model):
#     title = models.CharField(unique=True, max_length=50)
# 
#     def __str__(self):
#         return self.title
# 
#     class Meta:
#         ordering = ['title']
# 
# class Student(Account):
#     clazz = models.ForeignKey(Class, related_name='students', on_delete=models.CASCADE)
# 
#     def __str__(self):
#         return '{} ({})'.format(self.user.username, self.clazz)
# 
# class Teacher(Account):
#     subject = models.ForeignKey(Subject, related_name='teachers', on_delete=models.CASCADE)
# 
#     def __str__(self):
#         return '{} ({})'.format(self.user.username, self.subject)
# 
# class Grade(models.Model):
#     GRADE_VALIDATORS = [MinValueValidator(2), MaxValueValidator(6)]
# 
#     value = models.FloatField(validators=GRADE_VALIDATORS)
#     subject = models.ForeignKey(Subject, related_name='grades', on_delete=models.CASCADE)
#     student = models.ForeignKey(Student, related_name='grades', on_delete=models.CASCADE)
# 
#     def __str__(self):
#         return '{} - {} ({})'.format(self.student, self.subject, self.value)


# Path: students/admin.py
from django.contrib import admin
from django.contrib.admin.decorators import register
from materials.admin import MaterialInline
from .models import Class, Subject, Student, Teacher, Grade





@register(Subject)
class SubjectAdmin(admin.ModelAdmin):
    list_display = ('id', 'title')
    inlines = [
        MaterialInline
    ]


class GradeInline(admin.TabularInline):
    model = Grade



@register(Student)