start add class

This commit is contained in:
starnakin 2023-02-12 21:55:04 +01:00
parent 9c903176b1
commit 1bbc0631b6
7 changed files with 87 additions and 15 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): def add_user(email: str, password: str):
password_hashed = hasher.hash_text(password) 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): def check_password(email: str, password: str):
password_hashed = get_user_by_email(email).get("password") 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__())

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__())