Compare commits

..

No commits in common. "ed6879b7f1bb858a62fe889a8be683022272b3db" and "832a8ca8801be21cc6a7eb1fd09b559037e0897b" have entirely different histories.

7 changed files with 20 additions and 103 deletions

View File

@ -35,10 +35,6 @@ form#new_schedule_form input {
width: 100% width: 100%
} }
.text-danger {
color: #721c24;
}
.alert-warning { .alert-warning {
color: #856404; color: #856404;
background-color: #fff3cd; background-color: #fff3cd;

View File

@ -1,30 +0,0 @@
# Generated by Django 3.0.6 on 2020-05-19 08:21
import collections
from django.db import migrations, models
import jsonfield.fields
class Migration(migrations.Migration):
dependencies = [
('schedule', '0004_auto_20200518_1425'),
]
operations = [
migrations.AlterField(
model_name='schedule',
name='output_peregrine',
field=models.BinaryField(blank=True, help_text='This is the output in binary format from the Peregrine cluster', null=True, verbose_name='Peregrine binary output'),
),
migrations.AlterField(
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}, null=True, verbose_name='Peregrine JSON output'),
),
migrations.AlterField(
model_name='schedule',
name='planning_source',
field=jsonfield.fields.JSONField(blank=True, help_text='The schedule input in JSON format based on the form data', load_kwargs={'object_pairs_hook': collections.OrderedDict}, null=True, verbose_name='Schedule input'),
),
]

View File

@ -76,11 +76,11 @@ class Schedule(MetaDataModel):
status = models.CharField(_('Status'), max_length=10, choices=ScheduleStatus.choices, default=ScheduleStatus.NEW, help_text=_('The status of this schedule.'), db_index=True, ) status = models.CharField(_('Status'), max_length=10, choices=ScheduleStatus.choices, default=ScheduleStatus.NEW, help_text=_('The status of this schedule.'), db_index=True, )
planning_source = JSONField(_('Schedule input'), blank=True, null=True, load_kwargs={'object_pairs_hook': collections.OrderedDict}, help_text=_('The schedule input in JSON format based on the form data')) 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'))
peregrine_result = JSONField(_('Peregrine JSON output'), blank=True, null=True, load_kwargs={'object_pairs_hook': collections.OrderedDict}, help_text=_('The results from the Peregrine job in JSON')) 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, null=True, help_text=_('This is the output in binary format from the Peregrine cluster')) 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.')) 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.'))

View File

@ -14,7 +14,6 @@
<th>{% trans "Updated" %}</th> <th>{% trans "Updated" %}</th>
<th>{% trans "Status" %}</th> <th>{% trans "Status" %}</th>
<th>{% trans "Report" %}</th> <th>{% trans "Report" %}</th>
<th>{% trans "Actions" %}</th>
</tr> </tr>
{% for schedule in object_list %} {% for schedule in object_list %}
<tr> <tr>
@ -24,7 +23,6 @@
<td>{{ schedule.updated_at|date:"SHORT_DATETIME_FORMAT" }}</td> <td>{{ schedule.updated_at|date:"SHORT_DATETIME_FORMAT" }}</td>
<td>{{ schedule.get_status_display }}</td> <td>{{ schedule.get_status_display }}</td>
<td>None</td> <td>None</td>
<td><a href="{% url 'schedule:clone' schedule_id=schedule.id %}">Clone</a></td>
</tr> </tr>
{% empty %} {% empty %}
<tr> <tr>

View File

