Django Library Mycreole
Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

context.py 1.2KB

12345678910111213141516171819202122232425262728293031323334353637
  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. logger = logging.getLogger(settings.ROOT_LOGGER_NAME).getChild(__name__)
  9. NEW_ATTACHMENT_UID = 'new_attachment'
  10. def context_adaption(context, request, title, rel_path, **kwargs):
  11. context.set_additional_title(title)
  12. add_bar = parameter.get(parameter.MYCREOLE_BAR)
  13. for key in add_bar:
  14. method = add_bar[key]
  15. if method is not None:
  16. method(context, request, caller_name="mycreole-attachments", **kwargs)
  17. add_new(request, context[context.ACTIONBAR], rel_path, kwargs.get('next'))
  18. for key in kwargs:
  19. context[key] = kwargs[key]
  20. logger.debug("context adapted: %s", repr(context))
  21. def add_new(request, bar, rel_path, nxt):
  22. bar.append_entry(
  23. NEW_ATTACHMENT_UID, # uid
  24. _('New Attachment'), # name
  25. color_icon_url(request, 'plus.png'), # icon
  26. url_upload(request, rel_path, nxt), # url
  27. True, # left
  28. False # active
  29. )