vancauwe commited on
Commit
a63231d
1 Parent(s): f1a6252

fix: new icons and bug fixes in validation

Browse files
app/assets/icons/balai-magique.png ADDED
app/assets/icons/correct.png ADDED
app/assets/icons/supprimer.png ADDED
app/credits.py CHANGED
@@ -49,4 +49,10 @@ schedule: <a href="https://www.flaticon.com/free-icons/follow-up" title="follow
49
 
50
  Effective: <a href="https://www.flaticon.com/free-icons/cog" title="cog icons">Cog icons created by monkik - Flaticon</a>
51
 
 
 
 
 
 
 
52
  """
 
49
 
50
  Effective: <a href="https://www.flaticon.com/free-icons/cog" title="cog icons">Cog icons created by monkik - Flaticon</a>
51
 
52
+ correct: <a href="https://www.flaticon.com/fr/icones-gratuites/termine" title="termin茅 ic么nes">Termin茅 ic么nes cr茅茅es par kliwir art - Flaticon</a>
53
+
54
+ supprimer: <a href="https://www.flaticon.com/fr/icones-gratuites/faux" title="faux ic么nes">Faux ic么nes cr茅茅es par hqrloveq - Flaticon</a>
55
+
56
+ balai-magique: <a href="https://www.flaticon.com/fr/icones-gratuites/la-magie" title="la magie ic么nes">La magie ic么nes cr茅茅es par Freepik - Flaticon</a>
57
+
58
  """
app/mode_advanced.py CHANGED
@@ -5,7 +5,8 @@ from geolocalisation.js_geolocation import js_geocode, display_location
5
  from validation_submission.utils_individual import generate_random_md5
6
  from validation_submission.utils_individual import add_data_to_individual
7
  from validation_submission.submission import validate_save_individual
8
- from validation_submission.validation import reset_error_box
 
9
  from geolocalisation.maps import get_location
10
  from functools import partial
11
  from dead import show_section_dead
@@ -354,10 +355,6 @@ with gr.Blocks(theme='shivi/calm_seafoam') as advanced:
354
  fe_name_recipient_dead.input(save_fe, inputs=[fe_name_recipient_dead, gr.Textbox("recipient name", visible=False), individual],outputs=[individual])
355
  fe_collection_ref_dead.input(save_fe, inputs=[fe_collection_ref_dead, gr.Textbox("collection reference", visible=False), individual], outputs=[individual])
356
 
357
- # ---------------------------------------------------------
358
- # Error Box
359
- error_box = gr.Text(value=None, visible=False)
360
-
361
  # ---------------------------------------------------------
362
  # Spacer
363
  with gr.Row(elem_id="centered-row"):
@@ -371,6 +368,14 @@ with gr.Blocks(theme='shivi/calm_seafoam') as advanced:
371
  justify-content: center;
372
  }