@ -2,8 +2,8 @@
{% load i18n %} {% load i18n %}
{% load static %} {% load static %}
{% block title %}{% if form.json.value %}{% trans "Clone schedule" %}{% else %}{% trans "New schedule" %}{% endif %}{% endblock %} {% block title %}{% trans "New schedule" %}{% endblock %}
{% block pagetitle %}{% if form.json.value %}{% trans "Clone schedule" %}{% else %}{% trans "New schedule" %}{% endif %}{% endblock %} {% block pagetitle %}{% trans "New schedule" %}{% endblock %}
{% block content %} {% block content %}
<form method="POST" action="{% url 'schedule:new' %}" id="new_schedule_form"> <form method="POST" action="{% url 'schedule:new' %}" id="new_schedule_form">
{% csrf_token %} {% csrf_token %}
@ -464,7 +464,7 @@
var clone = jQuery('div.poliekliniek_specialisatie:first').clone() var clone = jQuery('div.poliekliniek_specialisatie:first').clone()
clone.find('input').val(''); clone.find('input').val('');
clone.find('option:disabled').removeAttr('disabled'); clone.find('option:disabled').removeAttr('disabled');
clone.find('small.text-muted').show(); clone.find('small').show();
clone.insertAfter('div.poliekliniek_specialisatie:last'); clone.insertAfter('div.poliekliniek_specialisatie:last');
updateSpecialisaties(); updateSpecialisaties();
loadRemoveSpecialisatie(); loadRemoveSpecialisatie();
@ -476,7 +476,6 @@
jQuery(this).parentsUntil('.poliekliniek_specialisatie').parent().remove(); jQuery(this).parentsUntil('.poliekliniek_specialisatie').parent().remove();
updateSpecialisaties(); updateSpecialisaties();
updateSpecialisatieValues(); updateSpecialisatieValues();
calculateBehandelingen();
}); });
} }
@ -503,7 +502,7 @@
}); });
jQuery('div.werktijden select').off('change').on('change',function(event){ jQuery('div.werktijden select').off('change').on('change',function(event){
check_working_hours(jQuery(this).parentsUntil('.werktijden').parent()); check_working_hours(this);
}); });
} }
@ -537,7 +536,11 @@
clone.insertAfter('tr.behandeling:last'); clone.insertAfter('tr.behandeling:last');
jQuery('tr.behandeling :input').off('change keyup').on('change keyup',function(){ jQuery('tr.behandeling input.behandeling_calc').off('change keyup').on('change keyup',function(){
calculateBehandelingen();
});
jQuery('tr.behandeling select').off('change').on('change',function(){
calculateBehandelingen(); calculateBehandelingen();
}); });
@ -551,7 +554,6 @@
jQuery(this).parentsUntil('.behandeling').parent().remove(); jQuery(this).parentsUntil('.behandeling').parent().remove();
updateBehandelingen(); updateBehandelingen();
calculateBehandelingen();
}); });
} }
@ -809,11 +811,8 @@
} }
function check_working_hours(html, showerror) { function check_working_hours(html, showerror) {
if (Array.isArray(html)) { html = jQuery(html).parentsUntil('.werktijden').parent();
html = html[0]; html = jQuery(html[0]);
}
html = jQuery(html);
let day_start = html.find('select[name^="werkdag_start_afdeling_"]'); let day_start = html.find('select[name^="werkdag_start_afdeling_"]');
let day_end = html.find('select[name^="werkdag_end_afdeling_"]'); let day_end = html.find('select[name^="werkdag_end_afdeling_"]');
@ -918,35 +917,6 @@
} }
} }
function load_clone_data() {
if (jQuery('input#id_json').val() != '') {
let form = jQuery('form#new_schedule_form');
let json_data = JSON.parse(form.find('input#id_json').val());
jQuery.each(json_data,function(key,value){
let input = form.find(':input[name="' + key + '"]');
if (input.length == 0) {
// check for second or more specilism or treatment
if (key.indexOf('behandeling') >= 0) {
addBehandeling();
} else {
addSpecialisatie();
}
input = form.find(':input[name="' + key + '"]');
}
input.val(value);
updateSpecialisatieValues();
});
validate_working_hours();
calculateBehandelingen();
validate_behandeling_hours();
}
}
jQuery(function() { jQuery(function() {
jQuery('a.add_specialisatie').on('click',function(event){ jQuery('a.add_specialisatie').on('click',function(event){
event.preventDefault(); event.preventDefault();
@ -969,7 +939,7 @@
}); });
jQuery('div.werktijden select').off('change').on('change',function(event){ jQuery('div.werktijden select').off('change').on('change',function(event){
check_working_hours(jQuery(this).parentsUntil('.werktijden').parent()); check_working_hours(this);
calculateBehandelingen(); calculateBehandelingen();
}); });
@ -979,7 +949,7 @@
}); });
}); });
jQuery('tr.behandeling :input').off('change keyup').on('change keyup',function(event){ jQuery('input.behandeling_calc').off('change keyup').on('change keyup',function(event){
calculateBehandelingen(); calculateBehandelingen();
}); });
@ -996,11 +966,10 @@
return true; return true;
} else { } else {
alert('Er zijn wat problemen met het formulier. Controleer de invoer velden'); alert('Er zijn wat problemen met het formulier. Controleer de invoer velden');
} }
return false; return false;
}); });
load_clone_data();
}); });
</script> </script>
{% endblock %} {% endblock %}

View File

@ -5,8 +5,5 @@ from . import views
app_name = 'schedule' app_name = 'schedule'
urlpatterns = [ urlpatterns = [
path('', views.ScheduleListView.as_view(), name='list'), path('', views.ScheduleListView.as_view(), name='list'),
path('new', views.new_or_update_schedule, name='new'), path('new', views.new_or_update_study, name='new'),
#path('<int:pk>', views.ScheduleDetailView.as_view(), name='detail'),
path('<int:schedule_id>/clone', views.new_or_update_schedule, name='clone'),
] ]

View File

@ -3,7 +3,6 @@ from django.shortcuts import render, redirect
from django.views.generic.list import ListView from django.views.generic.list import ListView
from django.contrib.auth.mixins import LoginRequiredMixin from django.contrib.auth.mixins import LoginRequiredMixin
from django.contrib.auth.decorators import login_required from django.contrib.auth.decorators import login_required
from django.forms.models import model_to_dict
from .models import Schedule from .models import Schedule
from .forms import ScheduleForm from .forms import ScheduleForm
@ -20,16 +19,9 @@ class ScheduleListView(LoginRequiredMixin,ListView):
return Schedule.objects.filter(employee=self.request.user.employee).order_by('-created_at') return Schedule.objects.filter(employee=self.request.user.employee).order_by('-created_at')
@login_required @login_required
def new_or_update_schedule(request, schedule_id = None): def new_or_update_study(request, schedule = None):
template_name = 'schedule/schedule_new.html' template_name = 'schedule/schedule_new.html'
schedule = None
if schedule_id is not None:
try:
schedule = Schedule.objects.get(pk=schedule_id)
except Schedule.DoesNotExist:
pass
if request.method == 'POST': if request.method == 'POST':
schedule_form = ScheduleForm(request.POST) schedule_form = ScheduleForm(request.POST)
@ -51,12 +43,7 @@ def new_or_update_schedule(request, schedule_id = None):
return redirect('schedule:list') return redirect('schedule:list')
else: else:
if schedule is not None: schedule_form = ScheduleForm()
print(dir(schedule.planning_source))
schedule = json.dumps(schedule.planning_source)
print(schedule)
schedule_form = ScheduleForm(initial={'json' : schedule})
return render(request, template_name, { return render(request, template_name, {
'form' : schedule_form, 'form' : schedule_form,