Skip to content
Snippets Groups Projects
Commit fb58aa56 authored by fmk17's avatar fmk17
Browse files

Add indicator descriptions

parent a1bddd0e
No related branches found
No related tags found
No related merge requests found
......@@ -67,29 +67,50 @@ def format_user(user):
def format_location_days(location_days):
days, location, update_datetime = location_days
header = f"<b>RU {location.name}</b>"
used_indicators = set()
strings = []
strings.append(f"<b>RU {location.name}</b>")
if len(days):
body = "\n\n".join(
for day in days:
for menu in day.menus:
for item in menu.items:
used_indicators |= item.indicators
strings.append(
"\n\n".join(
f"<b>{day.date_raw}</b>\n"
+ "\n".join(
f" <b>{menu.meal_name}</b>\n"
+ "\n".join(
f"{item.name} "
+ "".join(indicator.emoji for indicator in item.indicators)
+ "".join(
indicator.emoji
for indicator in sorted(item.indicators)
)
for item in menu.items
)
for menu in day.menus
)
for day in days
)
)
else:
body = "<i>Cardápio indisponível</i>"
updated_on = (
strings.append("<i>Cardápio indisponível</i>")
if len(used_indicators):
strings.append(
"<b>Legenda:</b>\n"
+ "\n".join(
f"{indicator.emoji} · {indicator.description}"
for indicator in sorted(used_indicators)
)
)
strings.append(
"<i>Atualizado às "
+ update_datetime.strftime("%H:%M:%S")
+ " de hoje</i>"
)
return header + "\n\n" + body + "\n\n" + updated_on
return "\n\n".join(strings)
@dataclass
......
......@@ -37,24 +37,31 @@ WorkingWeekDay = [
class MenuItemIndicator(Enum):
VEGAN = ("🌱", "Indicado para veganos")
GLUTEN = ("🌾", "Não indicado para celíacos por conter glúten")
VEGAN = (1, "🌱", "Indicado para veganos")
GLUTEN = (2, "🌾", "Não indicado para celíacos por conter glúten")
LACTOSE = (
3,
"🥛",
"Não indicado para intolerantes à lactose por conter lactose",
)
ANIMAL = ("🥩", "Contém produtos de origem animal")
EGG = ("🥚", "Contém ovo")
HONEY = ("🍯", "Contém mel")
ALERGIC = ("⚠️", "Contém produto(s) alergênico(s)")
ANIMAL = (4, "🥩", "Contém produtos de origem animal")
EGG = (5, "🥚", "Contém ovo")
HONEY = (6, "🍯", "Contém mel")
ALERGIC = (7, "⚠️", "Contém produto(s) alergênico(s)")
def __new__(cls, emoji, description):
def __new__(cls, ordering, emoji, description):
obj = object.__new__(cls)
obj._value_ = (emoji, description)
obj.ordering = ordering
obj.emoji = emoji
obj.description = description
return obj
def __lt__(self, other):
if self.__class__ is other.__class__:
return self.ordering < other.ordering
return NotImplemented
@dataclass(frozen=True)
class MenuItem:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment