From d5b2decd89d8b9909f966a264474c20a2ff9fb31 Mon Sep 17 00:00:00 2001 From: Dan Funk Date: Mon, 30 Mar 2020 09:34:42 -0400 Subject: [PATCH] Fixing a bug that prevented editing existing studies. --- app.py | 6 ++++-- forms.py | 3 ++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/app.py b/app.py index 745930e..3a1b7fd 100644 --- a/app.py +++ b/app.py @@ -193,8 +193,10 @@ def _update_study(study, form): # quick hack to get auto-increment without creating a bunch of hassle, this is not # production code by any stretch of the imagination, but this is a throw away library. max_id = db.session.query(func.max(Study.STUDYID)).scalar() or 1 - - study.STUDYID = max_id + 1 + if not form.STUDYID.data: + study.STUDYID = max_id + 1 + else: + study.STUDYID = form.STUDYID.data study.TITLE = form.TITLE.data study.NETBADGEID = form.NETBADGEID.data study.DATE_MODIFIED = datetime.datetime.now() diff --git a/forms.py b/forms.py index 2e2bf60..0b8e7f6 100644 --- a/forms.py +++ b/forms.py @@ -3,13 +3,14 @@ import sys from flask_table import Table, Col, DateCol, LinkCol, BoolCol, DatetimeCol, NestedTableCol from flask_wtf import FlaskForm from wtforms import SelectMultipleField, SubmitField, StringField, IntegerField, BooleanField, DateField, widgets, \ - SelectField, validators + SelectField, validators, HiddenField from wtforms_alchemy import ModelForm from models import RequiredDocument, Investigator, StudyDetails class StudyForm(FlaskForm): + STUDYID = HiddenField() TITLE = StringField('Title', [validators.required()]) NETBADGEID = StringField('User UVA Computing Id', [validators.required()]) requirements = SelectMultipleField("Requirements",