[gen] Calendar event: better rendering for timeslots.
This commit is contained in:
parent
9934f6d7c9
commit
d1aec8d5e6
|
@ -80,11 +80,15 @@ class Event(Persistent):
|
||||||
self.eventType = eventType
|
self.eventType = eventType
|
||||||
self.timeslot = timeslot
|
self.timeslot = timeslot
|
||||||
|
|
||||||
def getName(self, allEventNames):
|
def getName(self, allEventNames, xhtml=True):
|
||||||
'''Gets the name for this event, that depends on it type and may include
|
'''Gets the name for this event, that depends on it type and may include
|
||||||
the timeslot if not "main".'''
|
the timeslot if not "main".'''
|
||||||
res = allEventNames[self.eventType]
|
res = allEventNames[self.eventType]
|
||||||
if self.timeslot != 'main': res += ' ' + self.timeslot
|
if self.timeslot != 'main':
|
||||||
|
# Prefix it with the timeslot
|
||||||
|
prefix = xhtml and ('<b>[%s]</b> ' % self.timeslot) or \
|
||||||
|
('[%s] ' % self.timeslot)
|
||||||
|
res = '%s%s' % (prefix, res)
|
||||||
return res
|
return res
|
||||||
|
|
||||||
def sameAs(self, other):
|
def sameAs(self, other):
|
||||||
|
@ -328,7 +332,7 @@ class Calendar(Field):
|
||||||
<!-- Events -->
|
<!-- Events -->
|
||||||
<x if="events">
|
<x if="events">
|
||||||
<div for="event in events" style="color: grey">
|
<div for="event in events" style="color: grey">
|
||||||
<x>:event.getName(allEventNames)</x>
|
<x>::event.getName(allEventNames)</x>
|
||||||
<!-- Icon for delete this particular event -->
|
<!-- Icon for delete this particular event -->
|
||||||
<img if="mayDelete and not single" class="clickable"
|
<img if="mayDelete and not single" class="clickable"
|
||||||
src=":url('delete')" style="visibility:hidden"
|
src=":url('delete')" style="visibility:hidden"
|
||||||
|
@ -714,7 +718,7 @@ class Calendar(Field):
|
||||||
|
|
||||||
def getEventsAt(self, obj, date):
|
def getEventsAt(self, obj, date):
|
||||||
'''Returns the list of events that exist at some p_date (=day).'''
|
'''Returns the list of events that exist at some p_date (=day).'''
|
||||||
obj = obj.o # Ensure p_obj is not a wrapper.
|
obj = obj.o # Ensure p_obj is not a wrapper
|
||||||
if not hasattr(obj.aq_base, self.name): return
|
if not hasattr(obj.aq_base, self.name): return
|
||||||
years = getattr(obj, self.name)
|
years = getattr(obj, self.name)
|
||||||
year = date.year()
|
year = date.year()
|
||||||
|
@ -950,8 +954,8 @@ class Calendar(Field):
|
||||||
events.append(Event(eventType))
|
events.append(Event(eventType))
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def createEvent(self, obj, date, timeslot, eventType=None, eventSpan=None,
|
def createEvent(self, obj, date, timeslot='main', eventType=None,
|
||||||
handleEventSpan=True):
|
eventSpan=None, handleEventSpan=True):
|
||||||
'''Create a new event in the calendar, at some p_date (day).
|
'''Create a new event in the calendar, at some p_date (day).
|
||||||
If p_eventType is given, it is used; else, rq['eventType'] is used.
|
If p_eventType is given, it is used; else, rq['eventType'] is used.
|
||||||
If p_handleEventSpan is True, we will use p_eventSpan (or
|
If p_handleEventSpan is True, we will use p_eventSpan (or
|
||||||
|
|
Loading…
Reference in a new issue