Skip to content

Commit

Permalink
Add new fields to Itinerary resource.
Browse files Browse the repository at this point in the history
* variation_id, reference to self variation.
* variations, a list of Itinerary models
* valid_during_ranges, a list of date ranges
  • Loading branch information
bartek committed Jul 23, 2015
1 parent 46201a0 commit f579625
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions gapipy/resources/tour/itinerary.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

from ..base import Resource
from ...models.base import BaseModel
from ...utils import duration_label, LocationLabelMixin, DurationLabelMixin
from ...utils import DurationLabelMixin, LocationLabelMixin, duration_label


class OptionalActivity(BaseModel):
Expand Down Expand Up @@ -77,18 +77,27 @@ def __repr__(self):
return '<{} {}>'.format(self.__class__.__name__, self.day)


class ValidDuringRange(BaseModel):
_date_fields = ['start_date', 'end_date']

def __repr__(self):
return '<{} ({} - {})>'.format(self.__class__.__name__, self.start_date, self.end_date)


class Itinerary(Resource):

_resource_name = 'itineraries'

_as_is_fields = [
'id', 'href', 'name', 'duration', 'meals_included', 'meals_budget',
'packing_lists', 'images',
'packing_lists', 'images', 'variation_id',
]
_resource_fields = [
('start_location', 'Place'),
('end_location', 'Place'),
]
_model_collection_fields = [
('days', ItineraryDay),
('variations', 'Itinerary'),
('valid_during_ranges', ValidDuringRange),
]

0 comments on commit f579625

Please sign in to comment.