diff --git a/__pycache__/database.cpython-310.pyc b/__pycache__/database.cpython-310.pyc index bea0111..76694da 100644 Binary files a/__pycache__/database.cpython-310.pyc and b/__pycache__/database.cpython-310.pyc differ diff --git a/article.py b/article.py new file mode 100644 index 0000000..b7f97a2 --- /dev/null +++ b/article.py @@ -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__()) diff --git a/database.json b/database.json deleted file mode 100644 index 33f2594..0000000 --- a/database.json +++ /dev/null @@ -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": {} -} \ No newline at end of file diff --git a/database.py b/database.py index 4455776..05a73b7 100644 --- a/database.py +++ b/database.py @@ -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") diff --git a/grocery_list.py b/grocery_list.py new file mode 100644 index 0000000..0ded30c --- /dev/null +++ b/grocery_list.py @@ -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 diff --git a/group.py b/group.py new file mode 100644 index 0000000..5065d1d --- /dev/null +++ b/group.py @@ -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__()) diff --git a/user.py b/user.py new file mode 100644 index 0000000..0b0a70c --- /dev/null +++ b/user.py @@ -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__())