poli_planning/polyclinic_scheduling/apps/schedule/models.py

52 lines
2.7 KiB
Python
Raw Normal View History

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.employee.models import Employee
from jsonfield import JSONField
import collections
# Create your models here.
class Schedule(MetaDataModel):
2020-05-18 14:22:52 +02:00
"""
A model that holds the schedule information. Here we store the form data and let the Peregrine cluster make the calculations.
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
----------
employee : Employee
The employee that is the owner of this schedule.
name : str
The name of the schedule. Max length is 100 characters.
email : str
The email address where the results should be sent to. Max length is 100 characters.
"""
2020-05-15 10:31:22 +02:00
class Meta:
2020-05-15 12:54:16 +02:00
verbose_name = _('schedule')
verbose_name_plural = _('schedules')
2020-05-15 10:31:22 +02:00
2020-05-13 15:54:40 +02:00
employee = models.ForeignKey(Employee, on_delete=models.CASCADE, help_text=_('Select the employee that is responsible for this schedule request'))
name = models.CharField(_('Name'), max_length=100, help_text=_('Name of the schedule'))
email = models.CharField(_('Email address'), max_length=100, help_text=_('Email address where the results will be sent to.'))
planning_source = JSONField(_('Schedule input'), blank=True, load_kwargs={'object_pairs_hook': collections.OrderedDict}, help_text=_('The schedule input in JSON format based on the form data'))
2020-05-14 15:20:19 +02:00
2020-05-13 15:54:40 +02:00
planning_peregrine = models.TextField(_('Peregrine input'), blank=True, help_text=_('This is the translated content from the source for use with Peregrine cluster'))
peregrine_accepted = models.BooleanField(_('Peregrine accepted'),default=False, help_text=_('When true, the Peregrine cluster has picked up the job.'))
2020-05-14 15:20:19 +02:00
peregrine_result = JSONField(_('Peregrine JSON output'), blank=True, load_kwargs={'object_pairs_hook': collections.OrderedDict}, help_text=_('The results from the Peregrine job in JSON'))
2020-05-13 15:54:40 +02:00
output_peregrine = models.BinaryField(_('Peregrine binary output'), blank=True, help_text=_('This is the output in binary format from the Peregrine cluster'))
2020-05-14 15:20:19 +02:00
report_sent = models.DateTimeField(_('Report is send to user'), blank=True, null=True, help_text=_('The date and time when the report has sended to the user.'))
2020-05-18 11:01:19 +02:00
peregrine_output_log = models.TextField(_('Peregrine logging'), blank=True, help_text=_('Here you can see the logging of the Peregrine job.'))
2020-05-13 15:54:40 +02:00
def __str__(self):
"""str: Returns a readable name for the schedule. Format is [schedule_name] (employee_name)."""
return '{} ({})'.format(self.name, self.employee)