373
  """
 
 
 
 
 
 
 
 
374
 
375
 
376
  # ---------------------------------------------------------
@@ -400,7 +405,7 @@ with gr.Blocks(theme='shivi/calm_seafoam') as advanced:
400
  checkbox_beak_wounded, text_beak_wounded, checkbox_body_wounded, text_body_wounded, checkbox_feathers_wounded, text_feathers_wounded, checkbox_head_wounded, text_head_wounded, checkbox_legs_wounded, text_legs_wounded,
401
  fe_collection_dropdown_wounded, fe_recepient_dropdown_wounded, fe_radio_dropdown_wounded, fe_answer_dropdown_wounded,
402
  fe_name_recipient_wounded, fe_collection_ref_wounded,
403
- error_box
404
  ])
405
  show_creds = gr.Button("CREDITS", icon=PATH_ICONS+"copyright.png", scale=0.5)
406
 
@@ -408,19 +413,30 @@ with gr.Blocks(theme='shivi/calm_seafoam') as advanced:
408
  # Button Click Logic
409
  button_clear.click()
410
  button_clear.click(hide_physical,
411
- outputs=[checkbox_beak_wounded, text_beak_wounded, checkbox_body_wounded, text_body_wounded, checkbox_feathers_wounded, text_feathers_wounded, checkbox_head_wounded, text_head_wounded, checkbox_legs_wounded, text_legs_wounded])
 
 
 
 
 
412
  button_clear.click(hide_physical,
413
- outputs=[checkbox_beak_dead, text_beak_dead, checkbox_body_dead, text_body_dead, checkbox_feathers_dead, text_feathers_dead, checkbox_head_dead, text_head_dead, checkbox_legs_dead, text_legs_dead])
414
- button_clear.click(reset_error_box, inputs=[error_box], outputs=[error_box])
415
-
 
 
 
 
 
416
 
417
  # ---------------------------------------------------------
418
  # VALIDATE ANIMAL
419
  button_df.click(validate_save_individual,
420
  inputs=[individual,
 
421
  error_box,
422
  gr.Text(mode, visible=False)],
423
- outputs=[error_box])
424
  # ---------------------------------------------------------
425
  #CREDITS
426
  with Modal(visible=False) as modal_creds:
 
5
  from validation_submission.utils_individual import generate_random_md5
6
  from validation_submission.utils_individual import add_data_to_individual
7
  from validation_submission.submission import validate_save_individual
8
+ from validation_submission.validation import reset_error_box
9
+ from validation_submission.utils_individual import reset_individual
10
  from geolocalisation.maps import get_location
11
  from functools import partial
12
  from dead import show_section_dead
 
355
  fe_name_recipient_dead.input(save_fe, inputs=[fe_name_recipient_dead, gr.Textbox("recipient name", visible=False), individual],outputs=[individual])
356
  fe_collection_ref_dead.input(save_fe, inputs=[fe_collection_ref_dead, gr.Textbox("collection reference", visible=False), individual], outputs=[individual])
357
 
 
 
 
 
358
  # ---------------------------------------------------------
359
  # Spacer
360
  with gr.Row(elem_id="centered-row"):
 
368
  justify-content: center;
369
  }
370
  """
371
+
372
+ # ---------------------------------------------------------
373
+ # Error Box
374
+ with gr.Row():
375
+ error_icon = gr.Image(PATH_ICONS+"chicken.png",
376
+ height=80, width=80, visible=False,
377
+ scale=1)
378
+ error_box = gr.Text(value=None, visible=False, scale=3)
379
 
380
 
381
  # ---------------------------------------------------------
 
405
  checkbox_beak_wounded, text_beak_wounded, checkbox_body_wounded, text_body_wounded, checkbox_feathers_wounded, text_feathers_wounded, checkbox_head_wounded, text_head_wounded, checkbox_legs_wounded, text_legs_wounded,
406
  fe_collection_dropdown_wounded, fe_recepient_dropdown_wounded, fe_radio_dropdown_wounded, fe_answer_dropdown_wounded,
407
  fe_name_recipient_wounded, fe_collection_ref_wounded,
408
+ error_icon, error_box
409
  ])
410
  show_creds = gr.Button("CREDITS", icon=PATH_ICONS+"copyright.png", scale=0.5)
411
 
 
413
  # Button Click Logic
414
  button_clear.click()
415
  button_clear.click(hide_physical,
416
+ inputs =[gr.Text(mode, visible=False)],
417
+ outputs=[checkbox_beak_wounded, text_beak_wounded,
418
+ checkbox_body_wounded, text_body_wounded,
419
+ checkbox_feathers_wounded, text_feathers_wounded,
420
+ checkbox_head_wounded, text_head_wounded,
421
+ checkbox_legs_wounded, text_legs_wounded])
422
  button_clear.click(hide_physical,
423
+ inputs =[gr.Text(mode, visible=False)],
424
+ outputs=[checkbox_beak_dead, text_beak_dead,
425
+ checkbox_body_dead, text_body_dead,
426
+ checkbox_feathers_dead, text_feathers_dead,
427
+ checkbox_head_dead, text_head_dead,
428
+ checkbox_legs_dead, text_legs_dead])
429
+ button_clear.click(reset_error_box, inputs=[error_icon, error_box], outputs=[error_icon, error_box])
430
+ button_clear.click(reset_individual, inputs=[individual], outputs=[individual])
431
 
