rapid_basics.py 810 B

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