znote 1.0.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,67 @@
1
+ import impmagic
2
+
3
+
4
+ @impmagic.loader(
5
+ {'module': '__main__'},
6
+ {'module': 'os'},
7
+ {'module': 'pony.orm', 'submodule': ['db_session']}
8
+ )
9
+ def list_workspace(user):
10
+ #create_workspace(user)
11
+
12
+ with db_session:
13
+ user_db = __main__.settings.orm.User.get(username=user)
14
+ if user_db:
15
+ return user_db.workspace.split(",")
16
+ return []
17
+
18
+
19
+ @impmagic.loader(
20
+ {'module': '__main__'},
21
+ {'module': 'os'},
22
+ {'module': 'pony.orm', 'submodule': ['db_session', 'commit']}
23
+ )
24
+ def create_workspace(user, namespace):
25
+ try:
26
+ with db_session:
27
+ user_db = __main__.settings.orm.User.get(username=user)
28
+ if user_db:
29
+ user_workspace = user_db.workspace.split(",")
30
+
31
+ if namespace not in user_workspace:
32
+ user_workspace.append(namespace)
33
+ user_db.workspace = ",".join(user_workspace)
34
+
35
+ commit()
36
+
37
+ return True
38
+
39
+ return False
40
+ except:
41
+ return False
42
+
43
+
44
+ @impmagic.loader(
45
+ {'module': '__main__'},
46
+ {'module': 'os'},
47
+ {'module': 'shutil'},
48
+ {'module': 'pony.orm', 'submodule': ['db_session', 'commit']}
49
+ )
50
+ def remove_workspace(user, namespace):
51
+ try:
52
+ with db_session:
53
+ user_db = __main__.settings.orm.User.get(username=user)
54
+ if user_db:
55
+ user_workspace = user_db.workspace.split(",")
56
+
57
+ if namespace in user_workspace:
58
+ user_workspace.remove(namespace)
59
+ user_db.workspace = ",".join(user_workspace)
60
+
61
+ commit()
62
+
63
+ return True
64
+
65
+ return False
66
+ except:
67
+ return False
znote/main.py ADDED
@@ -0,0 +1,2 @@
1
+ from .client import run_client
2
+ from .server import run_server
znote/model/models.py ADDED
@@ -0,0 +1,25 @@
1
+ from pony.orm import Required, Optional, PrimaryKey, LongStr
2
+ from datetime import datetime
3
+ import __main__
4
+
5
+
6
+ def Table(db, type_db="sqlite"):
7
+ class User(db.Entity):
8
+ id = PrimaryKey(int, auto=True)
9
+ username = Required(str, unique=True)
10
+ password_hash = Required(str)
11
+ created_at = Required(datetime)
12
+ workspace = Required(str, default="default")
13
+ active_workspace = Required(str, default="default")
14
+
15
+ class Note(db.Entity):
16
+ id = PrimaryKey(int, auto=True)
17
+ title = Required(str)
18
+ content = Required(str)
19
+ created_at = Required(datetime)
20
+ updated_at = Required(datetime)
21
+ creator_id = Required(int)
22
+ editor_id = Required(int)
23
+ protected = Optional(str)
24
+ shared_with = Optional(str) # Liste d’IDs ou noms d’utilisateurs
25
+ workspace = Required(str)