432
  # ---------------------------------------------------------
433
  # VALIDATE ANIMAL
434
  button_df.click(validate_save_individual,
435
  inputs=[individual,
436
+ error_icon,
437
  error_box,
438
  gr.Text(mode, visible=False)],
439
+ outputs=[individual, error_icon, error_box])
440
  # ---------------------------------------------------------
441
  #CREDITS
442
  with Modal(visible=False) as modal_creds:
app/mode_simple.py CHANGED
@@ -1,10 +1,12 @@
1
  import gradio as gr
2
  from gradio_modal import Modal
 
3
 
4
  from validation_submission.utils_individual import add_data_to_individual
5
  from validation_submission.submission import validate_save_individual
6
  from validation_submission.validation import reset_error_box
7
- from functools import partial
 
8
  from dead import show_section_dead
9
  from wounded import show_section_wounded
10
  from circumstances.circumstances import show_circumstances
@@ -15,6 +17,7 @@ from behavior.behavior_checkbox import show_behavior, on_select_behavior
15
  from follow_up.followup_events import save_fe
16
  from styling.style import *
17
  from credits import credits_text
 
18
 
19
  from geolocalisation.js_geolocation import js_geocode, display_location
20
  from validation_submission.utils_individual import generate_random_md5
@@ -356,10 +359,6 @@ with gr.Blocks(theme='shivi/calm_seafoam') as simple:
356
  fe_name_recipient_dead.input(save_fe, inputs=[fe_name_recipient_dead, gr.Textbox("recipient name", visible=False), individual],outputs=[individual])
357
  fe_collection_ref_dead.input(save_fe, inputs=[fe_collection_ref_dead, gr.Textbox("collection reference", visible=False), individual], outputs=[individual])
358
 
359
- # ---------------------------------------------------------
360
- # Error Box
361
- error_box = gr.Text(value=None, visible=False)
362
-
363
  # ---------------------------------------------------------
364
  # Spacer
365
  with gr.Row(elem_id="centered-row"):
@@ -374,6 +373,12 @@ with gr.Blocks(theme='shivi/calm_seafoam') as simple:
374
  }
375
  """
376
 
 
 
 
 
 
 
377
  # ---------------------------------------------------------
378
  # Allow clearing of all previous output
379
  with gr.Row():
@@ -381,7 +386,8 @@ with gr.Blocks(theme='shivi/calm_seafoam') as simple:
381
  scale = 3)
382
  button_clear = gr.ClearButton(value="CLEAR",
383
  scale = 1,
384
- components=[
 
385
  camera,
386
  #dead reset
387
  radio_circumstance_dead, radio_physical_dead,
@@ -400,7 +406,7 @@ with gr.Blocks(theme='shivi/calm_seafoam') as simple:
400
  checkbox_beak_wounded, text_beak_wounded, checkbox_body_wounded, text_body_wounded, checkbox_feathers_wounded, text_feathers_wounded, checkbox_head_wounded, text_head_wounded, checkbox_legs_wounded, text_legs_wounded,
401
  fe_collection_dropdown_wounded, fe_recepient_dropdown_wounded, fe_radio_dropdown_wounded, fe_answer_dropdown_wounded,
402
  fe_name_recipient_wounded, fe_collection_ref_wounded,
403
- error_box
404
  ])
405
  show_creds = gr.Button("CREDITS", icon=PATH_ICONS+"copyright.png", scale=0.5)
406
 
@@ -408,19 +414,30 @@ with gr.Blocks(theme='shivi/calm_seafoam') as simple:
408
  # Button Click Logic
409
  button_clear.click()
410
  button_clear.click(hide_physical,
411
- outputs=[checkbox_beak_wounded, text_beak_wounded, checkbox_body_wounded, text_body_wounded, checkbox_feathers_wounded, text_feathers_wounded, checkbox_head_wounded, text_head_wounded, checkbox_legs_wounded, text_legs_wounded])
 
 
 
 
 
412
  button_clear.click(hide_physical,
413
- outputs=[checkbox_beak_dead, text_beak_dead, checkbox_body_dead, text_body_dead, checkbox_feathers_dead, text_feathers_dead, checkbox_head_dead, text_head_dead, checkbox_legs_dead, text_legs_dead])
414
- button_clear.click(reset_error_box, inputs=[error_box], outputs=[error_box])
415
-
 
 
 
 
 
416
 
417
  # ---------------------------------------------------------
418
  # VALIDATE ANIMAL
419
  button_df.click(validate_save_individual,
420
  inputs=[individual,
 
421
  error_box,
422
  gr.Text(mode, visible=False)],
423
- outputs=[error_box])
424
  # ---------------------------------------------------------
425
  #CREDITS
426
  with Modal(visible=False) as modal_creds:
 
1
  import gradio as gr
2
  from gradio_modal import Modal
3
+ from functools import partial
4
 
5
  from validation_submission.utils_individual import add_data_to_individual
6
  from validation_submission.submission import validate_save_individual
7
  from validation_submission.validation import reset_error_box
8
+
9
+
10
  from dead import show_section_dead
11
  from wounded import show_section_wounded
12
  from circumstances.circumstances import show_circumstances
 
17
  from follow_up.followup_events import save_fe
18
  from styling.style import *
19
  from credits import credits_text
20
+ from validation_submission.utils_individual import reset_individual
21
 
22
  from geolocalisation.js_geolocation import js_geocode, display_location
23
  from validation_submission.utils_individual import generate_random_md5
 
359
  fe_name_recipient_dead.input(save_fe, inputs=[fe_name_recipient_dead, gr.Textbox("recipient name", visible=False), individual],outputs=[individual])
360
  fe_collection_ref_dead.input(save_fe, inputs=[fe_collection_ref_dead, gr.Textbox("collection reference", visible=False), individual], outputs=[individual])
361
 
 
 
 
 
362
  # ---------------------------------------------------------
363
  # Spacer
364
  with gr.Row(elem_id="centered-row"):
 
373
  }
374
  """
