rapid_basics.py 796 B

1234567891011121314151617181920212223242526272829303132
  1. # coding=utf-8
  2. __author__ = 'marcos.medeiros'
  3. from django import template
  4. from django.template import loader, Context
  5. from django.utils.safestring import mark_safe
  6. register = template.Library()
  7. _templates_path = 'rapid/basics/'
  8. @register.simple_tag
  9. def show_action(entry, url):
  10. action = entry.action
  11. if action.pick_generator:
  12. t = loader.get_template(_templates_path+'pick_action.html')
  13. c = Context({
  14. 'options': url,
  15. 'action': action,
  16. 'entry': entry,
  17. })
  18. return mark_safe(t.render(c))
  19. else:
  20. t = loader.get_template(_templates_path+'btn_action.html')
  21. c = Context({
  22. 'link': url,
  23. 'action': action,
  24. 'entry': entry,
  25. })
  26. return mark_safe(t.render(c))