changeset 238:5f5d7f07c1bd

added "show only upcoming" option for talks from calendar.
author casties
date Fri, 24 Jan 2014 16:19:35 +0100
parents 45ef92d6aa8c
children 452d4c28f176
files MPIWGStaff.py zpt/staff/edit_talks.zpt zpt/staff/member_index_html.zpt
diffstat 3 files changed, 24 insertions(+), 13 deletions(-) [+]
line wrap: on
line diff
--- a/MPIWGStaff.py	Wed Jan 08 14:24:36 2014 +0100
+++ b/MPIWGStaff.py	Fri Jan 24 16:19:35 2014 +0100
@@ -572,18 +572,22 @@
                 cal_id = "%s_talks"%self.getUsername()
                 # use ICS calendar
                 cal = self.getTalksCal()
-                if cal is not None:
+                if cal is None:
+                    # create new calendar
+                    cal = MPIWGIcsManager(cal_id, '', url, defaultProps=calendar_props)
+                    self.folder.get('calendars')[cal_id] = cal
+                    
+                else:
                     # calendar exists
-                    if cal.url == url:
-                        # same url
-                        return pt()
-                    else:
-                        # remove
+                    if cal.url != url:
+                        # remove and re-create
                         del self.folder.get('calendars')[cal_id]
+                        cal = MPIWGIcsManager(cal_id, '', url, defaultProps=calendar_props)
+                        self.folder.get('calendars')[cal_id] = cal
 
-                # create new calendar
-                cal = MPIWGIcsManager(cal_id, '', url, defaultProps=calendar_props)
-                self.folder.get('calendars')[cal_id] = cal
+                # show only upcoming
+                upcoming = argv.get('only_upcoming', None)
+                cal.setFlag('only_upcoming', (upcoming == 'yes'))
                 
             # manually edited talks
             elif argv.has_key('main_fields'): #got data to change
--- a/zpt/staff/edit_talks.zpt	Wed Jan 08 14:24:36 2014 +0100
+++ b/zpt/staff/edit_talks.zpt	Fri Jan 24 16:19:35 2014 +0100
@@ -70,6 +70,11 @@
   <p tal:condition="cal">
   Remove the calendar URL to enter talks manually.
   </p>
+  <p tal:condition="cal">
+    <tal:block tal:define="name string:only_upcoming; value python:test(cal.getFlag('only_upcoming'), 'yes', 'no');">
+      Show only upcoming events from the calendar: <span metal:use-macro="here/common_template/macros/yesno_input_radio"/>
+    </tal:block>    
+  </p>
   
   <p>
     <input type="submit" value="submit"/>
--- a/zpt/staff/member_index_html.zpt	Wed Jan 08 14:24:36 2014 +0100
+++ b/zpt/staff/member_index_html.zpt	Fri Jan 24 16:19:35 2014 +0100
@@ -75,21 +75,23 @@
     <!-- Talks -->
     <tal:block tal:define="calendar member/getTalksCal">
       <tal:block tal:condition="calendar">
-        <tal:block tal:define="talks python:calendar.getNext(6)" tal:condition="talks">
+        <tal:block tal:define="upcoming python:calendar.getFlag('only_upcoming'); 
+            talks python:test(upcoming, calendar.getAllItemsFromTodayOn(newestFirst=True)[:5], calendar.getNext(5))" tal:condition="talks">
         
-          <h2 class="line">Talks and presentations</h2>
+          <h2 class="line" tal:condition="upcoming">Upcoming talks and presentations</h2>
+          <h2 class="line" tal:condition="not:upcoming">Talks and presentations</h2>
 
           <table class="items shorter">
             <tr tal:repeat="talk talks">
               <tal:block tal:define="url python:talk.getValue('url')">
                 <td width="25%" tal:content="python:talk.getDate()" />
-                <td><a tal:omit-tag="not:url" tal:attributes="href url"> <span tal:replace="python:talk.getValue('location')" />
+                <td><a class="external" target="_blank" tal:omit-tag="not:url" tal:attributes="href url"><span tal:replace="python:talk.getValue('location')" />
                     &#150; <i><span tal:replace="python:talk.getValue('title')" /></i>
                 </a></td>
               </tal:block>
             </tr>
           </table>
-          <p tal:condition="python:len(talks)>5">
+          <p tal:condition="python:len(calendar.getItems())>5">
             <a class="internal" tal:attributes="href string:$baseUrl/talks_full_html">More</a>
           </p>
         </tal:block>