|
@@ -1,8 +1,10 @@
|
|
1
|
+from django.conf import settings
|
1
|
2
|
from django.utils.translation import gettext as _
|
|
3
|
+
|
2
|
4
|
import logging
|
|
5
|
+import importlib
|
|
6
|
+
|
3
|
7
|
from mycreole import url_upload
|
4
|
|
-from users.context import menubar as user_menubar
|
5
|
|
-from patt.context import navigationbar
|
6
|
8
|
from themes import color_icon_url
|
7
|
9
|
|
8
|
10
|
try:
|
|
@@ -15,9 +17,26 @@ NEW_ATTACHMENT_UID = 'new_attachment'
|
15
|
17
|
|
16
|
18
|
|
17
|
19
|
def context_adaption(context, request, title, rel_path, **kwargs):
|
|
20
|
+ def get_method(import_string):
|
|
21
|
+ class_data = import_string.split(".")
|
|
22
|
+ module_path = ".".join(class_data[:-1])
|
|
23
|
+ class_str = class_data[-1]
|
|
24
|
+ #
|
|
25
|
+ module = importlib.import_module(module_path)
|
|
26
|
+ return getattr(module, class_str)
|
|
27
|
+
|
|
28
|
+ def log_warning(method_name, e):
|
|
29
|
+ logger.warning('Could not import %s method for extending bars: %s - %s', method_name, type(e).__name__, e)
|
|
30
|
+
|
18
|
31
|
context.set_additional_title(title)
|
19
|
|
- user_menubar(context[context.MENUBAR], request)
|
20
|
|
- navigationbar(context, request)
|
|
32
|
+ for key in ["menubar", "navibar"]:
|
|
33
|
+ try:
|
|
34
|
+ method_name = settings.MYCREOLE_BAR[key]
|
|
35
|
+ except (AttributeError, KeyError) as e:
|
|
36
|
+ log_warning(key, e)
|
|
37
|
+ else:
|
|
38
|
+ method = get_method(method_name)
|
|
39
|
+ method(context, request, caller_name="attachments")
|
21
|
40
|
add_new(request, context[context.ACTIONBAR], rel_path, kwargs.get('next'))
|
22
|
41
|
for key in kwargs:
|
23
|
42
|
context[key] = kwargs[key]
|