From d2c9bab406559241b9a80d0e183268a6abff3aa0 Mon Sep 17 00:00:00 2001 From: Bezleputh Date: Thu, 28 Nov 2013 13:40:33 +0100 Subject: [PATCH] [ICapCalendar] update fields to be more strict in BaseCalendarEvent --- weboob/capabilities/calendar.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/weboob/capabilities/calendar.py b/weboob/capabilities/calendar.py index 09d530e8..d75f6f41 100644 --- a/weboob/capabilities/calendar.py +++ b/weboob/capabilities/calendar.py @@ -26,9 +26,11 @@ def enum(**enums): _values = enums.values() _items = enums.items() _index = dict((value, i) for i, value in enumerate(enums.values())) + _types = list((type(value) for value in enums.values())) enums['values'] = _values enums['items'] = _items enums['index'] = _index + enums['types'] = _types return type('Enum', (), enums) CATEGORIES = enum(CONCERT=u'Concert', CINE=u'Cinema', THEATRE=u'Theatre') @@ -50,7 +52,7 @@ class BaseCalendarEvent(CapBaseObject): summary = StringField('Title of the event') city = StringField('Name of the city in witch event will take place') location = StringField('Location of the event') - category = StringField('Category of the event') + category = Field('Category of the event', *CATEGORIES.types) description = StringField('Description of the event') price = FloatField('Price of the event') booked_entries = IntField('Entry number') @@ -62,9 +64,9 @@ class BaseCalendarEvent(CapBaseObject): sequence = IntField('Number of updates, the first is number 1') # (TENTATIVE, CONFIRMED, CANCELLED) - status = StringField('Status of theevent') + status = Field('Status of theevent', *STATUS.types) # (OPAQUE, TRANSPARENT) - transp = StringField('Describes if event is available') + transp = Field('Describes if event is available', *TRANSP.types) @classmethod def id2url(cls, _id):