diff options
| author | lwang | 2013-02-26 16:54:41 +0100 |
|---|---|---|
| committer | lwang | 2013-02-26 16:54:41 +0100 |
| commit | e8cc20898cce3b4249411eb188fefc211db79c63 (patch) | |
| tree | e7e8d2f250dfa59ecbd7449b3cdf5d67ade84a22 | |
| parent | ced4e122d9204e0e507f0a34c53f978c4d73c45d (diff) | |
| download | chouette-core-e8cc20898cce3b4249411eb188fefc211db79c63.tar.bz2 | |
complete api v1 for group lines, access points and access links
| -rw-r--r-- | app/controllers/api/v1/access_links_controller.rb | 14 | ||||
| -rw-r--r-- | app/controllers/api/v1/access_points_controller.rb | 13 | ||||
| -rw-r--r-- | app/controllers/api/v1/group_of_lines_controller.rb | 12 | ||||
| -rw-r--r-- | app/views/api/v1/access_links/index.rabl | 4 | ||||
| -rw-r--r-- | app/views/api/v1/access_links/short_description.rabl | 6 | ||||
| -rw-r--r-- | app/views/api/v1/access_links/show.rabl | 6 | ||||
| -rw-r--r-- | app/views/api/v1/access_points/index.rabl | 4 | ||||
| -rw-r--r-- | app/views/api/v1/access_points/short_description.rabl | 6 | ||||
| -rw-r--r-- | app/views/api/v1/access_points/show.rabl | 9 | ||||
| -rw-r--r-- | app/views/api/v1/group_of_lines/index.rabl | 4 | ||||
| -rw-r--r-- | app/views/api/v1/group_of_lines/short_description.rabl | 6 | ||||
| -rw-r--r-- | app/views/api/v1/group_of_lines/show.rabl | 6 | ||||
| -rw-r--r-- | config/routes.rb | 3 |
13 files changed, 93 insertions, 0 deletions
diff --git a/app/controllers/api/v1/access_links_controller.rb b/app/controllers/api/v1/access_links_controller.rb new file mode 100644 index 000000000..1b9c98538 --- /dev/null +++ b/app/controllers/api/v1/access_links_controller.rb @@ -0,0 +1,14 @@ +class Api::V1::AccessLinksController < Api::V1::ChouetteController + + defaults :resource_class => Chouette::AccessLink, :finder => :find_by_objectid! + +protected + + def collection + @access_links ||= ( @referential ? @referential.access_links.search(params[:q]).result(:distinct => true) : []) + + end + +end + + diff --git a/app/controllers/api/v1/access_points_controller.rb b/app/controllers/api/v1/access_points_controller.rb new file mode 100644 index 000000000..4c3f5adc0 --- /dev/null +++ b/app/controllers/api/v1/access_points_controller.rb @@ -0,0 +1,13 @@ +class Api::V1::AccessPointsController < Api::V1::ChouetteController + + defaults :resource_class => Chouette::AccessPoint, :finder => :find_by_objectid! + +protected + + def collection + @access_points ||= ( @referential ? @referential.access_points.search(params[:q]).result(:distinct => true) : []) + + end + +end + diff --git a/app/controllers/api/v1/group_of_lines_controller.rb b/app/controllers/api/v1/group_of_lines_controller.rb new file mode 100644 index 000000000..b3760e1b0 --- /dev/null +++ b/app/controllers/api/v1/group_of_lines_controller.rb @@ -0,0 +1,12 @@ +class Api::V1::GroupOfLinesController < Api::V1::ChouetteController + + defaults :resource_class => Chouette::GroupOfLine, :finder => :find_by_objectid! + +protected + + def collection + @group_of_lines ||= ( @referential ? @referential.group_of_lines.search(params[:q]).result(:distinct => true) : []) + + end + +end
\ No newline at end of file diff --git a/app/views/api/v1/access_links/index.rabl b/app/views/api/v1/access_links/index.rabl new file mode 100644 index 000000000..fb9c8d728 --- /dev/null +++ b/app/views/api/v1/access_links/index.rabl @@ -0,0 +1,4 @@ +collection @access_links + +extends "api/v1/access_links/show" + diff --git a/app/views/api/v1/access_links/short_description.rabl b/app/views/api/v1/access_links/short_description.rabl new file mode 100644 index 000000000..5c37de47c --- /dev/null +++ b/app/views/api/v1/access_links/short_description.rabl @@ -0,0 +1,6 @@ +object @access_link +extends "api/v1/trident_objects/short_description" + +[ :name, :short_name, :registration_number].each do |attr| + attributes attr, :unless => lambda { |m| m.send( attr).nil?} +end diff --git a/app/views/api/v1/access_links/show.rabl b/app/views/api/v1/access_links/show.rabl new file mode 100644 index 000000000..5dbbec81b --- /dev/null +++ b/app/views/api/v1/access_links/show.rabl @@ -0,0 +1,6 @@ +object @access_link +extends "api/v1/trident_objects/show" + +[:access_point_id , :comment , :creation_time , :creator_id , :default_duration , :frequent_traveller_duration , :int_user_needs , :lift_availability , :link_distance , :link_orientation , :link_type , :mobility_restricted_suitability , :mobility_restricted_traveller_duration , :name , :occasional_traveller_duration , :stairs_availability , :stop_area_id].each do |attr| + attributes attr, :unless => lambda { |m| m.send( attr).nil?} +end diff --git a/app/views/api/v1/access_points/index.rabl b/app/views/api/v1/access_points/index.rabl new file mode 100644 index 000000000..68037f89f --- /dev/null +++ b/app/views/api/v1/access_points/index.rabl @@ -0,0 +1,4 @@ +collection @access_points + +extends "api/v1/access_points/show" + diff --git a/app/views/api/v1/access_points/short_description.rabl b/app/views/api/v1/access_points/short_description.rabl new file mode 100644 index 000000000..e1786a51d --- /dev/null +++ b/app/views/api/v1/access_points/short_description.rabl @@ -0,0 +1,6 @@ +object @access_point +extends "api/v1/trident_objects/short_description" + +[ :name, :short_name, :registration_number].each do |attr| + attributes attr, :unless => lambda { |m| m.send( attr).nil?} +end diff --git a/app/views/api/v1/access_points/show.rabl b/app/views/api/v1/access_points/show.rabl new file mode 100644 index 000000000..76e43a9e5 --- /dev/null +++ b/app/views/api/v1/access_points/show.rabl @@ -0,0 +1,9 @@ +object @access_point +extends "api/v1/trident_objects/show" + +[ :name, :comment, :longitude, :latitude, :long_lat_type, + :x , :y , :projection_type, :country_code, :street_name, :contained_in, + :openning_time, :closing_time, :access_type, :lift_availability, + :mobility_restricted_suitability, :stairs_availability, :stop_area_id].each do |attr| + attributes attr, :unless => lambda { |m| m.send( attr).nil?} +end diff --git a/app/views/api/v1/group_of_lines/index.rabl b/app/views/api/v1/group_of_lines/index.rabl new file mode 100644 index 000000000..47b6b6d4e --- /dev/null +++ b/app/views/api/v1/group_of_lines/index.rabl @@ -0,0 +1,4 @@ +collection @group_of_lines + +extends "api/v1/group_of_lines/show" + diff --git a/app/views/api/v1/group_of_lines/short_description.rabl b/app/views/api/v1/group_of_lines/short_description.rabl new file mode 100644 index 000000000..770b334ec --- /dev/null +++ b/app/views/api/v1/group_of_lines/short_description.rabl @@ -0,0 +1,6 @@ +object @group_of_line +extends "api/v1/trident_objects/short_description" + +[ :creator_id, :name].each do |attr| + attributes attr, :unless => lambda { |m| m.send( attr).nil?} +end diff --git a/app/views/api/v1/group_of_lines/show.rabl b/app/views/api/v1/group_of_lines/show.rabl new file mode 100644 index 000000000..96e4bfc58 --- /dev/null +++ b/app/views/api/v1/group_of_lines/show.rabl @@ -0,0 +1,6 @@ +object @group_of_line +extends "api/v1/trident_objects/show" + +[ :creator_id, :name].each do |attr| + attributes attr, :unless => lambda { |m| m.send( attr).nil?} +end diff --git a/config/routes.rb b/config/routes.rb index d2eabf7c5..7928c228a 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -12,6 +12,9 @@ ChouetteIhm::Application.routes.draw do resources :companies, :only => [:index, :show] resources :networks, :only => [:index, :show] resources :stop_areas, :only => [:index, :show] + resources :group_of_lines, :only => [:index, :show] + resources :access_points, :only => [:index, :show] + resources :access_links, :only => [:index, :show] resources :lines, :only => [:index, :show] do resources :journey_patterns, :only => [:index, :show] resources :routes, :only => [:index, :show] do |