375
 
376
+ # ---------------------------------------------------------
377
+ # Error Box
378
+ with gr.Row():
379
+ error_icon = gr.Image(PATH_ICONS+"chicken.png", height=80, width=80, visible=False, scale=1)
380
+ error_box = gr.Text(value=None, visible=False, scale=4)
381
+
382
  # ---------------------------------------------------------
383
  # Allow clearing of all previous output
384
  with gr.Row():
 
386
  scale = 3)
387
  button_clear = gr.ClearButton(value="CLEAR",
388
  scale = 1,
389
+ icon = PATH_ICONS+"balai-magique.png",
390
+ components=[
391
  camera,
392
  #dead reset
393
  radio_circumstance_dead, radio_physical_dead,
 
406
  checkbox_beak_wounded, text_beak_wounded, checkbox_body_wounded, text_body_wounded, checkbox_feathers_wounded, text_feathers_wounded, checkbox_head_wounded, text_head_wounded, checkbox_legs_wounded, text_legs_wounded,
407
  fe_collection_dropdown_wounded, fe_recepient_dropdown_wounded, fe_radio_dropdown_wounded, fe_answer_dropdown_wounded,
408
  fe_name_recipient_wounded, fe_collection_ref_wounded,
409
+ error_icon, error_box
410
  ])
411
  show_creds = gr.Button("CREDITS", icon=PATH_ICONS+"copyright.png", scale=0.5)
412
 
 
414
  # Button Click Logic
415
  button_clear.click()
416
  button_clear.click(hide_physical,
417
+ inputs=[gr.Text(mode, visible=False)],
418
+ outputs=[checkbox_beak_wounded, text_beak_wounded,
419
+ checkbox_body_wounded, text_body_wounded,
420
+ checkbox_feathers_wounded, text_feathers_wounded,
421
+ checkbox_head_wounded, text_head_wounded,
422
+ checkbox_legs_wounded, text_legs_wounded])
423
  button_clear.click(hide_physical,
424
+ inputs=[gr.Text(mode, visible=False)],
425
+ outputs=[checkbox_beak_dead, text_beak_dead,
426
+ checkbox_body_dead, text_body_dead,
427
+ checkbox_feathers_dead, text_feathers_dead,
428
+ checkbox_head_dead, text_head_dead,
429
+ checkbox_legs_dead, text_legs_dead])
430
+ button_clear.click(reset_error_box, inputs=[error_icon, error_box], outputs=[error_icon, error_box])
431
+ button_clear.click(reset_individual, inputs=[individual], outputs=[individual])
432
 
