helpers.py 2.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. # -*- coding: utf-8 -*-
  2. """WebHelpers used in pod."""
  3. #from webhelpers import date, feedgenerator, html, number, misc, text
  4. from markupsafe import Markup
  5. from datetime import datetime
  6. from tg.i18n import ugettext as _, lazy_ugettext as l_
  7. import tg
  8. def current_year():
  9. now = datetime.now()
  10. return now.strftime('%Y')
  11. def icon(icon_name, white=False):
  12. if (white):
  13. return Markup('<i class="icon-%s icon-white"></i>' % icon_name)
  14. else:
  15. return Markup('<i class="icon-%s"></i>' % icon_name)
  16. def getExplanationAboutStatus(psStatusId, psCurrentStatusId):
  17. lsMsg = ""
  18. if psStatusId==psCurrentStatusId:
  19. return _("This is the current status.")
  20. else:
  21. if psStatusId=='information':
  22. return _("The item is a normal document, like a howto or a text document.")
  23. if psStatusId=='automatic':
  24. return _("The item will be automatically computed as \"in progress\" or \"done\" according to its children status.")
  25. if psStatusId=='new':
  26. return _("No action done on the item.")
  27. if psStatusId=='inprogress':
  28. return _("The item is being worked on.")
  29. if psStatusId=='standby':
  30. return _("Waiting for some external actions.")
  31. if psStatusId=='done':
  32. return _("The work associated with the item is finished.")
  33. if psStatusId=='closed':
  34. return _("Close the item if you want not to see it anymore. The data won't be deleted")
  35. if psStatusId=='deleted':
  36. return _("This status tells that the item has been deleted.")
  37. class ID(object):
  38. """ Helper class that will manage html items ids that need to be shared"""
  39. @classmethod
  40. def AddDocumentModalForm(cls, poNode=None):
  41. if poNode:
  42. return 'add-document-modal-form-%d'%poNode.node_id
  43. else:
  44. return 'add-document-modal-form'
  45. @classmethod
  46. def AddContactModalForm(cls, poNode=None):
  47. if poNode:
  48. return 'add-contact-modal-form-%d'%poNode.node_id
  49. else:
  50. return 'add-contact-modal-form'
  51. @classmethod
  52. def AddFileModalForm(cls, poNode=None):
  53. if poNode:
  54. return 'add-file-modal-form-%d'%poNode.node_id
  55. else:
  56. return 'add-file-modal-form'
  57. @classmethod
  58. def MoveDocumentModalForm(cls, poNode):
  59. return 'move-document-modal-form-{0}'.format(poNode.node_id)
  60. @classmethod
  61. def AddEventModalForm(cls, poNode=None):
  62. if poNode:
  63. return 'add-event-modal-form-%d'%poNode.node_id
  64. else:
  65. return 'add-event-modal-form'
  66. ## Original id is 'current-document-add-event-form'
  67. @classmethod
  68. def AddCommentInlineForm(cls):
  69. return 'current-document-add-comment-form'
  70. class ICON(object):
  71. Shared = '<i class="fa fa-group"></i>'
  72. Private = '<i class="fa fa-key"></i>'
  73. def tracker_js():
  74. js_file_path = tg.config.get('js_tracker_path', None)
  75. if js_file_path is not None:
  76. with open (js_file_path, "r") as js_file:
  77. data=js_file.read()
  78. return data
  79. else:
  80. return ""