From 61a574de77fbe9ab86c2561d29a1e2b357ba7d85 Mon Sep 17 00:00:00 2001 From: Carlos Vega <carlos.vega@uni.lu> Date: Tue, 6 Nov 2018 16:40:23 +0100 Subject: [PATCH] Fixes #264 Make number of visits to show in subject list customizable in study --- smash/web/api_views/subject.py | 2 +- ...30_study_visits_to_show_in_subject_list.py | 21 +++++++++++++++++++ smash/web/models/study.py | 7 +++++++ 3 files changed, 29 insertions(+), 1 deletion(-) create mode 100644 smash/web/migrations/0130_study_visits_to_show_in_subject_list.py diff --git a/smash/web/api_views/subject.py b/smash/web/api_views/subject.py index ab07fde9..6bf6bc78 100644 --- a/smash/web/api_views/subject.py +++ b/smash/web/api_views/subject.py @@ -71,7 +71,7 @@ def get_subject_columns(request, subject_list_type): add_column(result, "Info sent", "information_sent", study_subject_columns, "yes_no_filter", study.columns) add_column(result, "Type", "type", study_subject_columns, "type_filter", study.columns) add_column(result, "Edit", "edit", None, None, sortable=False) - for visit_number in range(1, 9): + for visit_number in range(1, study.visits_to_show_in_subject_list+1): visit_key = "visit_" + str(visit_number) add_column(result, "Visit " + str(visit_number), visit_key, None, "visit_filter", visible_param=study_subject_list.visits) diff --git a/smash/web/migrations/0130_study_visits_to_show_in_subject_list.py b/smash/web/migrations/0130_study_visits_to_show_in_subject_list.py new file mode 100644 index 00000000..071741cd --- /dev/null +++ b/smash/web/migrations/0130_study_visits_to_show_in_subject_list.py @@ -0,0 +1,21 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.11.5 on 2018-11-06 15:37 +from __future__ import unicode_literals + +import django.core.validators +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('web', '0129_auto_20181031_1348'), + ] + + operations = [ + migrations.AddField( + model_name='study', + name='visits_to_show_in_subject_list', + field=models.IntegerField(default=5, validators=[django.core.validators.MaxValueValidator(100), django.core.validators.MinValueValidator(1)], verbose_name=b'Number of visits to show in the subject list'), + ), + ] diff --git a/smash/web/models/study.py b/smash/web/models/study.py index c7b90db3..c8b2461e 100644 --- a/smash/web/models/study.py +++ b/smash/web/models/study.py @@ -2,6 +2,7 @@ from django.db import models from web.models import StudyColumns, StudyNotificationParameters +from django.core.validators import MaxValueValidator, MinValueValidator import re @@ -31,6 +32,12 @@ class Study(models.Model): verbose_name="Auto create follow up visit" ) + visits_to_show_in_subject_list = models.IntegerField( + verbose_name='Number of visits to show in the subject list', + default=5, + validators=[MaxValueValidator(100), MinValueValidator(1)] + ) + def check_nd_number(self, nd_number): regex = re.compile(self.nd_number_study_subject_regex) return regex.match(nd_number) is not None -- GitLab