433
  # ---------------------------------------------------------
434
  # VALIDATE ANIMAL
435
  button_df.click(validate_save_individual,
436
  inputs=[individual,
437
+ error_icon,
438
  error_box,
439
  gr.Text(mode, visible=False)],
440
+ outputs=[individual, error_icon, error_box])
441
  # ---------------------------------------------------------
442
  #CREDITS
443
  with Modal(visible=False) as modal_creds:
app/physical/physical_checkbox.py CHANGED
@@ -5,13 +5,8 @@ from validation_submission.utils_individual import add_data_to_individual
5
 
6
 
7
  # ---------------------------------------------------------
8
- def get_body_parts(mode):
9
- if mode == "simple":
10
- dropdown_config = get_custom_config_dropdowns(
11
- "config_checkbox_physical_simple.json"
12
- )
13
- elif mode == "advanced":
14
- dropdown_config = get_custom_config_dropdowns("config_checkbox_physical.json")
15
  return list(dropdown_config.keys())
16
 
17
 
@@ -89,7 +84,7 @@ def create_checkbox_legs(section, mode, label_checkbox, visible):
89
  # ---------------------------------------------------------
90
  def process_body_parts(section, mode, matched_box):
91
  # take all except "Common"
92
- body_parts = get_body_parts(mode)
93
  body_parts = body_parts[1:]
94
  label_checkbox = "Physical changes to "
95
  visibles = [True if matched_box == body_part else False for body_part in body_parts]
 
5
 
6
 
7
  # ---------------------------------------------------------
8
+ def get_body_parts():
9
+ dropdown_config = get_custom_config_dropdowns("config_checkbox_physical.json")
 
 
 
 
 
10
  return list(dropdown_config.keys())
11
 
12
 
 
84
  # ---------------------------------------------------------
85
  def process_body_parts(section, mode, matched_box):
86
  # take all except "Common"
87
+ body_parts = get_body_parts()
88
  body_parts = body_parts[1:]
89
  label_checkbox = "Physical changes to "
90
  visibles = [True if matched_box == body_part else False for body_part in body_parts]
app/styling/theme.py CHANGED
@@ -1,7 +1,13 @@
1
- import gradio as gr
 
 
 
 
 
 
 
2
 
3
- css= ""
4
- css_old = """
5
  .gradio-container {background: url(https://openclipart.org/image/2000px/279687)}
6
 
7
  /* Main background */
@@ -84,22 +90,3 @@ body {
84
  #error {background-color: #e82323}
85
  #valid {background-color: #07e63f}
86
  """
87
-
88
- # OLD THEME:
89
-
90
- # css = """
91
- # .gradio-container {background: url(https://openclipart.org/image/2000px/279687)}
92
- # #image {background-color: #73b9ae}
93
- # #dead {background-color: #333333}
94
- # #wounded {background-color: #5e0724}
95
- # #bird-boxes {background-color: #f2f3f3}
96
- # #buttons-conditions {background-color: #b3b3b3}
97
- # #dropdown-conditions {background-color: #b3b3b3}
98
- # #followup {background-color: #38241c}
99
- # #submit {background-color: #abb2bf}
100
- # #error {background-color: #e82323}
101
- # #valid {background-color: #07e63f}
102
- # """
103
-
104
- # theme = gr.themes.Soft(primary_hue="teal", secondary_hue="teal", neutral_hue="emerald",
105
- # font=[gr.themes.GoogleFont("Inconsolata"), "Arial", "sans-serif"])
 
1
+ css_for_error_box= """
2
+ #error {background-color: #e82323 !important;
3
+ color: white !important;
4
+ font-weight: bold;}
5
+ #valid {background-color: #07e63f !important;
6
+ color: white !important;
7
+ font-weight: bold;}
8
+ """
9
 
