poli_planning/polyclinic_scheduling/apps/employee/models.py

25 lines
1.1 KiB
Python
Raw Normal View History

2020-05-13 15:54:40 +02:00
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):
2020-05-15 10:31:22 +02:00
class Meta:
verbose_name = _('Employee')
verbose_name_plural = _('Employees')
2020-05-13 15:54:40 +02:00
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)