Event.py 4.71 KB
Newer Older
Jean-Paul Smets's avatar
Jean-Paul Smets committed
1 2 3
##############################################################################
#
# Copyright (c) 2002 Nexedi SARL and Contributors. All Rights Reserved.
4
#                    Jean-Paul Smets-Solanes <jp@nexedi.com>
Jean-Paul Smets's avatar
Jean-Paul Smets committed
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
#
# WARNING: This program as such is intended to be used by professional
# programmers who take the whole responsability of assessing all potential
# consequences resulting from its eventual inadequacies and bugs
# End users who are looking for a ready-to-use solution with commercial
# garantees and support are strongly adviced to contract a Free Software
# Service Company
#
# This program is Free Software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
#
##############################################################################

from AccessControl import ClassSecurityInfo

Yusei Tahara's avatar
Yusei Tahara committed
31
from Products.ERP5Type import Permissions, PropertySheet
32
from Products.ERP5.Document.Movement import Movement
33
from Products.ERP5.Document.EmailDocument import EmailDocument
Jean-Paul Smets's avatar
Jean-Paul Smets committed
34

35
class Event(EmailDocument, Movement):
Jean-Paul Smets's avatar
Jean-Paul Smets committed
36 37 38 39 40 41 42 43 44
    """
      Event is the base class for all events in ERP5.

      Event objects include emails, phone calls,

      The purpose of an Event object is to keep track
      of the interface between the ERP and third parties.

      Events have a start and stop date.
45 46

      Events may contain files and local role definitions.
Jean-Paul Smets's avatar
Jean-Paul Smets committed
47 48 49 50 51 52
    """

    meta_type = 'ERP5 Event'
    portal_type = 'Event'
    isPortalContent = 1
    isRADContent = 1
53
    isDelivery = 1
54
    
Jean-Paul Smets's avatar
Jean-Paul Smets committed
55 56
    # Declarative security
    security = ClassSecurityInfo()
57
    security.declareObjectProtected(Permissions.AccessContentsInformation)
Jean-Paul Smets's avatar
Jean-Paul Smets committed
58 59 60

    # Declarative properties
    property_sheets = ( PropertySheet.Base
61
                      , PropertySheet.XMLObject
Jean-Paul Smets's avatar
Jean-Paul Smets committed
62
                      , PropertySheet.CategoryCore
63
                      , PropertySheet.Document
Jean-Paul Smets's avatar
Jean-Paul Smets committed
64
                      , PropertySheet.DublinCore
65
                      , PropertySheet.Snapshot
Jean-Paul Smets's avatar
Jean-Paul Smets committed
66
                      , PropertySheet.Task
67 68
                      , PropertySheet.Url
                      , PropertySheet.TextDocument
69 70 71
                      , PropertySheet.Arrow
                      , PropertySheet.Movement
                      , PropertySheet.Event
72
                      , PropertySheet.Delivery
73 74
                      , PropertySheet.ItemAggregation
                     )
Jean-Paul Smets's avatar
Jean-Paul Smets committed
75

76 77
    security.declareProtected(Permissions.AccessContentsInformation,
                              'isAccountable')
78 79 80 81 82 83 84
    def isAccountable(self):
      """
        Returns 1 if this needs to be accounted
        Only account movements which are not associated to a delivery
        Whenever delivery is there, delivery has priority
      """
      return 1
85

86
    security.declareProtected(Permissions.AccessContentsInformation,
Romain Courteaud's avatar
Romain Courteaud committed
87 88
                              'getQuantity')
    def getQuantity(self):
89 90 91
      """
        Quantity is set automatically on Events.
      """
92 93
      # Provide opportunity to script this
      return 1.
94 95 96 97

    security.declareProtected(Permissions.AccessContentsInformation,
                               'getExplanationValue')
    def getExplanationValue(self):
98 99
      """
        An event is it's own explanation
100 101
      """
      return self
102 103

    security.declareProtected(Permissions.UseMailhostServices, 'send')
Yusei Tahara's avatar
Yusei Tahara committed
104 105
    def send(self, from_url=None, to_url=None, reply_url=None, subject=None,
             body=None, attachment_format=None, download=False, **kw):
106 107 108 109 110 111 112 113 114 115 116
      """
        Make the send method overridable by typed based script
        so that special kinds of events can use a different gateway
        to send messages. This is useful for example to send
        faxes through fax server or to send letters by printing
        them to the printer or to send SMS through a custom 
        gateway. In the most usual case, sending will only consist
        in changing the destination.
      """
      send_script = self._getTypeBasedMethod('send')
      if send_script is None:
Yusei Tahara's avatar
Yusei Tahara committed
117 118 119 120 121 122
        return Event.inheritedAttribute('send')(
            self, from_url, to_url, reply_url, subject, body, attachment_format, download
            )
      return send_script(
          from_url, to_url, reply_url, subject, body, attachment_format, download, **kw
          )