10
+ css_alternative = """
 
11
  .gradio-container {background: url(https://openclipart.org/image/2000px/279687)}
12
 
13
  /* Main background */
 
90
  #error {background-color: #e82323}
91
  #valid {background-color: #07e63f}
92
  """
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/validation_submission/processing.py CHANGED
@@ -1,45 +1,61 @@
1
  #### PROCESS FUNCTIONS
2
 
3
  def process_circumstance(data):
4
-
5
  fields_to_check = ["option_dropdown", "open_field", "extra"]
6
- if data["circumstance_radio"] == "Yes":
 
 
 
 
7
  for field in fields_to_check:
8
- if data["circumstance_type"][field+"_label"] == "NA":
9
- data["circumstance_type"].pop(field+"_label")
10
- else :
11
  val = data[f"circumstance_{field}"]
12
  key = data["circumstance_type"][field+"_label"]
13
- data["circumstance_type"][key] = val
14
- data["circumstance_type"].pop(field+"_label")
15
- return data
 
 
 
 
 
16
 
17
  def process_behaviors(data):
18
  behaviors =[]
19
- if data["behaviors_radio"] == "Yes":
 
 
20
  for type in data["behaviors_type"]:
21
  new_behavior = {}
22
  new_behavior["type"] = type
23
  behaviors.append(new_behavior)
24
- data["behaviors_type"] = behaviors
25
- return data
 
 
 
26
 
27
  def process_physical(data):
28
  body_parts= ["beak", "body", "legs", "feathers/wings/tail", "head incl. eyes"]
 
29
  anomalies=[]
30
  reformatted = {}
31
- reformatted["physical_radio"] = data["physical_radio"]
32
- if data["physical_radio"] == "Yes":
33
- for body_part in body_parts:
34
  anomaly = {}
35
  for key, val in data.items():
36
  if "type_"+ body_part in key:
37
- anomaly["type"] = body_part
38
  elif "anomaly_"+ body_part in key:
39
  anomaly["anomaly_type"] = val
40
  if anomaly:
41
  anomalies.append(anomaly)
42
  reformatted["physical_anomalies_type"] = anomalies
 
 
 
43
  return reformatted
44
 
45
  def process_followup(data):
 
1
  #### PROCESS FUNCTIONS
2
 
3
  def process_circumstance(data):
4
+ print(data)
5
  fields_to_check = ["option_dropdown", "open_field", "extra"]
6
+ reformatted ={}
7
+ if ("circumstance_radio" in data.keys()) and ("circumstance" in data.keys()) and ("circumstance_type" in data.keys()) and (data["circumstance_radio"] == "Yes"):
8
+ reformatted["circumstance_radio"] = data["circumstance_radio"]
9
+ reformatted["circumstance"] = data["circumstance"]
10
+ reformatted["circumstance_type"] = {}
11
  for field in fields_to_check:
12
+ if not data["circumstance_type"][field+"_label"] == "NA":
 
 
13
  val = data[f"circumstance_{field}"]
14
  key = data["circumstance_type"][field+"_label"]
15
+ print("TYPE: ", key)
16
+ reformatted["circumstance_type"][key] = val
17
+ else:
18
+ reformatted["circumstance_radio"] = None
19
+ reformatted["circumstance"] = None
20
+ reformatted["circumstance_type"] = {}
21
+ print (reformatted)
22
+ return reformatted
23
 
24
  def process_behaviors(data):
25
  behaviors =[]
26
+ reformatted = {}
27
+ if ("behaviors_radio" in data.keys()) and ("behaviors_type" in data.keys()) and (data["behaviors_radio"] == "Yes"):
28
+ reformatted["behaviors_radio"] = data["behaviors_radio"]
29
  for type in data["behaviors_type"]:
30
  new_behavior = {}
31
  new_behavior["type"] = type
32
  behaviors.append(new_behavior)
33
+ reformatted["behaviors_type"] = behaviors
34
+ else:
35
+ reformatted["behaviors_radio"] = None
36
+ reformatted["behaviors_type"] = []
37
+ return reformatted
38
 
39
  def process_physical(data):
40
  body_parts= ["beak", "body", "legs", "feathers/wings/tail", "head incl. eyes"]
