# Path: students/serializers.py
# class SubjectSerializer(serializers.ModelSerializer):
#     title = serializers.CharField(
#         max_length=50,
#         allow_blank=False,
#         validators=[
#             UniqueValidator(
#                 queryset=Subject.objects.all(),
#                 message='Subject with this title already exists.'
#             )
#         ]
#     )
# 
#     class Meta:
#         model = Subject
#         fields = ('id', 'title')
# 
# class TeacherAuthorSerializer(DefaultAuthorSerializer):
#     class Meta:
#         model = Teacher
#         fields = ('id', 'user', 'subject')
# 
# Path: materials/models.py
# class Material(models.Model):
#     title = models.CharField(max_length=150, blank=True)
#     section = models.CharField(max_length=150, blank=True)
#     content = models.TextField(blank=False)
#     class_number = models.IntegerField(
#         choices=Class.CLASS_NUMBERS,
#         validators=[Class.CLASS_NUMBER_VALIDATORS]
#     )
#     subject = models.ForeignKey(Subject, related_name='materials', on_delete=models.CASCADE)
#     video_url = models.URLField(blank=True)
#     author = models.ForeignKey(Teacher, null=True, on_delete=models.CASCADE)
# 
#     def __str__(self):
#         return '{} - {} ({} class) posted by {}'.format(
#             self.title, self.subject, self.class_number, self.author
#         )


from rest_framework import serializers
from students.serializers import SubjectSerializer, TeacherAuthorSerializer
from .models import Material




class MaterialSerializer(serializers.ModelSerializer):
    title = serializers.CharField(required=False, min_length=3, max_length=150, allow_blank=True)
    section = serializers.CharField(required=False, min_length=3, max_length=150, allow_blank=True)
    content = serializers.CharField(allow_blank=False)
    subject = SubjectSerializer(read_only=True)
    video_url = serializers.URLField(required=False, allow_blank=True)

    class Meta:

# Path: students/serializers.py
# class SubjectSerializer(serializers.ModelSerializer):
#     title = serializers.CharField(
#         max_length=50,
#         allow_blank=False,
#         validators=[
#             UniqueValidator(
#                 queryset=Subject.objects.all(),
#                 message='Subject with this title already exists.'
#             )
#         ]
#     )
# 
#     class Meta:
#         model = Subject
#         fields = ('id', 'title')
# 
# class TeacherAuthorSerializer(DefaultAuthorSerializer):
#     class Meta:
#         model = Teacher
#         fields = ('id', 'user', 'subject')
# 
# Path: materials/models.py
# class Material(models.Model):
#     title = models.CharField(max_length=150, blank=True)
#     section = models.CharField(max_length=150, blank=True)
#     content = models.TextField(blank=False)
#     class_number = models.IntegerField(
#         choices=Class.CLASS_NUMBERS,
#         validators=[Class.CLASS_NUMBER_VALIDATORS]
#     )
#     subject = models.ForeignKey(Subject, related_name='materials', on_delete=models.CASCADE)
#     video_url = models.URLField(blank=True)
#     author = models.ForeignKey(Teacher, null=True, on_delete=models.CASCADE)
# 
#     def __str__(self):
#         return '{} - {} ({} class) posted by {}'.format(
#             self.title, self.subject, self.class_number, self.author
#         )


# Path: materials/serializers.py
from rest_framework import serializers
from students.serializers import SubjectSerializer, TeacherAuthorSerializer
from .models import Material





class MaterialSerializer(serializers.ModelSerializer):
    title = serializers.CharField(required=False, min_length=3, max_length=150, allow_blank=True)
    section = serializers.CharField(required=False, min_length=3, max_length=150, allow_blank=True)
    content = serializers.CharField(allow_blank=False)
    subject = SubjectSerializer(read_only=True)
    video_url = serializers.URLField(required=False, allow_blank=True)

    class Meta:

        model = Material