Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
scheduling-system
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
External wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
SMASCH
scheduling-system
Commits
defbeb6e
Commit
defbeb6e
authored
4 years ago
by
Piotr Gawron
Browse files
Options
Downloads
Patches
Plain Diff
don't persist data from frontend if the field is readonly
parent
4e2b9419
No related branches found
Branches containing commit
No related tags found
Tags containing commit
3 merge requests
!316
Merge 1.0.1
,
!315
1.0.1 into master
,
!310
Resolve "saving subject with custom date_field makes subject form unusable"
Pipeline
#38406
passed
4 years ago
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
CHANGELOG
+3
-0
3 additions, 0 deletions
CHANGELOG
smash/web/forms/study_subject_forms.py
+8
-6
8 additions, 6 deletions
smash/web/forms/study_subject_forms.py
with
11 additions
and
6 deletions
CHANGELOG
+
3
−
0
View file @
defbeb6e
smasch (1.0.1-1) stable; urgency=low
* bug fix: readonly custom Date Field was inproperly persisted in forms
(#383)
-- Piotr Gawron <piotr.gawron@uni.lu> Mon, 15 Mar 2021 14:00:00 +0200
smasch (1.0.0-1) stable; urgency=low
...
...
This diff is collapsed.
Click to expand it.
smash/web/forms/study_subject_forms.py
+
8
−
6
View file @
defbeb6e
...
...
@@ -7,8 +7,8 @@ from django.forms import ModelForm
from
web.forms.forms
import
DATETIMEPICKER_DATE_ATTRS
,
get_worker_from_args
,
DATEPICKER_DATE_ATTRS
from
web.models
import
StudySubject
,
Study
,
StudyColumns
,
VoucherType
,
Worker
from
web.models.constants
import
SCREENING_NUMBER_PREFIXES_FOR_TYPE
,
CUSTOM_FIELD_TYPE_TEXT
,
CUSTOM_FIELD_TYPE_BOOLEAN
,
\
CUSTOM_FIELD_TYPE_INTEGER
,
CUSTOM_FIELD_TYPE_DOUBLE
,
\
from
web.models.constants
import
SCREENING_NUMBER_PREFIXES_FOR_TYPE
,
CUSTOM_FIELD_TYPE_TEXT
,
\
CUSTOM_FIELD_TYPE_BOOLEAN
,
CUSTOM_FIELD_TYPE_INTEGER
,
CUSTOM_FIELD_TYPE_DOUBLE
,
\
CUSTOM_FIELD_TYPE_DATE
,
CUSTOM_FIELD_TYPE_SELECT_LIST
,
CUSTOM_FIELD_TYPE_FILE
from
web.models.custom_data
import
CustomStudySubjectField
,
CustomStudySubjectValue
from
web.models.custom_data.custom_study_subject_field
import
get_study_subject_field_id
...
...
@@ -158,8 +158,9 @@ class StudySubjectAddForm(StudySubjectForm):
instance
=
super
(
StudySubjectAddForm
,
self
).
save
(
commit
)
# we can add custom values only after object exists in the database
for
field_type
in
CustomStudySubjectField
.
objects
.
filter
(
study
=
self
.
study
):
self
.
instance
.
set_custom_data_value
(
field_type
,
get_study_subject_field_value
(
field_type
,
self
[
get_study_subject_field_id
(
field_type
)]))
if
not
field_type
.
readonly
:
self
.
instance
.
set_custom_data_value
(
field_type
,
get_study_subject_field_value
(
field_type
,
self
[
get_study_subject_field_id
(
field_type
)]))
return
instance
def
build_screening_number
(
self
,
cleaned_data
):
...
...
@@ -289,8 +290,9 @@ class StudySubjectEditForm(StudySubjectForm):
def
save
(
self
,
commit
=
True
)
->
StudySubject
:
for
field_type
in
CustomStudySubjectField
.
objects
.
filter
(
study
=
self
.
study
):
self
.
instance
.
set_custom_data_value
(
field_type
,
get_study_subject_field_value
(
field_type
,
self
[
get_study_subject_field_id
(
field_type
)]))
if
not
field_type
.
readonly
:
self
.
instance
.
set_custom_data_value
(
field_type
,
get_study_subject_field_value
(
field_type
,
self
[
get_study_subject_field_id
(
field_type
)]))
return
super
(
StudySubjectForm
,
self
).
save
(
commit
)
class
Meta
:
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment