# HG changeset patch # User Paul Boddie # Date 1238028033 -3600 # Node ID 146d489146986a1b561fa842bb5db7cc5f95400a # Parent f88e0568aaf84ef2a93d919f4d3a2064236ec2d9 Prevent multiple inclusion of events via many categories. Added year-relative start and end parameter values. Added a sample category page. diff -r f88e0568aaf8 -r 146d48914698 EventAggregatorSupport.py --- a/EventAggregatorSupport.py Thu Mar 26 01:04:02 2009 +0100 +++ b/EventAggregatorSupport.py Thu Mar 26 01:40:33 2009 +0100 @@ -120,6 +120,13 @@ today = datetime.date.today() return (today.year, today.month) +def getCurrentYear(): + + "Return the current year." + + today = datetime.date.today() + return today.year + def monthupdate(date, n): "Return 'date' updated by 'n' months." @@ -263,6 +270,7 @@ events = [] shown_events = {} all_shown_events = [] + processed_pages = set() earliest = None latest = None @@ -278,6 +286,13 @@ for page_in_category in pages_in_category: pagename = page_in_category.page_name + # Only process each page once. + + if pagename in processed_pages: + continue + else: + processed_pages.add(pagename) + # Get a real page, not a result page. real_page_in_category = Page(request, pagename) diff -r f88e0568aaf8 -r 146d48914698 macros/EventAggregator.py --- a/macros/EventAggregator.py Thu Mar 26 01:04:02 2009 +0100 +++ b/macros/EventAggregator.py Thu Mar 26 01:40:33 2009 +0100 @@ -45,13 +45,29 @@ # Macro functions. def getMonth(arg): + n = None + if arg.startswith("current"): date = EventAggregatorSupport.getCurrentMonth() if len(arg) > 8: n = int(arg[7:]) - date = EventAggregatorSupport.monthupdate(date, n) + + elif arg.startswith("yearstart"): + date = (EventAggregatorSupport.getCurrentYear(), 1) + if len(arg) > 10: + n = int(arg[9:]) + + elif arg.startswith("yearend"): + date = (EventAggregatorSupport.getCurrentYear(), 12) + if len(arg) > 8: + n = int(arg[7:]) + else: date = EventAggregatorSupport.getMonth(arg) + + if n is not None: + date = EventAggregatorSupport.monthupdate(date, n) + return date def getFormMonth(request, calendar_name, argname): diff -r f88e0568aaf8 -r 146d48914698 pages/CategoryEvents --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/pages/CategoryEvents Thu Mar 26 01:40:33 2009 +0100 @@ -0,0 +1,17 @@ +##master-page:CategoryTemplate +##master-date:Unknown-Date +#format wiki +#language en + +The events category. Here are the current month's events: + +<> + +To add a page to this category, add a link to this page on the last line of the page. You can add multiple categories to a page. + +'''List of pages in this category:''' + +<> + +---- +CategoryCategory