loubnabnl HF staff commited on
Commit
8cfd7ce
1 Parent(s): 6fb458c

use checkboxes instead

Browse files
Files changed (1) hide show
  1. app.py +48 -25
app.py CHANGED
@@ -55,36 +55,33 @@ def display_interventions(interventions_df, m):
55
  """Display NGO interventions on the map"""
56
  for index, row in interventions_df.iterrows():
57
  village_status = row[interventions_df.columns[7]]
58
- status = (
59
- "Done ✅"
60
- if row[interventions_df.columns[5]]
61
- != "Intervention prévue dans le futur / Planned future intervention"
62
- and village_status
63
- != "Critique, Besoin d'aide en urgence / Critical, in urgent need of help"
64
- else "Planned ⌛"
65
- )
66
  if (
67
  row[interventions_df.columns[5]]
68
- != "Intervention prévue dans le futur / Planned future intervention"
69
- and village_status
70
- != "Critique, Besoin d'aide en urgence / Critical, in urgent need of help"
71
  ):
72
- color_mk = "green"
 
 
73
  elif (
74
  row[interventions_df.columns[5]]
75
  != "Intervention prévue dans le futur / Planned future intervention"
76
  and village_status
77
- == "Critique, Besoin d'aide en urgence / Critical, in urgent need of help"
78
  ):
79
- color_mk = "darkgreen"
 
 
 
80
  else:
81
- color_mk = "pink"
 
82
 
83
  intervention_type = row[interventions_df.columns[6]].split("/")[0].strip()
84
  org = row[interventions_df.columns[1]]
85
  city = row[interventions_df.columns[9]]
86
  date = row[interventions_df.columns[4]]
87
- intervention_info = f"<b>Intervention Status:</b> {status}<br><b>Village Status:</b> {village_status.split('/')[0]}<br><b>Org:</b> {org}<br><b>Intervention:</b> {intervention_type}<br><b>📅 Date:</b> {date}"
 
88
  if row["latlng"] is None:
89
  continue
90
  folium.Marker(
@@ -270,20 +267,46 @@ show_interventions = st.checkbox(
270
  # Categories of villages
271
 
272
  st.markdown(
273
- "<br>👉 **State of villages visited by NGOs| Etat de villages visités par les ONGs | اختر نوع القرى التي زارتها الجمعيات**",
274
  unsafe_allow_html=True,
275
  )
276
 
277
- village_types = ["Critique", "Partiellement satisfait", "Entièrement satisfait "]
278
- selected_village_types = st.multiselect(
279
- " ",
280
- village_types,
281
- default=village_types,
 
 
 
 
 
 
 
 
 
 
282
  )
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
283
  status_mapping = {
284
- "Critique": "Critique, Besoin d'aide en urgence / Critical, in urgent need of help",
285
- "Partiellement satisfait": "Partiellement satisfait / Partially Served",
286
- "Entièrement satisfait ": "Entièrement satisfait / Fully served",
287
  }
288
  selected_statuses = [status_mapping[status] for status in selected_village_types]
289
 
 
55
  """Display NGO interventions on the map"""
56
  for index, row in interventions_df.iterrows():
57
  village_status = row[interventions_df.columns[7]]
 
 
 
 
 
 
 
 
58
  if (
59
  row[interventions_df.columns[5]]
60
+ == "Intervention prévue dans le futur / Planned future intervention"
 
 
61
  ):
62
+ # future intervention
63
+ color_mk = "pink"
64
+ status = "Planned ⌛"
65
  elif (
66
  row[interventions_df.columns[5]]
67
  != "Intervention prévue dans le futur / Planned future intervention"
68
  and village_status
69
+ != "Critique, Besoin d'aide en urgence / Critical, in urgent need of help"
70
  ):
71
+ # past intervention and village not in a critical condition
72
+ color_mk = "green"
73
+ status = "Done ✅"
74
+
75
  else:
76
+ color_mk = "darkgreen"
77
+ status = "Partial ⚠️"
78
 
79
  intervention_type = row[interventions_df.columns[6]].split("/")[0].strip()
80
  org = row[interventions_df.columns[1]]
81
  city = row[interventions_df.columns[9]]
82
  date = row[interventions_df.columns[4]]
83
+ population = row[interventions_df.columns[11]]
84
+ intervention_info = f"<b>Intervention Status:</b> {status}<br><b>Village Status:</b> {village_status.split('/')[0]}<br><b>Org:</b> {org}<br><b>Intervention:</b> {intervention_type}<br><b>Population:</b> {population}<br><b>📅 Date:</b> {date}"
85
  if row["latlng"] is None:
86
  continue
87
  folium.Marker(
 
267
  # Categories of villages
268
 
269
  st.markdown(
270
+ "👉 **State of villages visited by NGOs| Etat de villages visités par les ONGs | اختر نوع القرى التي زارتها الجمعيات**",
271
  unsafe_allow_html=True,
272
  )
273
 
274
+
275
+ # use checkboxes
276
+ col_1, col_2, col_3 = st.columns([1, 1, 1])
277
+
278
+ critical_villages = col_1.checkbox(
279
+ "🚨 Critical, in urgent need of help / وضع حرج، في حاجة عاجلة للمساعدة",
280
+ value=True,
281
+ )
282
+ partially_satisfied_villages = col_2.checkbox(
283
+ "⚠️ Partially served / مساعدة جزئية، بحاجة للمزيد من التدخلات",
284
+ value=True,
285
+ )
286
+ fully_satisfied_villages = col_3.checkbox(
287
+ "✅ Fully served / تمت المساعدة بشكل كامل",
288
+ value=True,
289
  )
290
+
291
+ selected_village_types = []
292
+
293
+ if critical_villages:
294
+ selected_village_types.append(
295
+ "🚨 Critical, in urgent need of help / وضع حرج، في حاجة عاجلة للمساعدة"
296
+ )
297
+
298
+ if partially_satisfied_villages:
299
+ selected_village_types.append(
300
+ "⚠️ Partially served / مساعدة جزئية، بحاجة للمزيد من التدخلات"
301
+ )
302
+
303
+ if fully_satisfied_villages:
304
+ selected_village_types.append("✅ Fully served / تمت المساعدة بشكل كامل")
305
+
306
  status_mapping = {
307
+ "🚨 Critical, in urgent need of help / وضع حرج، في حاجة عاجلة للمساعدة": "Critique, Besoin d'aide en urgence / Critical, in urgent need of help",
308
+ "⚠️ Partially served / مساعدة جزئية، بحاجة للمزيد من التدخلات": "Partiellement satisfait / Partially Served",
309
+ " Fully served / تمت المساعدة بشكل كامل": "Entièrement satisfait / Fully served",
310
  }
311
  selected_statuses = [status_mapping[status] for status in selected_village_types]
312