2020-05-13 15:54:40 +02:00
from django . db import models
from django . utils . translation import gettext_lazy as _
from lib . models . base import MetaDataModel
from apps . hospital . models import Hospital
# Create your models here.
class Polyclinic ( MetaDataModel ) :
2020-05-18 14:22:52 +02:00
"""
A model that holds the polyclinic information . This is just basic information just for getting in contact .
It will inherit the attributes : attr : ` ~ lib . models . base . MetaDataModel . created_at ` and : attr : ` ~ lib . models . base . MetaDataModel . updated_at ` from the Abstract model : class : ` ~ lib . models . base . MetaDataModel `
Attributes
- - - - - - - - - -
hospital : Hospital
The hospital where this polyclinic belongs to .
name : str
The name of the polyclinic . Max length is 200 characters .
phone : str
The general / direct phone number of this polyclinic . Max length is 20 characters .
"""
2020-05-15 10:31:22 +02:00
class Meta :
2020-05-15 12:54:16 +02:00
verbose_name = _ ( ' polyclinic ' )
verbose_name_plural = _ ( ' polyclinics ' )
2020-05-15 10:31:22 +02:00
2020-05-19 16:13:34 +02:00
hospital = models . ForeignKey ( Hospital , verbose_name = Hospital . _meta . verbose_name , on_delete = models . CASCADE , help_text = _ ( ' To which hospital belongs this polyclinic ' ) )
2020-05-13 15:54:40 +02:00
name = models . CharField ( _ ( ' Name ' ) , max_length = 200 , blank = True , help_text = _ ( ' The name of this polyclinic ' ) )
2020-05-18 14:22:52 +02:00
phone = models . CharField ( _ ( ' Phone number ' ) , max_length = 20 , blank = True , help_text = _ ( ' The general/direct phone number of this polyclinic ' ) )
2020-05-13 15:54:40 +02:00
def __str__ ( self ) :
2020-05-18 14:22:52 +02:00
""" str: Returns a readable name for the polyclinic. Format is [polyclinic_name] ([hospital_name]). """
2020-05-13 15:54:40 +02:00
return ' {} ( {} ) ' . format ( self . name , self . hospital )