from django.db import models

from .user import User


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

    Args:
        models (_type_): model class

    Returns:
        _type_: string object (faculty.role, faculty.first_name, and faculty.last_name)
    """
    user = models.OneToOneField(
        User, on_delete=models.CASCADE, primary_key=True)
    role = models.CharField(max_length=15)

    def __str__(self) -> str:
        return f'{self.role}: {self.user.first_name} {self.user.last_name}'

    class Meta:
        ordering = ['role']
