from django.db import models

# from ces_fall_rest_api.models.faculty import Faculty
from .outcome import Outcome
from .subject_area import SubjectArea
from .semester import Semester


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

    Args:
        models (_type_): Model class
    
    Returns:
        _type_: string object (course.number and course name)

    """
    number = models.CharField(max_length=10)
    name = models.CharField(max_length=35)
    outcomes = models.ManyToManyField(Outcome, blank=True)
    subject_area = models.ForeignKey(
        SubjectArea, on_delete=models.CASCADE, blank=True, null=True)

    semester = models.ForeignKey(Semester, on_delete=models.DO_NOTHING)

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

    class Meta:
        ordering = ['number']
