Tantalos / utils /event_participation.py
DrDomedag's picture
Fixed another set of bugs.
a0f6dae
import streamlit as st
from utils.allergens import *
from utils.variables import *
from utils.event_participation import *
def show_event_participation(user_id):
st.title("Event participation")
st.write("Welcome to the event!")
relevant_allergies = []
#st.write("The dish served at the event will contain the following ingredients:")
for ingredient in ingredient_list:
#found = False
#st.write(ingredient)
for allergen in user_list[user_id].keys():
if allergen == ingredient and not (ingredient_list[ingredient] and user_list[user_id][ingredient][1]):
relevant_allergies.append(ingredient)
break
#st.write(f"The dish will contain {ingredient}. You are allergic to {ingredient}.⚠️")
else:
for s in synonyms[ingredient]:
if s == allergen and not (ingredient_list[ingredient] and user_list[user_id][s][1]):
relevant_allergies.append(f"{ingredient} ({s})")
break
if len(relevant_allergies) == 0:
st.write("✅You can eat this dish!✅")
else:
st.write("⚠️You cannot eat this dish because it contains:")
for a in relevant_allergies:
st.write(a)
with st.expander("Show ingredients"):
st.write("**The dish served at the event will contain the following ingredients:**")
for ingredient in ingredient_list:
restriction = False
for allergen in user_list[user_id].keys():
if allergen == ingredient and not (ingredient_list[ingredient] and user_list[user_id][ingredient][1]):
restriction = True
break
else:
for s in synonyms[ingredient]:
if s in user_list[user_id].keys() and not (ingredient_list[ingredient] and user_list[user_id][s][1]):
restriction = True
break
if restriction:
st.write(f" :red[{ingredient}]{' (cooked)' if ingredient_list[ingredient] else ' (raw)'}")
else:
st.write(f"{ingredient} {' (cooked)' if ingredient_list[ingredient] else ' (raw)'}")
with st.expander("Show your dietary restrictions"):
st.write("**Your reported aversions are:**")
for allergen in user_list[user_id].keys():
st.write(allergen)