from django.db import models
from django.contrib.postgres.fields import ArrayField

from .semester import Semester
from .major import Major


class MajorQuestion(models.Model):
    """A class that inherits from the model class which 
    create a MajorQuestion model.This MajorQuestion model 
    defines a datastore entity.
    This class is ordering by MajorQuestion.major.

    Args:
        models (_type_): model class

    Returns:
        _type_: string object (MajorQuestion.major)
    """
    major = models.OneToOneField(
        Major, on_delete=models.CASCADE)
    questions = ArrayField(models.CharField(max_length=100))
    semester = models.ForeignKey(Semester, on_delete=models.CASCADE)

    def __str__(self) -> str:
        return f'{self.major}'

    class Meta:
        ordering = ['major']
