summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFrédéric Péters <fpeters@entrouvert.com>2011-12-07 19:56:20 (GMT)
committerFrédéric Péters <fpeters@entrouvert.com>2011-12-07 19:56:20 (GMT)
commit53ea38c2fa9ce7470c5cc8c62ef0e3b873a349f0 (patch)
tree0f42aba5c55acbf7687c30bcc41597d3069e04fa
parentd3d25d2c7df201f5dcf1ecff5348f255d3759be3 (diff)
downloadtabellio.webviews-53ea38c2fa9ce7470c5cc8c62ef0e3b873a349f0.zip
tabellio.webviews-53ea38c2fa9ce7470c5cc8c62ef0e3b873a349f0.tar.gz
tabellio.webviews-53ea38c2fa9ce7470c5cc8c62ef0e3b873a349f0.tar.bz2
display all day events, and move event title up (#1111)
-rw-r--r--tabellio/webviews/misc.py39
-rw-r--r--tabellio/webviews/pcfhome_folder.pt8
2 files changed, 29 insertions, 18 deletions
diff --git a/tabellio/webviews/misc.py b/tabellio/webviews/misc.py
index d8e8aa8..255a00d 100644
--- a/tabellio/webviews/misc.py
+++ b/tabellio/webviews/misc.py
@@ -71,25 +71,33 @@ class PcfHomeFolder(BrowserView):
return None
return l[0].getObject()
- def get_event(self):
+ def get_coming_day_events(self):
catalog = getToolByName(self.context, 'portal_catalog')
# do not go more than 100 days in the future
- start = datetime.datetime.now()
+ start = datetime.datetime.today()
end = start + datetime.timedelta(100)
+ calendar = getToolByName(self.context, 'portal_calendar')
r = catalog(
- portal_type=['tabellio.agenda.comevent', 'tabellio.agenda.parlevent'],
+ portal_type=['tabellio.agenda.comevent',
+ 'tabellio.agenda.parlevent',
+ 'tabellio.agenda.event'],
+ review_state=calendar.getCalendarStates(),
start={'query': start, 'range': 'min'},
sort_on='start')
if len(r) == 0:
return None
- return r[0].getObject()
+ day = r[0].getObject().start.timetuple()[:3]
+ return [x.getObject() for x in r if x.start.timetuple()[:3] == day]
def next_event_url(self):
- context = self.get_event()
- catalog = getToolByName(context, 'portal_catalog')
+ try:
+ current_event = self.get_coming_day_events()[-1]
+ except (TypeError, IndexError):
+ return None
+ catalog = getToolByName(self.context, 'portal_catalog')
# do not go more than 100 days in the future
- end = context.start + datetime.timedelta(100)
- start = context.start
+ end = current_event.start + datetime.timedelta(100)
+ start = current_event.start
monthly_view = MonthlyView(self.context, init_calendar=True)
serie_of_events = monthly_view.get_events_from_catalog(
start, end, portal_type=['tabellio.agenda.parlevent',
@@ -97,7 +105,7 @@ class PcfHomeFolder(BrowserView):
'tabellio.agenda.event'])
for i, event in enumerate(serie_of_events):
event_id = ((type(event.getId) is str) and event.getId or event.getId())
- if event_id == context.id:
+ if event_id == current_event.id:
try:
return serie_of_events[i+1].getURL()
except IndexError:
@@ -105,11 +113,14 @@ class PcfHomeFolder(BrowserView):
return None
def previous_event_url(self):
- context = self.get_event()
- catalog = getToolByName(context, 'portal_catalog')
- end = context.start
+ try:
+ current_event = self.get_coming_day_events()[0]
+ except (TypeError, IndexError):
+ return None
+ catalog = getToolByName(self.context, 'portal_catalog')
+ end = current_event.start + datetime.timedelta(1)
# do not go back more than 100 days in the past
- start = context.start - datetime.timedelta(100)
+ start = current_event.start - datetime.timedelta(100)
monthly_view = MonthlyView(self.context, init_calendar=True)
serie_of_events = monthly_view.get_events_from_catalog(
start, end, portal_type=['tabellio.agenda.parlevent',
@@ -117,7 +128,7 @@ class PcfHomeFolder(BrowserView):
'tabellio.agenda.event'])
for i, event in enumerate(serie_of_events):
event_id = ((type(event.getId) is str) and event.getId or event.getId())
- if event_id == context.id:
+ if event_id == current_event.id:
if i == 0:
return None
return serie_of_events[i-1].getURL()
diff --git a/tabellio/webviews/pcfhome_folder.pt b/tabellio/webviews/pcfhome_folder.pt
index dc233bc..522c3ac 100644
--- a/tabellio/webviews/pcfhome_folder.pt
+++ b/tabellio/webviews/pcfhome_folder.pt
@@ -103,12 +103,12 @@ jQuery(document).ready(function(){
<a class="more-link" href="#" tal:attributes="href homenews/absolute_url">plus</a>
</dd>
</tal:block>
- <tal:block tal:define="event view/get_event" tal:condition="event">
+ <tal:block tal:define="events view/get_coming_day_events" tal:condition="events">
<dt id="fieldset-legend-agenda">Agenda</dt>
<dd id="fieldset-agenda"
tal:define="previous_url view/previous_event_url;
next_url view/next_event_url;">
- <div>
+ <div tal:define="event python: events[0]">
<div class="blocdate">
<a tal:condition="previous_url" class="previous" href="#" tal:attributes="href previous_url">←</a>
<div class="date">
@@ -117,11 +117,11 @@ jQuery(document).ready(function(){
</div>
<a tal:condition="next_url" class="next" href="#" tal:attributes="href next_url">→</a>
</div>
- <div class="event-description">
+ <div tal:repeat="event events" tal:attributes="class string:event-description ${event/klass}">
+ <h3 class="event-title"><span class="event-type-square">■</span><span tal:replace="event/Title"/></h3>
<div class="event-hour">À <span tal:content="event/start/hour">14</span> heures <span tal:condition="event/start/minute" tal:content="event/start/minute">00</span></div>
<div class="place" tal:content="event/place">Salle des séances - Hôtel de Ligne</div>
<div class="description">
- <p tal:content="event/Title">Séance</p>
<p tal:content="event/description">
L'heure des questions d'actualité est fixée à 14 heures.
</p>