|
@@ -9,6 +9,7 @@ from tracim.config.app_cfg import CFG
|
9
|
9
|
|
10
|
10
|
from tracim.controllers import TIMRestController
|
11
|
11
|
from tracim.controllers.content import UserWorkspaceFolderRestController
|
|
12
|
+from tracim.controllers.read import ContentController
|
12
|
13
|
|
13
|
14
|
from tracim.lib.helpers import convert_id_into_instances
|
14
|
15
|
from tracim.lib.content import ContentApi
|
|
@@ -42,6 +43,19 @@ class UserWorkspaceRestController(TIMRestController):
|
42
|
43
|
def get_all(self, *args, **kw):
|
43
|
44
|
tg.redirect(tg.url('/home'))
|
44
|
45
|
|
|
46
|
+ @tg.expose()
|
|
47
|
+ def mark_read(self, workspace_id, **kwargs):
|
|
48
|
+
|
|
49
|
+ user = tmpl_context.current_user
|
|
50
|
+ workspace_api = WorkspaceApi(user)
|
|
51
|
+ workspace = workspace_api.get_one(workspace_id)
|
|
52
|
+
|
|
53
|
+ content_api = ContentApi(user)
|
|
54
|
+ content_api.mark_read__workspace(workspace)
|
|
55
|
+
|
|
56
|
+ tg.redirect('/workspaces/{}'.format(workspace_id))
|
|
57
|
+ return DictLikeClass(fake_api=fake_api)
|
|
58
|
+
|
45
|
59
|
@tg.expose('tracim.templates.workspace.getone')
|
46
|
60
|
def get_one(self, workspace_id, **kwargs):
|
47
|
61
|
"""
|
|
@@ -56,6 +70,13 @@ class UserWorkspaceRestController(TIMRestController):
|
56
|
70
|
user = tmpl_context.current_user
|
57
|
71
|
|
58
|
72
|
current_user_content = Context(CTX.CURRENT_USER).toDict(user)
|
|
73
|
+ fake_api = Context(CTX.CURRENT_USER).toDict({
|
|
74
|
+ 'current_user': current_user_content})
|
|
75
|
+
|
|
76
|
+ unread_contents = ContentApi(user).get_last_unread(None,
|
|
77
|
+ ContentType.Any,
|
|
78
|
+ None)
|
|
79
|
+ current_user_content = Context(CTX.CURRENT_USER).toDict(user)
|
59
|
80
|
current_user_content.roles.sort(key=lambda role: role.workspace.name)
|
60
|
81
|
|
61
|
82
|
workspace_api = WorkspaceApi(user)
|
|
@@ -64,6 +85,9 @@ class UserWorkspaceRestController(TIMRestController):
|
64
|
85
|
dictified_current_user = Context(CTX.CURRENT_USER).toDict(user)
|
65
|
86
|
dictified_folders = self.folders.get_all_fake(workspace).result
|
66
|
87
|
fake_api = DictLikeClass(
|
|
88
|
+ last_unread=Context(CTX.CONTENT_LIST).toDict(unread_contents,
|
|
89
|
+ 'contents',
|
|
90
|
+ 'nb'),
|
67
|
91
|
current_user=dictified_current_user,
|
68
|
92
|
current_workspace_folders=dictified_folders,
|
69
|
93
|
current_user_workspace_role=workspace.get_user_role(user)
|