Compare commits

...

2 Commits

Author SHA1 Message Date
1bbc0631b6 start add class 2023-02-12 21:55:04 +01:00
9c903176b1 add the first version groceries_list page 2023-02-12 21:54:29 +01:00
10 changed files with 158 additions and 17 deletions

Binary file not shown.

26
article.py Normal file
View File

@ -0,0 +1,26 @@
class Article():
def __init__(self, name: str, id: str, price: float = 0, quantity: int = 1) -> Article:
"""
the article data
:param name: the name
:type name: str
:param id: uuid
:type id: str
:param price: price
:type price: float
:param quantity: quantity
:type quantity: int
:return: the article
:rtype: Article
"""
self.name = name;
self.id = id;
self.price = price;
self.quantity = quantity;
return (self);
def __repr__(self):
return (f"Article(name={self.name},id={self.id},price={self.price},quantity={self.quantity})")
def __str__(self):
return (self.__repr__())

View File

@ -1,14 +0,0 @@
{
"users": {
"1": {
"email": "camille@chauvet.pro",
"password": "b'$2b$12$FVOKVF9p/SlSv9ANVNDW.eOmv1f3qtB0WU86g4ED4B8J2fMBPZu7.'"
},
"2": {
"email": "spam@camille.chauvet.pro",
"password": "b'$2b$12$D2DexgunhMTbYWkXmEQKw.Aa13W9QZE4CjsNUyaU5bSaZ8ZpdJ2hO'"
}
},
"resets": {},
"_default": {}
}

View File

@ -24,7 +24,7 @@ def user_exist(email: str):
def add_user(email: str, password: str):
password_hashed = hasher.hash_text(password)
users.insert({"email": email, "password": str(password_hashed)});
users.insert({"email": email, "password": str(password_hashed), "id": uuid.uuid4()});
def check_password(email: str, password: str):
password_hashed = get_user_by_email(email).get("password")

12
grocery_list.py Normal file
View File

@ -0,0 +1,12 @@
class GroceryList():
def __init__(self, id: str, articles: list):
"""
Groceries List
:param id: uuid
:type id: str
:param articles: list of articles
:type articles: list[Article]
:return: the grocery list
:rtype: GroceryList
"""
self.id = str

23
group.py Normal file
View File

@ -0,0 +1,23 @@
class Group():
def __init__(self, id: str, members: list, lists: list) -> Group:
"""
this class aims to store group with an id, a list of members, a lists of greceries lists
:param id: the uuid of the groups
:type id: int
:param members: the lists of members (User)
:type members: list[User]
:param lists: the lists of groceries lists
:type lists: list[GroceriesList]
:return: the group
:rtype: Group
"""
self.id = id;
self.members = members
self.lists: lists
return (self)
def __str__(self):
return (f"Group(id={self.id},members={self.members},lists={self.lists})")
def __repr__(self):
return (self.__str__())

View File

@ -6,7 +6,6 @@
</head>
<body>
<h1>connected</h1>
<h2>Welcome to FlaskApp!</h2>
<a href="/logout">
<input type="button" value="logout">
</a>

71
templates/grocery.html Normal file
View File

@ -0,0 +1,71 @@
<!DOCTYPE html>
<html>
<header>
<title>{{name}}</title>
</header>
<body>
<div id="container">
<table>
<tr>
<td><b>Acheté</b></td>
<td><b>Nom</b></td>
<td><b>Quantité</b></td>
<td><b>Prix</b></td>
</tr>
<tr>
{% for article in articles %}
<td class="buyed">
<input type="checkbox" id={{article.id}}>
</td>
<td>
<input type="text" value={{article.name}}>
</td>
<td>
<input type="number" value="{{article.quantity}}" size="7" step="1">
</td>
<td>
<input type="number" value="{{article.price}}" size="9" step="0.01"'>
</td>
{% endfor %}
</tr>
<tr>
<td class="add_element" colspan="4">
<a href={{add_button_url}}>
<input type="button" value="+">
</a>
</td>
</tr>
</table>
</div>
<style>
td.buyed {
text-align: center;
vertical-align: middle;
}
body {
background: #67BE4B;
}
#container {
width: 400px;
margin: 0 auto;
margin-top: 5%;
border: 1px solid #f1f1f1;
background: #fff;
}
td.add_element {
background: #fff;
margin: 100%;
text-align: center;
}
td.add_element input[type=button] {
width: 100%;
border: 0px;
background: #67BE4B;
}
td.add_element input[type=button]:hover {
background: #fff;
border: 1px solid #67BE4B;
}
</style>
</body>
</html>

View File

@ -4,7 +4,6 @@
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="index.css" />
<title>Beyond School</title>
</head>
<body>

25
user.py Normal file
View File

@ -0,0 +1,25 @@
class User():
def __init__(self, mail: str, password: str, id: str, groups: list = []) -> User:
"""
User: store user data
:param mail: the mail address
:type mail: str
:param password: the password
:type password: str
:param id: the uuid
:type id: str
:param groups: the lists of groups the user is in
:type groups: list[Group]
:return: the user
:rtype: User
"""
self.mail = mail
self.password = password
self.id = id;
self.groups = groups
def __repr__(self):
return (f"User(mail={self.mail},password={self.password},id={self.id},groups={self.groups})")
def __str__(self):
return (self.__repr__())