|
@@ -4,6 +4,7 @@ import logging
|
4
|
4
|
from django.utils.translation import gettext as _
|
5
|
5
|
|
6
|
6
|
|
|
7
|
+from pages import access
|
7
|
8
|
from .help import actionbar as actionbar_add_help
|
8
|
9
|
import mycreole
|
9
|
10
|
import pages
|
|
@@ -18,6 +19,7 @@ logger = logging.getLogger(ROOT_LOGGER_NAME).getChild(__name__)
|
18
|
19
|
|
19
|
20
|
ATTACHMENT_UID = 'attachment'
|
20
|
21
|
BACK_UID = 'back'
|
|
22
|
+EDIT_UID = 'edit'
|
21
|
23
|
HELP_UID = 'help'
|
22
|
24
|
|
23
|
25
|
|
|
@@ -56,12 +58,7 @@ def add_back_menu(request, bar):
|
56
|
58
|
|
57
|
59
|
def menubar(context, request, caller_name, **kwargs):
|
58
|
60
|
bar = context[context.MENUBAR]
|
59
|
|
- # replace_profile(request, bar)
|
60
|
61
|
add_help_menu(request, bar)
|
61
|
|
- # add_tasklist_menu(request, bar)
|
62
|
|
- # add_filter_submenu(request, bar, VIEW_TASKLIST_UID)
|
63
|
|
- # add_projectlist_menu(request, bar)
|
64
|
|
- # add_printview_menu(request, bar)
|
65
|
62
|
finalise_bar(request, bar)
|
66
|
63
|
|
67
|
64
|
|
|
@@ -78,18 +75,27 @@ def add_help_menu(request, bar):
|
78
|
75
|
|
79
|
76
|
def actionbar(context, request, caller_name, **kwargs):
|
80
|
77
|
bar = context[context.ACTIONBAR]
|
81
|
|
- if caller_name == 'pages':
|
82
|
|
- # acc = acc_task(kwargs['task'], request.user)
|
83
|
|
- # if acc.modify or acc.modify_limited:
|
84
|
|
- # add_edittask_menu(request, bar, kwargs['task'].id)
|
85
|
|
- # if acc.add_comments:
|
86
|
|
- # add_newcomment_menu(request, bar, kwargs['task'].id)
|
87
|
|
- add_manageupload_menu(request, bar, kwargs['upload_path'])
|
|
78
|
+ if caller_name == 'page':
|
|
79
|
+ if access.write_page(request, kwargs["rel_path"]):
|
|
80
|
+ add_edit_menu(request, bar, kwargs["rel_path"])
|
|
81
|
+ if access.modify_attachment(request, kwargs["rel_path"]):
|
|
82
|
+ add_manageupload_menu(request, bar, kwargs['upload_path'])
|
88
|
83
|
elif caller_name == 'helpview':
|
89
|
84
|
actionbar_add_help(context, request, **kwargs)
|
90
|
85
|
finalise_bar(request, bar)
|
91
|
86
|
|
92
|
87
|
|
|
88
|
+def add_edit_menu(request, bar, rel_path):
|
|
89
|
+ bar.append_entry(
|
|
90
|
+ EDIT_UID, # uid
|
|
91
|
+ _('Edit'), # name
|
|
92
|
+ color_icon_url(request, 'edit.png'), # icon
|
|
93
|
+ pages.url_edit(request, rel_path), # url
|
|
94
|
+ True, # left
|
|
95
|
+ False # active
|
|
96
|
+ )
|
|
97
|
+
|
|
98
|
+
|
93
|
99
|
def add_manageupload_menu(request, bar, upload_path):
|
94
|
100
|
bar.append_entry(
|
95
|
101
|
ATTACHMENT_UID, # uid
|
|
@@ -105,185 +111,3 @@ def finalise_bar(request, bar):
|
105
|
111
|
if len(bar) == 0:
|
106
|
112
|
bar.append_entry(*empty_entry_parameters(request))
|
107
|
113
|
|
108
|
|
-
|
109
|
|
-"""from .access import create_project_possible, create_task_possible, acc_task
|
110
|
|
-from django.db.models.functions import Lower
|
111
|
|
-import patt
|
112
|
|
-from .search import common_searches
|
113
|
|
-from themes import empty_entry_parameters, color_icon_url, gray_icon_url
|
114
|
|
-from users.context import PROFILE_ENTRY_UID
|
115
|
|
-
|
116
|
|
-
|
117
|
|
-COMMENTNEW_UID = 'commentnew'
|
118
|
|
-CREATE_PROJECT_UID = 'create-project'
|
119
|
|
-CREATE_TASK_UID = 'create-task'
|
120
|
|
-PRINTVIEW_UID = 'printview'
|
121
|
|
-TASKEDIT_UID = 'taskedit'
|
122
|
|
-VIEW_PROJECTLIST_UID = 'view-projectlist'
|
123
|
|
-VIEW_TASKLIST_UID = 'view-tasklist'
|
124
|
|
-
|
125
|
|
-
|
126
|
|
-
|
127
|
|
-
|
128
|
|
-
|
129
|
|
-
|
130
|
|
-
|
131
|
|
-
|
132
|
|
-def replace_profile(request, bar):
|
133
|
|
- try:
|
134
|
|
- bar.replace_entry(
|
135
|
|
- PROFILE_ENTRY_UID,
|
136
|
|
- PROFILE_ENTRY_UID, # uid
|
137
|
|
- request.user.username, # name
|
138
|
|
- color_icon_url(request, 'user.png'), # icon
|
139
|
|
- patt.url_profile(request), # url
|
140
|
|
- False, # left
|
141
|
|
- False # active
|
142
|
|
- )
|
143
|
|
- except ValueError:
|
144
|
|
- pass # Profile entry does not exist, so exchange is not needed (e.g. no user is logged in)
|
145
|
|
-
|
146
|
|
-
|
147
|
|
-
|
148
|
|
-
|
149
|
|
-def add_tasklist_menu(request, bar):
|
150
|
|
- bar.append_entry(
|
151
|
|
- VIEW_TASKLIST_UID, # uid
|
152
|
|
- _('Tasklist'), # name
|
153
|
|
- color_icon_url(request, 'task.png'), # icon
|
154
|
|
- patt.url_tasklist(request), # url
|
155
|
|
- True, # left
|
156
|
|
- patt.is_tasklistview(request) # active
|
157
|
|
- )
|
158
|
|
-
|
159
|
|
-
|
160
|
|
-def add_projectlist_menu(request, bar):
|
161
|
|
- bar.append_entry(
|
162
|
|
- VIEW_PROJECTLIST_UID, # uid
|
163
|
|
- _('Projectlist'), # name
|
164
|
|
- color_icon_url(request, 'folder.png'), # icon
|
165
|
|
- patt.url_projectlist(request), # url
|
166
|
|
- True, # left
|
167
|
|
- patt.is_projectlistview(request) # active
|
168
|
|
- )
|
169
|
|
-
|
170
|
|
-
|
171
|
|
-def add_printview_menu(request, bar):
|
172
|
|
- bar.append_entry(
|
173
|
|
- PRINTVIEW_UID, # uid
|
174
|
|
- _('Printview'), # name
|
175
|
|
- color_icon_url(request, 'print.png'), # icon
|
176
|
|
- patt.url_printview(request), # url
|
177
|
|
- True, # left
|
178
|
|
- patt.is_printview(request) # active
|
179
|
|
- )
|
180
|
|
-
|
181
|
|
-
|
182
|
|
-def add_newtask_menu(request, bar, project_id):
|
183
|
|
- bar.append_entry(
|
184
|
|
- CREATE_TASK_UID, # uid
|
185
|
|
- _('New Task'), # name
|
186
|
|
- color_icon_url(request, 'plus.png'), # icon
|
187
|
|
- patt.url_tasknew(request, project_id), # url
|
188
|
|
- True, # left
|
189
|
|
- False # active
|
190
|
|
- )
|
191
|
|
-
|
192
|
|
-
|
193
|
|
-def add_edittask_menu(request, bar, task_id):
|
194
|
|
- bar.append_entry(
|
195
|
|
- TASKEDIT_UID, # uid
|
196
|
|
- _('Edit'), # name
|
197
|
|
- color_icon_url(request, 'edit.png'), # icon
|
198
|
|
- patt.url_taskedit(request, task_id), # url
|
199
|
|
- True, # left
|
200
|
|
- False # active
|
201
|
|
- )
|
202
|
|
-
|
203
|
|
-
|
204
|
|
-def add_newcomment_menu(request, bar, task_id):
|
205
|
|
- bar.append_entry(
|
206
|
|
- COMMENTNEW_UID, # uid
|
207
|
|
- _('Add Comment'), # name
|
208
|
|
- color_icon_url(request, 'edit2.png'), # icon
|
209
|
|
- patt.url_commentnew(request, task_id), # url
|
210
|
|
- True, # left
|
211
|
|
- False # active
|
212
|
|
- )
|
213
|
|
-
|
214
|
|
-
|
215
|
|
-def add_newproject_menu(request, bar):
|
216
|
|
- bar.append_entry(
|
217
|
|
- CREATE_PROJECT_UID, # uid
|
218
|
|
- _('New Project'), # name
|
219
|
|
- color_icon_url(request, 'plus.png'), # icon
|
220
|
|
- patt.url_projectnew(request), # url
|
221
|
|
- True, # left
|
222
|
|
- False # active
|
223
|
|
- )
|
224
|
|
-
|
225
|
|
-
|
226
|
|
-
|
227
|
|
-
|
228
|
|
-
|
229
|
|
-
|
230
|
|
-def add_filter_submenu(request, bar, menu_uid):
|
231
|
|
- bar.append_entry_to_entry(
|
232
|
|
- menu_uid,
|
233
|
|
- menu_uid + '-easysearch', # uid
|
234
|
|
- _('Easysearch'), # name
|
235
|
|
- gray_icon_url(request, 'search.png'), # icon
|
236
|
|
- patt.url_easysearch(request), # url
|
237
|
|
- True, # left
|
238
|
|
- False # active
|
239
|
|
- )
|
240
|
|
- if patt.get_search_query(request) is not None:
|
241
|
|
- bar.append_entry_to_entry(
|
242
|
|
- menu_uid,
|
243
|
|
- menu_uid + '-save', # uid
|
244
|
|
- _('Save Search as Filter'), # name
|
245
|
|
- gray_icon_url(request, 'save.png'), # icon
|
246
|
|
- patt.url_filteredit(request), # url
|
247
|
|
- True, # left
|
248
|
|
- False # active
|
249
|
|
- )
|
250
|
|
- bar.append_entry_to_entry(
|
251
|
|
- menu_uid,
|
252
|
|
- menu_uid + '-all', # uid
|
253
|
|
- _('All Tasks'), # name
|
254
|
|
- gray_icon_url(request, 'task.png'), # icon
|
255
|
|
- patt.url_tasklist(request), # url
|
256
|
|
- True, # left
|
257
|
|
- False # active
|
258
|
|
- )
|
259
|
|
- cs = common_searches(request)
|
260
|
|
- for common_filter_id in cs:
|
261
|
|
- bar.append_entry_to_entry(
|
262
|
|
- menu_uid,
|
263
|
|
- menu_uid + '-common', # uid
|
264
|
|
- _(cs[common_filter_id][0]), # name
|
265
|
|
- gray_icon_url(request, 'filter.png'), # icon
|
266
|
|
- patt.url_tasklist(request, common_filter_id=common_filter_id), # url
|
267
|
|
- True, # left
|
268
|
|
- False # active
|
269
|
|
- )
|
270
|
|
- for s in request.user.search_set.order_by(Lower('name')):
|
271
|
|
- active = patt.is_tasklistview(request, s.id)
|
272
|
|
- if active is True:
|
273
|
|
- url = patt.url_filteredit(request, s.id)
|
274
|
|
- else:
|
275
|
|
- url = patt.url_tasklist(request, user_filter_id=s.id)
|
276
|
|
- if active:
|
277
|
|
- icon = 'settings.png'
|
278
|
|
- else:
|
279
|
|
- icon = 'favourite.png'
|
280
|
|
- bar.append_entry_to_entry(
|
281
|
|
- menu_uid,
|
282
|
|
- menu_uid + '-sub', # uid
|
283
|
|
- s.name, # name
|
284
|
|
- gray_icon_url(request, icon), # icon
|
285
|
|
- url, # url
|
286
|
|
- True, # left
|
287
|
|
- active # active
|
288
|
|
- )
|
289
|
|
-"""
|