Skip to content
Snippets Groups Projects
Commit daa8f423 authored by Piotr Gawron's avatar Piotr Gawron
Browse files

possibility to configure which study subject fields should be available in the system

parent b2da009c
No related branches found
No related tags found
1 merge request!139Configuration page for a study
from study_forms import StudyEditForm, StudyNotificationParametersEditForm
from study_forms import StudyEditForm, StudyNotificationParametersEditForm, StudyColumnsEditForm
from worker_form import WorkerForm
from forms import VisitDetailForm, \
VisitAddForm, KitRequestForm, StatisticsForm, AvailabilityAddForm, \
......@@ -13,4 +13,4 @@ __all__ = [StudySubjectAddForm, StudySubjectDetailForm, StudySubjectEditForm, Wo
AppointmentDetailForm, AppointmentEditForm, AppointmentAddForm, VisitDetailForm, VisitAddForm,
ContactAttemptAddForm, ContactAttemptEditForm, KitRequestForm, StatisticsForm, AvailabilityAddForm,
AvailabilityEditForm, HolidayAddForm, SubjectAddForm, SubjectEditForm, SubjectDetailForm, VoucherTypeForm,
VoucherTypePriceForm, VoucherForm, StudyEditForm, StudyNotificationParametersEditForm]
VoucherTypePriceForm, VoucherForm, StudyEditForm, StudyNotificationParametersEditForm, StudyColumnsEditForm]
......@@ -2,7 +2,7 @@ import logging
from django.forms import ModelForm
from web.models import Study, StudyNotificationParameters
from web.models import Study, StudyNotificationParameters, StudyColumns
logger = logging.getLogger(__name__)
......@@ -26,3 +26,13 @@ class StudyNotificationParametersEditForm(ModelForm):
class Meta:
model = StudyNotificationParameters
fields = '__all__'
class StudyColumnsEditForm(ModelForm):
def __init__(self, *args, **kwargs):
super(StudyColumnsEditForm, self).__init__(*args, **kwargs)
class Meta:
model = StudyColumns
fields = '__all__'
......@@ -8,107 +8,107 @@ class StudyColumns(models.Model):
class Meta:
app_label = 'web'
postponed = models.BooleanField(choices=BOOL_CHOICES,
verbose_name='Postponed',
default=True
)
postponed = models.BooleanField(
verbose_name='Postponed',
default=True
)
datetime_contact_reminder = models.BooleanField(choices=BOOL_CHOICES,
datetime_contact_reminder = models.BooleanField(
default=True,
verbose_name='Please make a contact on'
)
type = models.BooleanField(choices=BOOL_CHOICES,
type = models.BooleanField(
default=True,
verbose_name='Type'
)
default_location = models.BooleanField(choices=BOOL_CHOICES,
default_location = models.BooleanField(
default=True,
verbose_name='Default appointment location',
)
flying_team = models.BooleanField(choices=BOOL_CHOICES,
flying_team = models.BooleanField(
default=True,
verbose_name='Default flying team location (if applicable)',
)
screening_number = models.BooleanField(choices=BOOL_CHOICES,
screening_number = models.BooleanField(
default=True,
verbose_name='Screening number',
)
nd_number = models.BooleanField(choices=BOOL_CHOICES,
nd_number = models.BooleanField(
default=True,
verbose_name='ND number',
)
mpower_id = models.BooleanField(choices=BOOL_CHOICES,
mpower_id = models.BooleanField(
default=True,
verbose_name='MPower ID'
)
comments = models.BooleanField(choices=BOOL_CHOICES,
comments = models.BooleanField(
default=True,
verbose_name='Comments'
)
referral = models.BooleanField(choices=BOOL_CHOICES,
referral = models.BooleanField(
default=True,
verbose_name='Referred by'
)
diagnosis = models.BooleanField(choices=BOOL_CHOICES,
diagnosis = models.BooleanField(
default=True,
verbose_name='Diagnosis'
)
year_of_diagnosis = models.BooleanField(choices=BOOL_CHOICES,
year_of_diagnosis = models.BooleanField(
default=True,
verbose_name='Year of diagnosis (YYYY)'
)
information_sent = models.BooleanField(choices=BOOL_CHOICES,
information_sent = models.BooleanField(
default=True,
verbose_name='Information sent',
)
pd_in_family = models.BooleanField(choices=BOOL_CHOICES,
pd_in_family = models.BooleanField(
default=True,
verbose_name='PD in family',
)
resigned = models.BooleanField(choices=BOOL_CHOICES,
resigned = models.BooleanField(
default=True,
verbose_name='Resigned',
)
resign_reason = models.BooleanField(choices=BOOL_CHOICES,
resign_reason = models.BooleanField(
default=True,
verbose_name='Resign reason'
)
referral_letter = models.BooleanField(choices=BOOL_CHOICES,
referral_letter = models.BooleanField(
default=False,
verbose_name='Referral letter'
)
health_partner = models.BooleanField(choices=BOOL_CHOICES,
health_partner = models.BooleanField(
default=False,
verbose_name='Health partner'
)
health_partner_feedback_agreement = models.BooleanField(choices=BOOL_CHOICES,
health_partner_feedback_agreement = models.BooleanField(
default=False,
verbose_name='Agrees to give information to referral'
)
screening = models.BooleanField(choices=BOOL_CHOICES,
screening = models.BooleanField(
default=False,
verbose_name='Screening'
)
previously_in_study = models.BooleanField(choices=BOOL_CHOICES,
previously_in_study = models.BooleanField(
default=False,
verbose_name='Previously in PDP study',
)
voucher_types = models.BooleanField(choices=BOOL_CHOICES,
voucher_types = models.BooleanField(
default=False,
verbose_name='Voucher types',
)
vouchers = models.BooleanField(choices=BOOL_CHOICES,
vouchers = models.BooleanField(
default=False,
verbose_name='Vouchers',
)
......@@ -85,6 +85,31 @@
</div>
</div><!-- /.box-body -->
<div class="box-header with-border">
<h3>Available subject study data</h3>
</div>
<div class="box-body">
<div class="col-md-12">
{% for field in study_columns_form %}
<div class="col-md-6 form-group {% if field.errors %}has-error{% endif %}">
<label for="{# TODO #}" class="col-sm-4 control-label">
{{ field.label }}
</label>
<div class="col-sm-8">
{{ field|add_class:'form-control' }}
</div>
{% if field.errors %}
<span class="help-block"> {{ field.errors }} </span>
{% endif %}
</div>
{% endfor %}
</div>
</div><!-- /.box-body -->
<div class="box-footer">
<div class="col-sm-4">
<button type="submit" class="btn btn-block btn-success">Save</button>
......
......@@ -4,9 +4,9 @@ import logging
from django.contrib import messages
from django.shortcuts import redirect, get_object_or_404
from . import wrap_response
from ..forms import StudyEditForm, StudyNotificationParametersEditForm
from ..models import Study
from web.forms import StudyColumnsEditForm, StudyEditForm, StudyNotificationParametersEditForm
from web.models import Study
from web.views import wrap_response
logger = logging.getLogger(__name__)
......@@ -18,9 +18,12 @@ def study_edit(request, study_id):
notifications_form = StudyNotificationParametersEditForm(request.POST, request.FILES,
instance=study.notification_parameters,
prefix="notifications")
if study_form.is_valid() and notifications_form.is_valid():
study_columns_form = StudyColumnsEditForm(request.POST, request.FILES, instance=study.columns,
prefix="columns")
if study_form.is_valid() and notifications_form.is_valid() and study_columns_form.is_valid():
study_form.save()
notifications_form.save()
study_columns_form.save()
messages.success(request, "Modifications saved")
if '_continue' in request.POST:
return redirect('web.views.edit_study', study_id=study.id)
......@@ -29,12 +32,13 @@ def study_edit(request, study_id):
messages.add_message(request, messages.ERROR, 'Invalid data. Please fix data and try again.')
else:
study_form = StudyEditForm(instance=study, prefix="study")
notifications_form = StudyNotificationParametersEditForm(instance=study.notification_parameters, prefix="notifications")
notifications_form = StudyNotificationParametersEditForm(instance=study.notification_parameters,
prefix="notifications")
study_columns_form = StudyColumnsEditForm(instance=study.columns,
prefix="columns")
return wrap_response(request, 'study/edit.html', {
'study_form': study_form,
'notifications_form': notifications_form,
# 'study_subject': study_subject,
# 'contact_attempts': contact_attempts,
# 'mail_templates': MailTemplate.get_subject_mail_templates(languages)
'study_columns_form': study_columns_form,
})
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment