from django.db import models
from .subject_area import SubjectArea


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

    Args:
        models (_type_): model class

    Returns:
        _type_: sting object (Major.degree and Major.subject_area)
    """
    degree = models.CharField(max_length=25)
    subject_area = models.ForeignKey(SubjectArea, on_delete=models.CASCADE)

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

    class Meta:
        ordering = ['subject_area']
        unique_together = (('degree', 'subject_area'),)
