# Path: wprevents/events/api.py
# class EventResource(CustomResource):
#   class Meta:
#     queryset = Event.objects.all()
#     fields = ['id', 'title', 'slug', 'start', 'end', 'city', 'country', 'description']
#     filtering = {
#       "title": ('startswith',),
#     }
# 
#     allowed_methods = ['get']
#     include_resource_uri = False
#     include_absolute_url = False
# 
#     serializer = CustomSerializer(formats=['json', 'csv', 'ical'])
# 
#   def dehydrate(self, bundle):
#     if bundle.obj.space:
#       bundle.data['space'] = bundle.obj.space.name
#     bundle.data['functional_areas'] = ','.join(bundle.obj.area_names)
# 
#     return bundle
# 
# class InstanceResource(CustomResource):
#   class Meta:
#     queryset = Instance.objects.all()
#     fields = ['id', 'start', 'end']
#     allowed_methods = ['get']
#     include_resource_uri = False
#     include_absolute_url = False
# 
#     serializer = CustomSerializer(formats=['csv', 'ical'])
# 
#   def dehydrate(self, bundle):
#     if bundle.obj.event:
#       bundle.data['event_id'] = bundle.obj.event.id
#       bundle.data['title'] = bundle.obj.event.title
#       bundle.data['slug'] = bundle.obj.event.slug
#       bundle.data['description'] = bundle.obj.event.description
#       bundle.data['functional_areas'] = ','.join(bundle.obj.event.area_names)
#       if bundle.obj.event.space:
#         bundle.data['space'] = bundle.obj.event.space.name
# 
#     return bundle
# 
# class SpaceResource(CustomResource):
#   class Meta:
#     queryset = Space.objects.all()
#     fields = ['name', 'address', 'address2', 'city', 'country', 'lat', 'lon', 'photo_url']
# 
#     allowed_methods = ['get']
#     include_resource_uri = False
#     include_absolute_url = False
# 
#     serializer = CustomSerializer(formats=['csv'])
# 
# class FunctionalAreaResource(CustomResource):
#   class Meta:
#     queryset = FunctionalArea.objects.all()
#     fields = ['name', 'slug', 'color']
# 
#     allowed_methods = ['get']
#     include_resource_uri = False
#     include_absolute_url = False
# 
#     serializer = CustomSerializer(formats=['csv'])


from django.conf.urls.defaults import include, patterns, url
from tastypie.api import Api
from wprevents.events.api import EventResource, InstanceResource, SpaceResource, FunctionalAreaResource




v1_api = Api(api_name='v1')
v1_api.register(EventResource())
v1_api.register(InstanceResource())
v1_api.register(SpaceResource())
v1_api.register(FunctionalAreaResource())


# Path: wprevents/events/api.py
# class EventResource(CustomResource):
#   class Meta:
#     queryset = Event.objects.all()
#     fields = ['id', 'title', 'slug', 'start', 'end', 'city', 'country', 'description']
#     filtering = {
#       "title": ('startswith',),
#     }
# 
#     allowed_methods = ['get']
#     include_resource_uri = False
#     include_absolute_url = False
# 
#     serializer = CustomSerializer(formats=['json', 'csv', 'ical'])
# 
#   def dehydrate(self, bundle):
#     if bundle.obj.space:
#       bundle.data['space'] = bundle.obj.space.name
#     bundle.data['functional_areas'] = ','.join(bundle.obj.area_names)
# 
#     return bundle
# 
# class InstanceResource(CustomResource):
#   class Meta:
#     queryset = Instance.objects.all()
#     fields = ['id', 'start', 'end']
#     allowed_methods = ['get']
#     include_resource_uri = False
#     include_absolute_url = False
# 
#     serializer = CustomSerializer(formats=['csv', 'ical'])
# 
#   def dehydrate(self, bundle):
#     if bundle.obj.event:
#       bundle.data['event_id'] = bundle.obj.event.id
#       bundle.data['title'] = bundle.obj.event.title
#       bundle.data['slug'] = bundle.obj.event.slug
#       bundle.data['description'] = bundle.obj.event.description
#       bundle.data['functional_areas'] = ','.join(bundle.obj.event.area_names)
#       if bundle.obj.event.space:
#         bundle.data['space'] = bundle.obj.event.space.name
# 
#     return bundle
# 
# class SpaceResource(CustomResource):
#   class Meta:
#     queryset = Space.objects.all()
#     fields = ['name', 'address', 'address2', 'city', 'country', 'lat', 'lon', 'photo_url']
# 
#     allowed_methods = ['get']
#     include_resource_uri = False
#     include_absolute_url = False
# 
#     serializer = CustomSerializer(formats=['csv'])
# 
# class FunctionalAreaResource(CustomResource):
#   class Meta:
#     queryset = FunctionalArea.objects.all()
#     fields = ['name', 'slug', 'color']
# 
#     allowed_methods = ['get']
#     include_resource_uri = False
#     include_absolute_url = False
# 
#     serializer = CustomSerializer(formats=['csv'])


# Path: wprevents/api/urls.py
from django.conf.urls.defaults import include, patterns, url
from tastypie.api import Api
from wprevents.events.api import EventResource, InstanceResource, SpaceResource, FunctionalAreaResource





v1_api = Api(api_name='v1')
v1_api.register(EventResource())
v1_api.register(InstanceResource())
v1_api.register(SpaceResource())
v1_api.register(FunctionalAreaResource())


urlpatterns = patterns('', url(r'', include(v1_api.urls)))