Update schedule module

This commit is contained in:
2020-05-14 15:20:19 +02:00
parent 5be8fa9c6d
commit d9899f2d56
17 changed files with 871 additions and 701 deletions

View File

@ -0,0 +1,24 @@
from django.core.management.base import BaseCommand, CommandError
from apps.schedule.models import Schedule
#from polls.models import Question as Poll
class Command(BaseCommand):
help = 'Send out all the new reports'
# def add_arguments(self, parser):
# parser.add_argument('poll_ids', nargs='+', type=int)
def handle(self, *args, **options):
Schedule.objects.filter(peregrine_result__isnull=False).filter(report_sent__isnull=True)
# for poll_id in options['poll_ids']:
# try:
# poll = Poll.objects.get(pk=poll_id)
# except Poll.DoesNotExist:
# raise CommandError('Poll "%s" does not exist' % poll_id)
# poll.opened = False
# poll.save()
# self.stdout.write(self.style.SUCCESS('Successfully closed poll "%s"' % poll_id))

View File

@ -0,0 +1,25 @@
# Generated by Django 3.0.6 on 2020-05-14 13:18
import collections
from django.db import migrations, models
import jsonfield.fields
class Migration(migrations.Migration):
dependencies = [
('schedule', '0001_initial'),
]
operations = [
migrations.AddField(
model_name='schedule',
name='peregrine_result',
field=jsonfield.fields.JSONField(blank=True, help_text='The results from the Peregrine job in JSON', load_kwargs={'object_pairs_hook': collections.OrderedDict}, verbose_name='Peregrine JSON output'),
),
migrations.AddField(
model_name='schedule',
name='report_sent',
field=models.DateTimeField(blank=True, help_text='The date and time when the report has sended to the user.', null=True, verbose_name='Report is send to user'),
),
]

View File

@ -15,12 +15,17 @@ class Schedule(MetaDataModel):
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'))
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.'))
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'))
output_peregrine = models.BinaryField(_('Peregrine binary output'), blank=True, help_text=_('This is the output in binary format from the Peregrine cluster'))
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.'))
def __str__(self):
"""str: Returns a readable name for the schedule. Format is [schedule_name] (employee_name)."""
return '{} ({})'.format(self.name, self.employee)