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:
global _repository
data = _get_data()
return render_template('frietlijst.html', dto=data)
return render_template('frietlijst.html', data=data)
def anonymize_name(name: str) -> str:
@@ -22,7 +21,7 @@ def anonymize_name(name: str) -> str:
return result
@cached(cache=TTLCache(maxsize=2, ttl=10))
@cached(cache=TTLCache(maxsize=1, ttl=10))
def _get_data() -> DTO:
cutoff = datetime.datetime.now() - datetime.timedelta(days=4)

View File

@@ -10,7 +10,10 @@ class DTO:
self.__items: Dict[str, int] = {}
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)
for item_name in item_names:

View File

@@ -1,11 +1,15 @@
class Item:
def __init__(self, name: str, amount: int):
def __init__(self,
name: str,
amount: int):
assert name == name.lower()
self.name = name
self.amount = amount
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:
return True
if not self.__contains_fries and other.__contains_fries:

View File

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

View File

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