helpers.py 2.6KB

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