# 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'


from django.db import models
from django.contrib.auth.models import User
from students.models import Class



class BaseAbstractPost(models.Model):
    posted_on = models.DateTimeField(auto_now_add=True)
    edited = models.BooleanField(default=False)
    last_edited_on = models.DateTimeField(auto_now=True)

    class Meta:
        abstract = True


class AbstractPost(BaseAbstractPost):
    author = models.ForeignKey(User, on_delete=models.CASCADE)

    class Meta:
        abstract = True


class News(AbstractPost):
    title = models.CharField(max_length=100, blank=False)
    content = models.TextField(max_length=10000, blank=False)
    class_number = models.IntegerField(
        default=8,

# 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'


# Path: news/models.py
from django.db import models
from django.contrib.auth.models import User
from students.models import Class




class BaseAbstractPost(models.Model):
    posted_on = models.DateTimeField(auto_now_add=True)
    edited = models.BooleanField(default=False)
    last_edited_on = models.DateTimeField(auto_now=True)

    class Meta:
        abstract = True


class AbstractPost(BaseAbstractPost):
    author = models.ForeignKey(User, on_delete=models.CASCADE)

    class Meta:
        abstract = True


class News(AbstractPost):
    title = models.CharField(max_length=100, blank=False)
    content = models.TextField(max_length=10000, blank=False)
    class_number = models.IntegerField(
        default=8,

        validators=[Class.CLASS_NUMBER_VALIDATORS],