41
+ body_parts_search = ["beak", "body", "legs", "feathers", "head"]
42
  anomalies=[]
43
  reformatted = {}
44
+ if ("physical_radio" in data.keys()) and (data["physical_radio"] == "Yes") and any("type_" in key for key in data.keys()) and any("anomaly_" in key for key in data.keys()):
45
+ reformatted["physical_radio"] = data["physical_radio"]
46
+ for b, body_part in enumerate(body_parts_search):
47
  anomaly = {}
48
  for key, val in data.items():
49
  if "type_"+ body_part in key:
50
+ anomaly["type"] = body_parts[b]
51
  elif "anomaly_"+ body_part in key:
52
  anomaly["anomaly_type"] = val
53
  if anomaly:
54
  anomalies.append(anomaly)
55
  reformatted["physical_anomalies_type"] = anomalies
56
+ else:
57
+ reformatted["physical_radio"] = None
58
+ reformatted["physical_anomalies_type"] = []
59
  return reformatted
60
 
61
  def process_followup(data):
app/validation_submission/submission.py CHANGED
@@ -1,15 +1,16 @@
1
  import json
2
  from validation_submission.validation import validate_individual
3
-
4
  from huggingface_hub import HfApi
5
  import os
6
 
7
 
8
- def validate_save_individual(data, error_box, mode):
9
- individual, error_box = validate_individual(data, error_box, mode)
10
  if individual:
 
11
  push_to_dataset_hf(individual.model_dump())
12
- return error_box
13
 
14
 
15
  def push_to_dataset_hf(individual):
 
1
  import json
2
  from validation_submission.validation import validate_individual
3
+ import gradio as gr
4
  from huggingface_hub import HfApi
5
  import os
6
 
7
 
8
+ def validate_save_individual(data, error_icon, error_box, mode):
9
+ individual, error_icon, error_box = validate_individual(data, error_icon, error_box, mode)
10
  if individual:
11
+ print("pushing to hugging face")
12
  push_to_dataset_hf(individual.model_dump())
13
+ return individual, error_icon, error_box
14
 
15
 
16
  def push_to_dataset_hf(individual):
app/validation_submission/utils_individual.py CHANGED
@@ -1,6 +1,7 @@
1
  import random
2
  import string
3
  import hashlib
 
4
 
5
  def generate_random_md5():
6
  # Generate a random string
@@ -12,4 +13,8 @@ def generate_random_md5():
12
  def add_data_to_individual(key, value, individual):
13
  individual[key] = value
14
  return individual
 
 
 
 
15
 
 
1
  import random
2
  import string
3
  import hashlib
4
+ import gradio as gr
5
 
6
  def generate_random_md5():
7
  # Generate a random string
 
13
  def add_data_to_individual(key, value, individual):
14
  individual[key] = value
15
  return individual
16
+
17
+ def reset_individual(individual):
18
+ individual = gr.State({})
19
+ return individual
20
 
app/validation_submission/validation.py CHANGED
@@ -17,6 +17,13 @@ from validation_submission.processing import (
17
  process_followup,
18
  )
19
 
 
 
 
 
 
 
 
20
 
21
  def get_fields(data_dict, keyword):
22
  extract = {}
@@ -26,8 +33,8 @@ def get_fields(data_dict, keyword):
26
  return extract
27
 
28
 
29
- def validate_individual(data, error_box, mode: str):
30
- error_box = reset_error_box(error_box)
31
  # data = get_json_one_individual() # TODO: This should change
32
  data["identifier"] = str(uuid.uuid4())
33
  if "image" in data.keys():
@@ -48,14 +55,12 @@ def validate_individual(data, error_box, mode: str):
48
  data["wounded_state"] = "No"
49
  data["dead_state"] = "No"
50
  if (data["wounded_state"] == "Yes") or (data["dead_state"] == "Yes"):
51
- data_wounded_dead = data # get_json_tmp("wounded_dead")
52
- # print(f"Data Wounded Dead: {data_wounded_dead}")
53
  circumstance, error_circumstance = validate_circumstance(data_wounded_dead)
54
  physical, error_physical = validate_physical(data_wounded_dead, mode)
