Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -269,6 +269,11 @@ def display_image(image_path):
|
|
| 269 |
img = Image.open(f)
|
| 270 |
st.image(img, caption='', use_column_width=True)
|
| 271 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 272 |
SPEAKER_RE = re.compile(r'^\s*\*\*(T|P):\*\*\s*(.*)$')
|
| 273 |
|
| 274 |
def read_md(path: str) -> str:
|
|
@@ -589,8 +594,13 @@ def show_field(f: Field, index: int, data_collected):
|
|
| 589 |
key = f.name + str(index)
|
| 590 |
# track the logical field name once per page; prep_and_save_data relies on this
|
| 591 |
st.session_state.data_inputs_keys.append(f.name)
|
| 592 |
-
|
| 593 |
-
(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 594 |
if not SHOW_HELP_ICON:
|
| 595 |
f.title = f'**{f.title}**\n\n{f.help}' if f.help else f.title
|
| 596 |
|
|
@@ -601,7 +611,8 @@ def show_field(f: Field, index: int, data_collected):
|
|
| 601 |
if f.following_mandatory_values and st.session_state[key] in f.following_mandatory_values:
|
| 602 |
st.session_state.following_mandatory = True
|
| 603 |
if f.mandatory or st.session_state.following_mandatory:
|
| 604 |
-
if
|
|
|
|
| 605 |
st.session_state.valid = False
|
| 606 |
validation_error = True
|
| 607 |
elif f.following_mandatory_values and st.session_state[key] in f.following_mandatory_values:
|
|
|
|
| 269 |
img = Image.open(f)
|
| 270 |
st.image(img, caption='', use_column_width=True)
|
| 271 |
|
| 272 |
+
def _ensure_key(key: str, default):
|
| 273 |
+
if key not in st.session_state:
|
| 274 |
+
st.session_state[key] = default
|
| 275 |
+
return st.session_state[key]
|
| 276 |
+
|
| 277 |
SPEAKER_RE = re.compile(r'^\s*\*\*(T|P):\*\*\s*(.*)$')
|
| 278 |
|
| 279 |
def read_md(path: str) -> str:
|
|
|
|
| 594 |
key = f.name + str(index)
|
| 595 |
# track the logical field name once per page; prep_and_save_data relies on this
|
| 596 |
st.session_state.data_inputs_keys.append(f.name)
|
| 597 |
+
default_val = (
|
| 598 |
+
data_collected.get(f.name, INPUT_FIELD_DEFAULT_VALUES[f.type])
|
| 599 |
+
if data_collected else INPUT_FIELD_DEFAULT_VALUES[f.type]
|
| 600 |
+
)
|
| 601 |
+
value = _ensure_key(key, default_val)
|
| 602 |
+
#value = st.session_state[key] if key in st.session_state else \
|
| 603 |
+
# (data_collected[f.name] if data_collected else INPUT_FIELD_DEFAULT_VALUES[f.type])
|
| 604 |
if not SHOW_HELP_ICON:
|
| 605 |
f.title = f'**{f.title}**\n\n{f.help}' if f.help else f.title
|
| 606 |
|
|
|
|
| 611 |
if f.following_mandatory_values and st.session_state[key] in f.following_mandatory_values:
|
| 612 |
st.session_state.following_mandatory = True
|
| 613 |
if f.mandatory or st.session_state.following_mandatory:
|
| 614 |
+
if value == INPUT_FIELD_DEFAULT_VALUES[f.type]:
|
| 615 |
+
#if st.session_state[key] == INPUT_FIELD_DEFAULT_VALUES[f.type]:
|
| 616 |
st.session_state.valid = False
|
| 617 |
validation_error = True
|
| 618 |
elif f.following_mandatory_values and st.session_state[key] in f.following_mandatory_values:
|