from django.db import models from django.utils.translation import gettext_lazy as _ from lib.models.base import MetaDataModel # Create your models here. class Hospital(MetaDataModel): name = models.CharField(_('Name'), max_length=200, help_text=_('The name of this hospital')) address = models.CharField(_('Address'), max_length=200, blank=True, help_text=_('The address of this hospital')) postal_code = models.CharField(_('Postal code'), max_length=10, blank=True, help_text=_('The postal code of this hospital')) city = models.CharField(_('City'), max_length=60, blank=True, help_text=_('The city of this hospital')) phone = models.CharField(_('Phone number'), max_length=18, blank=True, help_text=_('The general phone number of this hospital')) def __str__(self): """str: Returns a readable name for the hospital. Format is [hospital_name] ([city]).""" return '{}{}'.format(self.name, ('' if not self.city else ' ({})'.format(self.city)))