[biplan] fix bugs
This commit is contained in:
parent
0ff2abb2fd
commit
51ddda4bf9
4 changed files with 19 additions and 6 deletions
|
|
@ -28,6 +28,14 @@ from.calendar import BiplanCalendarEvent
|
|||
__all__ = ['BiplanBackend']
|
||||
|
||||
|
||||
def cmp_start_date(p1, p2):
|
||||
if p1.start_date == p2.start_date:
|
||||
return 0
|
||||
if p1.start_date > p2.start_date:
|
||||
return 1
|
||||
return -1
|
||||
|
||||
|
||||
class BiplanBackend(BaseBackend, ICapCalendarEvent):
|
||||
NAME = 'biplan'
|
||||
DESCRIPTION = u'lebiplan.org website'
|
||||
|
|
@ -53,11 +61,15 @@ class BiplanBackend(BaseBackend, ICapCalendarEvent):
|
|||
query.city,
|
||||
query.categories)
|
||||
|
||||
return itertools.chain(concert_events, theatre_events)
|
||||
items = list(itertools.chain(concert_events, theatre_events))
|
||||
items.sort(cmp=cmp_start_date)
|
||||
return items
|
||||
|
||||
def list_events(self, date_from, date_to=None):
|
||||
return itertools.chain(self.browser.list_events_concert(date_from, date_to),
|
||||
self.browser.list_events_theatre(date_from, date_to))
|
||||
items = list(itertools.chain(self.browser.list_events_concert(date_from, date_to),
|
||||
self.browser.list_events_theatre(date_from, date_to)))
|
||||
items.sort(cmp=cmp_start_date)
|
||||
return items
|
||||
|
||||
def get_event(self, _id):
|
||||
return self.browser.get_event(_id)
|
||||
|
|
|
|||
|
|
@ -43,7 +43,7 @@ class BiplanBrowser(PagesBrowser):
|
|||
date_to=date_to,
|
||||
city=city,
|
||||
categories=categories,
|
||||
is_Concert=False)
|
||||
is_concert=False)
|
||||
|
||||
def get_event(self, _id, event=None):
|
||||
return self.event_page.go(_id=_id).get_event(obj=event)
|
||||
|
|
|
|||
|
|
@ -38,6 +38,6 @@ class BiplanCalendarEventConcert(BiplanCalendarEvent):
|
|||
|
||||
|
||||
class BiplanCalendarEventTheatre(BiplanCalendarEvent):
|
||||
def __init__(self, _id):
|
||||
def __init__(self):
|
||||
BiplanCalendarEvent.__init__(self)
|
||||
self.category = CATEGORIES.THEATRE
|
||||
|
|
|
|||
|
|
@ -85,7 +85,8 @@ class ProgramPage(HTMLPage):
|
|||
item_xpath = '//div[@class="ligne"]'
|
||||
|
||||
class item(ItemElement):
|
||||
klass = BiplanCalendarEventConcert if Env('is_concert') else BiplanCalendarEventTheatre
|
||||
def klass(self):
|
||||
return BiplanCalendarEventConcert() if self.env['is_concert'] else BiplanCalendarEventTheatre()
|
||||
|
||||
def condition(self):
|
||||
return (self.el.xpath('./div'))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue