Back to index

plone3  3.1.7
Public Member Functions | Static Public Attributes | Private Member Functions | Static Private Attributes
ATContentTypes.content.event.ATEvent Class Reference
Inheritance diagram for ATContentTypes.content.event.ATEvent:
Inheritance graph
[legend]
Collaboration diagram for ATContentTypes.content.event.ATEvent:
Collaboration graph
[legend]

List of all members.

Public Member Functions

def setEventType
def setSubject
def getEventTypes
def cmf_edit
def post_validate
def __cmp__
def __hash__
def update

Static Public Attributes

 schema = ATEventSchema
string portal_type = 'Event'
string archetype_name = 'Event'
tuple assocMimetypes = ()
tuple assocFileExt = ('event', )
tuple cmf_edit_kws
tuple security = ClassSecurityInfo()
tuple start_date = ComputedAttribute(_start_date)
tuple end_date = ComputedAttribute(_end_date)
tuple duration = ComputedAttribute(_duration)

Private Member Functions

def _start_date
def _end_date
def _duration

Static Private Attributes

dictionary _atct_newTypeFor = {'portal_type' : 'CMF Event', 'meta_type' : 'CMF Event'}
tuple __implements__

Detailed Description

Information about an upcoming event, which can be displayed in the calendar.

Definition at line 180 of file event.py.


Member Function Documentation

def ATContentTypes.content.event.ATEvent.__cmp__ (   self,
  other 
)
Compare method

If other is based on ATEvent, compare start, duration and title.
#If other is a number, compare duration and number
If other is a DateTime instance, compare start date with date
In all other cases there is no specific order

Definition at line 349 of file event.py.

00349 
00350     def __cmp__(self, other):
00351         """Compare method
00352 
00353         If other is based on ATEvent, compare start, duration and title.
00354         #If other is a number, compare duration and number
00355         If other is a DateTime instance, compare start date with date
00356         In all other cases there is no specific order
00357         """
00358         # Please note that we can not use self.Title() here: the generated
00359         # edit accessor uses getToolByName, which ends up in
00360         # five.localsitemanager looking for a parent using a comparison
00361         # on this object -> infinite recursion.
00362         if IATEvent.isImplementedBy(other):
00363             return cmp((self.start_date, self.duration, self.title),
00364                        (other.start_date, other.duration, other.title))
00365         #elif isinstance(other, (int, long, float)):
00366         #    return cmp(self.duration, other)
00367         elif isinstance(other, DateTime):
00368             return cmp(self.start(), other)
00369         else:
00370             # TODO come up with a nice cmp for types
00371             return cmp(self.title, other)

Here is the call graph for this function:

Definition at line 372 of file event.py.

00372 
00373     def __hash__(self):
00374         return hash((self.start_date, self.duration, self.title))

Here is the call graph for this function:

Definition at line 343 of file event.py.

00343 
00344     def _duration(self):
00345         return self.end_date - self.start_date

Definition at line 334 of file event.py.

00334 
00335     def _end_date(self):
00336         value = self['endDate']
00337         if value is None:
00338             return self.start_date
00339         return DT2dt(value)

Here is the call graph for this function:

Definition at line 325 of file event.py.

00325 
00326     def _start_date(self):
00327         value = self['startDate']
00328         if value is None:
00329             value = self['creation_date']
00330         return DT2dt(value)

Here is the call graph for this function:

def ATContentTypes.content.event.ATEvent.cmf_edit (   self,
  title = None,
  description = None,
  eventType = None,
  effectiveDay = None,
  effectiveMo = None,
  effectiveYear = None,
  expirationDay = None,
  expirationMo = None,
  expirationYear = None,
  start_date = None,
  start_time = None,
  startAMPM = None,
  end_date = None,
  stop_time = None,
  stopAMPM = None,
  location = None,
  contact_name = None,
  contact_email = None,
  contact_phone = None,
  event_url = None 
)

Definition at line 254 of file event.py.

00254 
00255              event_url=None):
00256 
00257         if effectiveDay and effectiveMo and effectiveYear and start_time:
00258             sdate = '%s-%s-%s %s %s' % (effectiveDay, effectiveMo, effectiveYear,
00259                                          start_time, startAMPM)
00260         elif start_date:
00261             if not start_time:
00262                 start_time = '00:00:00'
00263             sdate = '%s %s' % (start_date, start_time)
00264         else:
00265             sdate = None
00266 
00267         if expirationDay and expirationMo and expirationYear and stop_time:
00268             edate = '%s-%s-%s %s %s' % (expirationDay, expirationMo,
00269                                         expirationYear, stop_time, stopAMPM)
00270         elif end_date:
00271             if not stop_time:
00272                 stop_time = '00:00:00'
00273             edate = '%s %s' % (end_date, stop_time)
00274         else:
00275             edate = None
00276 
00277         if sdate and edate:
00278             if edate < sdate:
00279                 edate = sdate
00280             self.setStartDate(sdate)
00281             self.setEndDate(edate)
00282 
00283         self.update(title=title, description=description, eventType=eventType,
00284                     location=location, contactName=contact_name,
00285                     contactEmail=contact_email, contactPhone=contact_phone,
00286                     eventUrl=event_url)

Here is the caller graph for this function:

fetch a list of the available event types from the vocabulary

Definition at line 239 of file event.py.

00239 
00240     def getEventTypes(self):
00241         """fetch a list of the available event types from the vocabulary
00242         """
00243         f = self.getField('eventType')
00244         result = self.collectKeywords('eventType', f.accessor)
00245         return tuple(result)

Here is the call graph for this function:

def ATContentTypes.content.event.ATEvent.post_validate (   self,
  REQUEST = None,
  errors = None 
)
Validates start and end date

End date must be after start date

Definition at line 288 of file event.py.

00288 
00289     def post_validate(self, REQUEST=None, errors=None):
00290         """Validates start and end date
00291 
00292         End date must be after start date
00293         """
00294         if 'startDate' in errors or 'endDate' in errors:
00295             # No point in validating bad input
00296             return
00297         
00298         rstartDate = REQUEST.get('startDate', None)
00299         rendDate = REQUEST.get('endDate', None)
00300 
00301         if rendDate:
00302             try:
00303                 end = DateTime(rendDate)
00304             except:
00305                 errors['endDate'] = _(u'error_invalid_end_date',
00306                                       default=u'End date is not valid.')
00307         else:
00308             end = self.end()
00309         if rstartDate:
00310             try:
00311                 start = DateTime(rstartDate)
00312             except:
00313                 errors['startDate'] = _(u'error_invalid_start_date',
00314                                         default=u'Start date is not valid.')
00315         else:
00316             start = self.start()
00317 
00318         if 'startDate' in errors or 'endDate' in errors:
00319             # No point in validating bad input
00320             return
00321         
00322         if start > end:
00323             errors['endDate'] = _(u'error_end_must_be_after_start_date',
00324                                   default=u'End date must be after start date.')

Here is the call graph for this function:

def ATContentTypes.content.event.ATEvent.setEventType (   self,
  value,
  alreadySet = False,
  kw 
)
CMF compatibility method

Changing the event type changes also the subject.

Definition at line 203 of file event.py.

00203 
00204     def setEventType(self, value, alreadySet=False, **kw):
00205         """CMF compatibility method
00206 
00207         Changing the event type changes also the subject.
00208         """
00209         if type(value) is StringType:
00210             value = (value,)
00211         elif not value:
00212             # mostly harmless?
00213             value = ()
00214         f = self.getField('eventType')
00215         f.set(self, value, **kw) # set is ok
00216         if not alreadySet:
00217             self.setSubject(value, alreadySet=True, **kw)

Here is the call graph for this function:

Here is the caller graph for this function:

def ATContentTypes.content.event.ATEvent.setSubject (   self,
  value,
  alreadySet = False,
  kw 
)
CMF compatibility method

Changing the subject changes also the event type.

Definition at line 219 of file event.py.

00219 
00220     def setSubject(self, value, alreadySet=False, **kw):
00221         """CMF compatibility method
00222 
00223         Changing the subject changes also the event type.
00224         """
00225         f = self.getField('subject')
00226         f.set(self, value, **kw) # set is ok
00227 
00228         # set the event type to the first subject
00229         if type(value) is StringType:
00230             v = (value, )
00231         elif value:
00232             v = value
00233         else:
00234             v = ()
00235 
00236         if not alreadySet:
00237             self.setEventType(v, alreadySet=True, **kw)

Here is the call graph for this function:

Here is the caller graph for this function:

def ATContentTypes.content.event.ATEvent.update (   self,
  event = None,
  kwargs 
)

Definition at line 376 of file event.py.

00376 
00377     def update(self, event=None, **kwargs):
00378         # Clashes with BaseObject.update, so
00379         # we handle gracefully
00380         info = {}
00381         if event is not None:
00382             for field in event.Schema().fields():
00383                 info[field.getName()] = event[field.getName()]
00384         elif kwargs:
00385             info = kwargs
00386         ATCTContent.update(self, **info)
00387 
00388 registerATCT(ATEvent, PROJECTNAME)

Here is the call graph for this function:

Here is the caller graph for this function:


Member Data Documentation

Initial value:
(ATCTContent.__implements__, IATEvent,
                      CalendarSupportMixin.__implements__,
                      HistoryAwareMixin.__implements__)

Definition at line 196 of file event.py.

dictionary ATContentTypes.content.event.ATEvent._atct_newTypeFor = {'portal_type' : 'CMF Event', 'meta_type' : 'CMF Event'} [static, private]

Definition at line 187 of file event.py.

Definition at line 186 of file event.py.

Definition at line 189 of file event.py.

Definition at line 188 of file event.py.

Initial value:
('effectiveDay', 'effectiveMo', 'effectiveYear',
                      'expirationDay', 'expirationMo', 'expirationYear',
                      'start_time', 'startAMPM', 'stop_time', 'stopAMPM',
                      'start_date', 'end_date', 'contact_name', 'contact_email',
                      'contact_phone', 'event_url')

Definition at line 190 of file event.py.

tuple ATContentTypes.content.event.ATEvent.duration = ComputedAttribute(_duration) [static]

Definition at line 347 of file event.py.

tuple ATContentTypes.content.event.ATEvent.end_date = ComputedAttribute(_end_date) [static]

Definition at line 341 of file event.py.

Definition at line 185 of file event.py.

Definition at line 183 of file event.py.

tuple ATContentTypes.content.event.ATEvent.security = ClassSecurityInfo() [static]

Definition at line 200 of file event.py.

tuple ATContentTypes.content.event.ATEvent.start_date = ComputedAttribute(_start_date) [static]

Definition at line 332 of file event.py.


The documentation for this class was generated from the following file: