NOJIRA final touches

This commit is contained in:
2021-09-15 17:14:34 +02:00
parent 5a9a6658ab
commit 8c6078d625
5 changed files with 24 additions and 13 deletions

View File

@@ -8,9 +8,8 @@ from repository import Repository
def process(_) -> str: def process(_) -> str:
global _repository
data = _get_data() data = _get_data()
return render_template('frietlijst.html', dto=data) return render_template('frietlijst.html', data=data)
def anonymize_name(name: str) -> str: def anonymize_name(name: str) -> str:
@@ -22,7 +21,7 @@ def anonymize_name(name: str) -> str:
return result return result
@cached(cache=TTLCache(maxsize=2, ttl=10)) @cached(cache=TTLCache(maxsize=1, ttl=10))
def _get_data() -> DTO: def _get_data() -> DTO:
cutoff = datetime.datetime.now() - datetime.timedelta(days=4) cutoff = datetime.datetime.now() - datetime.timedelta(days=4)

View File

@@ -10,7 +10,10 @@ class DTO:
self.__items: Dict[str, int] = {} self.__items: Dict[str, int] = {}
self.__orders: List[Order] = [] self.__orders: List[Order] = []
def add(self, applicant_name: str, item_names: List[str]): def add(self,
applicant_name: str,
item_names: List[str]
) -> None:
self.__applicants.append(applicant_name) self.__applicants.append(applicant_name)
for item_name in item_names: for item_name in item_names:

View File

@@ -1,11 +1,15 @@
class Item: class Item:
def __init__(self, name: str, amount: int): def __init__(self,
name: str,
amount: int):
assert name == name.lower() assert name == name.lower()
self.name = name self.name = name
self.amount = amount self.amount = amount
self.__contains_fries = 'friet' in self.name or 'twister' in self.name self.__contains_fries = 'friet' in self.name or 'twister' in self.name
def __lt__(self: "Item", other: "Item") -> bool: def __lt__(self: "Item",
other: "Item"
) -> bool:
if self.__contains_fries and not other.__contains_fries: if self.__contains_fries and not other.__contains_fries:
return True return True
if not self.__contains_fries and other.__contains_fries: if not self.__contains_fries and other.__contains_fries:

View File

@@ -2,9 +2,13 @@ from typing import List
class Order: class Order:
def __init__(self, name: str, items: List[str]): def __init__(self,
name: str,
items: List[str]):
self.name = name self.name = name
self.items = items self.items = items
def __lt__(self: "Order", other: "Order") -> bool: def __lt__(self: "Order",
other: "Order"
) -> bool:
return self.name < other.name return self.name < other.name

View File

@@ -8,20 +8,20 @@
<div class="markdown-body"> <div class="markdown-body">
<h1>Reeds besteld</h1> <h1>Reeds besteld</h1>
<ol> <ol>
{% for applicant in dto.applicants %} {% for applicant in data.applicants %}
<li>{{ applicant }}</li> <li>{{ applicant }}</li>
{% endfor %} {% endfor %}
</ol> </ol>
<h1>Streeplijst</h1> <h1>Streeplijst</h1>
<ul> <ul>
{% for item in dto.items %} {% for item in data.items %}
<li>{{ item.name }}: {{ item.amount }}</li> <li>{{ item.name }}: {{ item.amount }}</li>
{% endfor %} {% endfor %}
</ul> </ul>
<h1>Totaaloverzicht</h1> <h1>Totaaloverzicht</h1>
<ul> <ul>
{% for order in dto.orders %} {% for order in data.orders %}
<li> <li>
{{ order.name }} {{ order.name }}
<ul> <ul>
@@ -35,8 +35,9 @@
<p> Heb je feedback? <p> Heb je feedback?
<a href="https://docs.google.com/forms/d/e/1FAIpQLSddGpp9kbvW9QfLVATOM3pJqhq1ci0_gdZdpGmXmkPRMoiLEw/viewform?usp=sf_link" <a href="https://docs.google.com/forms/d/e/1FAIpQLSddGpp9kbvW9QfLVATOM3pJqhq1ci0_gdZdpGmXmkPRMoiLEw/viewform?usp=sf_link"
target="_blank">Klik hier!</a></p> target="_blank">Klik hier!</a></p>
<p>Wil je de code van deze pagina zien of hieraan bijdragen? <a href="https://github.com/spijkercenter/frietlijst" <p>Wil je de code van deze pagina zien of hieraan bijdragen?
target="_blank">Klik hier!</a> <a href="https://github.com/spijkercenter/frietlijst"
target="_blank">Klik hier!</a>
</p> </p>
</div> </div>
</body> </body>