Django Library Mycreole
選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

context.py 1.3KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. from django.conf import settings
  2. from django.utils.translation import gettext as _
  3. import logging
  4. import importlib
  5. from mycreole import url_upload
  6. from mycreole import parameter
  7. from themes import color_icon_url
  8. try:
  9. from config import APP_NAME as ROOT_LOGGER_NAME
  10. except ImportError:
  11. ROOT_LOGGER_NAME = 'root'
  12. logger = logging.getLogger(ROOT_LOGGER_NAME).getChild(__name__)
  13. NEW_ATTACHMENT_UID = 'new_attachment'
  14. def context_adaption(context, request, title, rel_path, **kwargs):
  15. context.set_additional_title(title)
  16. add_bar = parameter.get(parameter.MYCREOLE_BAR)
  17. for key in add_bar:
  18. method = add_bar[key]
  19. if method is not None:
  20. method(context, request, caller_name="mycreole-attachments", **kwargs)
  21. add_new(request, context[context.ACTIONBAR], rel_path, kwargs.get('next'))
  22. for key in kwargs:
  23. context[key] = kwargs[key]
  24. logger.debug("context adapted: %s", repr(context))
  25. def add_new(request, bar, rel_path, nxt):
  26. bar.append_entry(
  27. NEW_ATTACHMENT_UID, # uid
  28. _('New Attachment'), # name
  29. color_icon_url(request, 'plus.png'), # icon
  30. url_upload(request, rel_path, nxt), # url
  31. True, # left
  32. False # active
  33. )