poli_planning/polyclinic_scheduling/apps/employee/models.py

25 lines
1.1 KiB
Python

from django.db import models
from django.contrib.auth.models import User
from django.utils.translation import gettext_lazy as _
from lib.models.base import MetaDataModel
from apps.hospital.models import Hospital
from apps.polyclinic.models import Polyclinic
# Create your models here.
class Employee(MetaDataModel):
class Meta:
verbose_name = _('employee')
verbose_name_plural = _('employees')
user = models.OneToOneField(User, on_delete=models.CASCADE, help_text=_('Django user'))
hospital = models.ForeignKey(Hospital, on_delete=models.CASCADE, help_text=_('Select the hospital for this employee'))
polyclinic = models.ManyToManyField(Polyclinic, blank=True, help_text=_('Select the polyclinic(s) for this employee'))
phone = models.CharField(_('Phone number'), max_length=15, blank=True, help_text=_('The direct phone number of this employee'))
def __str__(self):
"""str: Returns a readable name for the hospital. Format is [hospital_name] ([city])."""
return '{} ({})'.format(self.user.get_full_name(), self.hospital)