diff options
| author | Michel Etienne | 2012-11-06 18:53:29 +0100 | 
|---|---|---|
| committer | Michel Etienne | 2012-11-06 18:53:29 +0100 | 
| commit | 48842ac1197560b1b7f597e3e1be7c4d93f8d098 (patch) | |
| tree | dfeee03bf8ae1fb2b4a665b61c95bfe33056105f /app/controllers/access_points_controller.rb | |
| parent | c1c4d3fbc9231fe6b1bdd325faced49f33cdf1b2 (diff) | |
| download | chouette-core-48842ac1197560b1b7f597e3e1be7c4d93f8d098.tar.bz2 | |
add access_points and access_links managment
Diffstat (limited to 'app/controllers/access_points_controller.rb')
| -rw-r--r-- | app/controllers/access_points_controller.rb | 54 | 
1 files changed, 54 insertions, 0 deletions
| diff --git a/app/controllers/access_points_controller.rb b/app/controllers/access_points_controller.rb new file mode 100644 index 000000000..4f3c0d717 --- /dev/null +++ b/app/controllers/access_points_controller.rb @@ -0,0 +1,54 @@ +class AccessPointsController < ChouetteController +  defaults :resource_class => Chouette::AccessPoint + +  belongs_to :referential do +    belongs_to :stop_area, :parent_class => Chouette::StopArea, :optional => true, :polymorphic => true +  end + +  respond_to :html, :kml, :xml, :json + + +  def index +    request.format.kml? ? @per_page = nil : @per_page = 12 +    index! +  end + +  def show +    map.editable = false +    @access_links = @access_point.access_link_matrix +    show! do |format| +      unless access_point.position or params[:default] +        format.kml { +          render :nothing => true, :status => :not_found  +        } +         +      end +    end +  end +   +  def edit +    access_point.position ||= access_point.default_position +    map.editable = true +    edit! +  end + + +  protected +   +  alias_method :access_point, :resource + +  def map +    @map = AccessPointMap.new(access_point).with_helpers(self) +  end + +  def collection +    @q = parent.access_points.search(params[:q]) +    @access_points ||=  +      begin +        access_points = @q.result(:distinct => true).order(:name) +        access_points = access_points.paginate(:page => params[:page]) if @per_page.present? +        access_points +      end +  end + +end | 