55
  followup, error_followup = validate_follow_up(data_wounded_dead)
56
 
57
  if data["wounded_state"] == "Yes":
58
- # print(f"Physical: {physical}")
59
  behavior, error_behavior = validate_behavior(data_wounded_dead, mode)
60
  try:
61
  individual = Report(
@@ -116,6 +121,11 @@ def validate_individual(data, error_box, mode: str):
116
  or error_physical
117
  or error_individual
118
  ):
 
 
 
 
 
119
  error_box = show_error(
120
  error_box,
121
  error_behavior,
@@ -126,13 +136,18 @@ def validate_individual(data, error_box, mode: str):
126
  )
127
  individual = None
128
  else:
 
 
 
 
 
129
  error_box = gr.Text(
130
  label="ALL VALID.",
131
- value="Record Registered. You can return to the Display.",
132
  visible=True,
133
  elem_id="valid",
134
  )
135
- return individual, error_box
136
 
137
 
138
  def show_error(
@@ -161,9 +176,10 @@ def show_error(
161
  return error_box
162
 
163
 
164
- def reset_error_box(error_box):
 
165
  error_box = gr.Text(value=None, visible=False)
166
- return error_box
167
 
168
 
169
  #### VALIDATION FUNCTIONS
 
17
  process_followup,
18
  )
19
 
20
+ from dotenv import load_dotenv
21
+ import os
22
+ load_dotenv()
23
+ PATH = os.getcwd() + "/"
24
+ PATH_ASSETS = os.getenv('PATH_ASSETS')
25
+ PATH_ICONS = PATH + PATH_ASSETS + "icons/"
26
+
27
 
28
  def get_fields(data_dict, keyword):
29
  extract = {}
 
33
  return extract
34
 
35
 
36
+ def validate_individual(data, error_icon, error_box, mode: str):
37
+ error_icon, error_box = reset_error_box(error_icon, error_box)
38
  # data = get_json_one_individual() # TODO: This should change
39
  data["identifier"] = str(uuid.uuid4())
40
  if "image" in data.keys():
 
55
  data["wounded_state"] = "No"
56
  data["dead_state"] = "No"
57
  if (data["wounded_state"] == "Yes") or (data["dead_state"] == "Yes"):
58
+ data_wounded_dead = data
 
59
  circumstance, error_circumstance = validate_circumstance(data_wounded_dead)
60
  physical, error_physical = validate_physical(data_wounded_dead, mode)
61
  followup, error_followup = validate_follow_up(data_wounded_dead)
62
 
63
  if data["wounded_state"] == "Yes":
 
64
  behavior, error_behavior = validate_behavior(data_wounded_dead, mode)
65
  try:
66
  individual = Report(
 
121
  or error_physical
122
  or error_individual
123
  ):
124
+ error_icon = gr.Image(PATH_ICONS+"supprimer.png", height=80, width=80,
125
+ interactive=False,
126
+ show_fullscreen_button = False, show_share_button=False,
127
+ show_download_button=False, show_label=False,
128
+ visible=True)
129
  error_box = show_error(
130
  error_box,
131
  error_behavior,
 
136
  )
137
  individual = None
138
  else:
139
+ error_icon = gr.Image(PATH_ICONS+"correct.png", height=80, width=80,
140
+ interactive=False,
141
+ show_fullscreen_button = False, show_share_button=False,
142
+ show_download_button=False, show_label=False,
143
+ visible=True)
144
  error_box = gr.Text(
145
  label="ALL VALID.",
146
+ value="Record Registered. Remember to press the CLEAR button before submitting a new record.",
147
  visible=True,
148
  elem_id="valid",
149
  )
150
+ return individual, error_icon, error_box
151
 
152
 
153
  def show_error(
 
176
  return error_box
177
 
178
 
179
+ def reset_error_box(error_icon, error_box):
180
+ error_icon = gr.Image(PATH_ICONS+"supprimer.png", height=80, width=80, visible=False)
181
  error_box = gr.Text(value=None, visible=False)
182
+ return error_icon, error_box
183
 
184
 
185
  #### VALIDATION FUNCTIONS