Spaces:
Running
on
CPU Upgrade
Running
on
CPU Upgrade
Commit
•
2ade62d
1
Parent(s):
aa140fd
fix interventions filtering
Browse files
app.py
CHANGED
@@ -51,23 +51,23 @@ if auto_refresh:
|
|
51 |
|
52 |
|
53 |
# Streamlit functions
|
54 |
-
def display_interventions(interventions_df):
|
55 |
"""Display NGO interventions on the map"""
|
56 |
for index, row in interventions_df.iterrows():
|
57 |
village_status = row[interventions_df.columns[7]]
|
58 |
-
|
|
|
|
|
59 |
village_status = "Partiellement satisfait / Partially Served"
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
color_mk = "pink"
|
66 |
status = "Planned ⌛"
|
67 |
elif (
|
68 |
-
|
69 |
-
!= "Intervention prévue dans le futur / Planned future intervention"
|
70 |
-
and village_status
|
71 |
!= "Critique, Besoin d'aide en urgence / Critical, in urgent need of help"
|
72 |
):
|
73 |
# past intervention and village not in a critical condition
|
@@ -255,7 +255,7 @@ selected_options = []
|
|
255 |
st.markdown(
|
256 |
"👉 **Choose request type | Choissisez le type de demande | اختر نوع الطلب**"
|
257 |
)
|
258 |
-
col1, col2, col3, col4, col5 = st.columns([2,
|
259 |
cols = [col1, col2, col3, col4, col5]
|
260 |
|
261 |
for i, option in enumerate(options):
|
@@ -276,16 +276,11 @@ show_interventions = st.checkbox(
|
|
276 |
value=True,
|
277 |
)
|
278 |
|
279 |
-
# Categories of villages
|
280 |
st.markdown(
|
281 |
"👉 **State of villages visited by NGOs| Etat de villages visités par les ONGs | وضعية القرى التي زارتها الجمعيات**",
|
282 |
unsafe_allow_html=True,
|
283 |
)
|
284 |
-
|
285 |
-
|
286 |
-
# use checkboxes
|
287 |
col_1, col_2, col_3 = st.columns([1, 1, 1])
|
288 |
-
|
289 |
critical_villages = col_1.checkbox(
|
290 |
"🚨 Critical, in urgent need of help / وضع حرج، في حاجة عاجلة للمساعدة",
|
291 |
value=True,
|
@@ -298,9 +293,7 @@ fully_satisfied_villages = col_3.checkbox(
|
|
298 |
"✅ Fully served / تمت المساعدة بشكل كامل",
|
299 |
value=True,
|
300 |
)
|
301 |
-
|
302 |
selected_village_types = []
|
303 |
-
|
304 |
if critical_villages:
|
305 |
selected_village_types.append(
|
306 |
"🚨 Critical, in urgent need of help / وضع حرج، في حاجة عاجلة للمساعدة"
|
@@ -322,7 +315,7 @@ status_mapping = {
|
|
322 |
selected_statuses = [status_mapping[status] for status in selected_village_types]
|
323 |
|
324 |
if show_interventions:
|
325 |
-
display_interventions(interventions_df)
|
326 |
|
327 |
# Show requests
|
328 |
show_requests(filtered_df)
|
|
|
51 |
|
52 |
|
53 |
# Streamlit functions
|
54 |
+
def display_interventions(interventions_df, selected_statuses):
|
55 |
"""Display NGO interventions on the map"""
|
56 |
for index, row in interventions_df.iterrows():
|
57 |
village_status = row[interventions_df.columns[7]]
|
58 |
+
is_future_intervention = row[interventions_df.columns[5]] == "Intervention prévue dans le futur / Planned future intervention"
|
59 |
+
|
60 |
+
if pd.isna(village_status) and not is_future_intervention:
|
61 |
village_status = "Partiellement satisfait / Partially Served"
|
62 |
+
|
63 |
+
if village_status not in selected_statuses:
|
64 |
+
continue
|
65 |
+
|
66 |
+
if is_future_intervention:
|
67 |
color_mk = "pink"
|
68 |
status = "Planned ⌛"
|
69 |
elif (
|
70 |
+
village_status
|
|
|
|
|
71 |
!= "Critique, Besoin d'aide en urgence / Critical, in urgent need of help"
|
72 |
):
|
73 |
# past intervention and village not in a critical condition
|
|
|
255 |
st.markdown(
|
256 |
"👉 **Choose request type | Choissisez le type de demande | اختر نوع الطلب**"
|
257 |
)
|
258 |
+
col1, col2, col3, col4, col5 = st.columns([2, 4, 2, 3, 2])
|
259 |
cols = [col1, col2, col3, col4, col5]
|
260 |
|
261 |
for i, option in enumerate(options):
|
|
|
276 |
value=True,
|
277 |
)
|
278 |
|
|
|
279 |
st.markdown(
|
280 |
"👉 **State of villages visited by NGOs| Etat de villages visités par les ONGs | وضعية القرى التي زارتها الجمعيات**",
|
281 |
unsafe_allow_html=True,
|
282 |
)
|
|
|
|
|
|
|
283 |
col_1, col_2, col_3 = st.columns([1, 1, 1])
|
|
|
284 |
critical_villages = col_1.checkbox(
|
285 |
"🚨 Critical, in urgent need of help / وضع حرج، في حاجة عاجلة للمساعدة",
|
286 |
value=True,
|
|
|
293 |
"✅ Fully served / تمت المساعدة بشكل كامل",
|
294 |
value=True,
|
295 |
)
|
|
|
296 |
selected_village_types = []
|
|
|
297 |
if critical_villages:
|
298 |
selected_village_types.append(
|
299 |
"🚨 Critical, in urgent need of help / وضع حرج، في حاجة عاجلة للمساعدة"
|
|
|
315 |
selected_statuses = [status_mapping[status] for status in selected_village_types]
|
316 |
|
317 |
if show_interventions:
|
318 |
+
display_interventions(interventions_df, selected_statuses)
|
319 |
|
320 |
# Show requests
|
321 |
show_requests(filtered_df)
|