diff options
| author | Alban Peignier | 2012-04-27 13:28:34 +0200 |
|---|---|---|
| committer | Alban Peignier | 2012-04-27 13:28:34 +0200 |
| commit | cca4d6c96bae2bad367eb44e1ba278a02fbe62ae (patch) | |
| tree | 53fa6e6b542d0b90fc1a21425561f24813e30f6d | |
| parent | dbc9af9b80d7a56a8e6ef9331b386fbb02ba98f8 (diff) | |
| parent | ba2527b56c76ca173a8769f1f3cbe949842c96b1 (diff) | |
| download | chouette-core-cca4d6c96bae2bad367eb44e1ba278a02fbe62ae.tar.bz2 | |
Merge branch 'master' of chouette.dryade.priv:/srv/git/chouette2
45 files changed, 866 insertions, 148 deletions
diff --git a/.gitignore b/.gitignore index aa1e11631..953761d7b 100644 --- a/.gitignore +++ b/.gitignore @@ -16,3 +16,6 @@ *~ public/assets/ +# for vim users +*.swp +*.swo @@ -0,0 +1 @@ +rvm jruby-1.6.6 @@ -1,31 +1,35 @@ source 'http://rubygems.org' gem 'rails', '3.1.3' - -# Bundle edge Rails instead: -# gem 'rails', :git => 'git://github.com/rails/rails.git' - -gem 'user_interface', :git => 'git://sim.dryade.priv/user_interface' - -gem 'apartment', :git => 'git://github.com/dryade/apartment.git' - +gem 'jquery-rails' gem 'devise' -gem "map_layers", "~> 0.0.4" - platforms :jruby do gem 'activerecord-jdbcpostgresql-adapter', :git => 'git://github.com/dryade/activerecord-jdbc-adapter.git' gem 'activerecord-jdbcsqlite3-adapter' gem 'jruby-openssl' + gem 'warbler' end platforms :ruby do gem 'pg', '~> 0.11.0' gem 'sqlite3' + gem 'capybara-webkit' end +gem "map_layers", "~> 0.0.4" + +gem 'user_interface', :git => 'git://sim.dryade.priv/user_interface' gem 'json' -gem 'warbler' +gem 'formtastic' +gem 'inherited_resources' +gem 'will_paginate', '~> 3.0' +gem 'ransack' +gem 'squeel' + +gem "acts_as_tree", :git => "git://github.com/dryade/acts_as_tree.git" +gem 'apartment', :git => 'git://github.com/dryade/apartment.git' +gem 'ninoxe', :git => 'git://chouette.dryade.priv/ninoxe'#, :path => '~/projects/ninoxe' # Gems used only for assets and not required # in production environments by default. @@ -37,39 +41,14 @@ group :assets do gem 'therubyrhino' end -gem 'jquery-rails' - -# To use ActiveModel has_secure_password -# gem 'bcrypt-ruby', '~> 3.0.0' - -# Use unicorn as the web server -# gem 'unicorn' - -# Deploy with Capistrano -# gem 'capistrano' - -# To use debugger -# gem 'ruby-debug' - -gem 'formtastic' -gem 'inherited_resources' -gem 'will_paginate', '~> 3.0' -gem 'ransack' -gem 'squeel' -gem 'RedCloth' - -gem 'ninoxe', :git => 'git://chouette.dryade.priv/ninoxe'#, :path => '~/projects/ninoxe' - group :development do - gem 'autotest-rails' - gem 'autotest-notification' gem 'capistrano' gem 'capistrano-ext' gem 'guard' gem 'guard-rspec' end -group :test, :development, :cucumber do +group :test, :development do gem "rspec" gem "rspec-rails" gem "remarkable", "~> 4.0.0.alpha4" @@ -77,20 +56,11 @@ group :test, :development, :cucumber do gem "shoulda", :git => 'git://github.com/thoughtbot/shoulda.git' end -group :cucumber do - gem 'capybara' - gem 'cucumber' - gem 'cucumber-rails' - gem 'launchy' - gem 'pickle', :git => 'git://github.com/mflorisson/pickle.git' -end - -group :test, :cucumber do - gem 'capybara' +group :test do + gem 'capybara' gem 'launchy' gem 'database_cleaner' - gem 'factory_girl_rails' - gem 'factory_girl' + gem 'factory_girl_rails', '1.7' end group :production do diff --git a/Gemfile.lock b/Gemfile.lock index 536c6edca..c22b08942 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,6 +1,6 @@ GIT remote: git://chouette.dryade.priv/ninoxe - revision: be3072bcfbceb597bc74ee7661733ea01110632a + revision: 8b4136d1c06cc03c22443cae4408b5b173dca9b5 specs: ninoxe (0.0.8) GeoRuby @@ -20,20 +20,17 @@ GIT jdbc-sqlite3 (3.7.2) GIT - remote: git://github.com/dryade/apartment.git - revision: cd6185f55eb6d9df958599825e848af4e12a9eae + remote: git://github.com/dryade/acts_as_tree.git + revision: 36ced5234beafdb3b21c2c2e2aa1686d37061497 specs: - apartment (0.14.1) + acts_as_tree (1.1.0) + activerecord (>= 3.0.0) GIT - remote: git://github.com/mflorisson/pickle.git - revision: 4316faa3ef00c414bf286336c57a6d10addcf79f + remote: git://github.com/dryade/apartment.git + revision: cd6185f55eb6d9df958599825e848af4e12a9eae specs: - pickle (0.4.4) - cucumber (>= 0.8) - rake - rspec (>= 1.3) - yard + apartment (0.14.1) GIT remote: git://github.com/thoughtbot/shoulda.git @@ -54,11 +51,8 @@ GEM remote: http://rubygems.org/ specs: GeoRuby (1.3.4) - RedCloth (4.2.9) - RedCloth (4.2.9-java) SyslogLogger (1.4.0) hoe (>= 1.2.0) - ZenTest (4.5.0) actionmailer (3.1.3) actionpack (= 3.1.3) mail (~> 2.3.0) @@ -92,11 +86,6 @@ GEM multi_json (~> 1.0) addressable (2.2.6) arel (2.2.3) - autotest-notification (2.3.4) - autotest-standalone (~> 4.5) - autotest-rails (4.1.1) - ZenTest (= 4.5) - autotest-standalone (4.5.9) bcrypt-ruby (3.0.1) bcrypt-ruby (3.0.1-java) bouncy-castle-java (1.5.0146.1) @@ -116,6 +105,9 @@ GEM rack-test (>= 0.5.4) selenium-webdriver (~> 2.0) xpath (~> 0.1.4) + capybara-webkit (0.11.0) + capybara (>= 1.0.0, < 1.2) + json childprocess (0.3.0) ffi (~> 1.0.6) coffee-rails (3.1.1) @@ -127,16 +119,6 @@ GEM coffee-script-source (1.1.2) composite_primary_keys (4.1.2) activerecord (~> 3.1) - cucumber (1.1.4) - builder (>= 2.1.2) - diff-lcs (>= 1.1.2) - gherkin (~> 2.7.1) - json (>= 1.4.6) - term-ansicolor (>= 1.0.6) - cucumber-rails (1.2.1) - capybara (>= 1.1.2) - cucumber (>= 1.1.3) - nokogiri (>= 1.5.0) database_cleaner (0.7.1) devise (2.0.4) bcrypt-ruby (~> 3.0) @@ -147,10 +129,10 @@ GEM erubis (2.7.0) execjs (1.2.13) multi_json (~> 1.0) - factory_girl (2.5.0) - activesupport - factory_girl_rails (1.6.0) - factory_girl (~> 2.5.0) + factory_girl (2.6.4) + activesupport (>= 2.3.9) + factory_girl_rails (1.7.0) + factory_girl (~> 2.6.0) railties (>= 3.0.0) ffi (1.0.11) ffi (1.0.11-java) @@ -158,10 +140,6 @@ GEM rails (~> 3.0) geokit (1.6.5) multi_json - gherkin (2.7.6) - json (>= 1.4.6) - gherkin (2.7.6-java) - json (>= 1.4.6) guard (1.0.1) ffi (>= 0.5.0) thor (~> 0.14.6) @@ -292,7 +270,6 @@ GEM activerecord (~> 3.0) activesupport (~> 3.0) polyamorous (~> 0.5.0) - term-ansicolor (1.0.7) therubyrhino (1.73.1) thor (0.14.6) tilt (1.3.3) @@ -313,31 +290,26 @@ GEM will_paginate (3.0.3) xpath (0.1.4) nokogiri (~> 1.3) - yard (0.7.4) PLATFORMS java ruby DEPENDENCIES - RedCloth SyslogLogger activerecord-jdbcpostgresql-adapter! activerecord-jdbcsqlite3-adapter + acts_as_tree! apartment! - autotest-notification - autotest-rails capistrano capistrano-ext capybara + capybara-webkit coffee-rails (~> 3.1.1) coffee-script-source - cucumber - cucumber-rails database_cleaner devise - factory_girl - factory_girl_rails + factory_girl_rails (= 1.7) formtastic guard guard-rspec @@ -349,7 +321,6 @@ DEPENDENCIES map_layers (~> 0.0.4) ninoxe! pg (~> 0.11.0) - pickle! rails (= 3.1.3) ransack remarkable (~> 4.0.0.alpha4) diff --git a/app/assets/images/icons/A.png b/app/assets/images/icons/A.png Binary files differnew file mode 100644 index 000000000..3c186dade --- /dev/null +++ b/app/assets/images/icons/A.png diff --git a/app/assets/images/icons/R.png b/app/assets/images/icons/R.png Binary files differnew file mode 100644 index 000000000..c55db80b8 --- /dev/null +++ b/app/assets/images/icons/R.png diff --git a/app/assets/images/icons/link.png b/app/assets/images/icons/link.png Binary files differnew file mode 100644 index 000000000..dcc09c640 --- /dev/null +++ b/app/assets/images/icons/link.png diff --git a/app/assets/images/map/boardingposition.png b/app/assets/images/map/boarding_position.png Binary files differindex f3ffe75d9..f3ffe75d9 100644 --- a/app/assets/images/map/boardingposition.png +++ b/app/assets/images/map/boarding_position.png diff --git a/app/assets/images/map/commercialstoppoint.png b/app/assets/images/map/commercial_stop_point.png Binary files differindex 2c87dc31a..2c87dc31a 100644 --- a/app/assets/images/map/commercialstoppoint.png +++ b/app/assets/images/map/commercial_stop_point.png diff --git a/app/assets/images/map/stopplace.png b/app/assets/images/map/stop_place.png Binary files differindex b5058573e..b5058573e 100644 --- a/app/assets/images/map/stopplace.png +++ b/app/assets/images/map/stop_place.png diff --git a/app/assets/stylesheets/lines.css.scss b/app/assets/stylesheets/lines.css.scss index 6c136af7c..c5370611c 100644 --- a/app/assets/stylesheets/lines.css.scss +++ b/app/assets/stylesheets/lines.css.scss @@ -58,6 +58,7 @@ .line_color{ color: white; font-weight: bold; padding: 0 5px 0 5px;} + h3.routes { clear: both; } .summary p label { font-weight: bold; diff --git a/app/assets/stylesheets/routes.css.scss b/app/assets/stylesheets/routes.css.scss new file mode 100644 index 000000000..c55a4646d --- /dev/null +++ b/app/assets/stylesheets/routes.css.scss @@ -0,0 +1,94 @@ +// Place all the styles related to the routes controller here. +// They will automatically be included in application.css. +// You can use Sass (SCSS) here: http://sass-lang.com/ +@import "common"; + +#workspace.lines.show +{ + .route:after { + @include after_div_for_object; + } + + .routes { + margin-top: 20px; + } + + .routes:after { + @include content_to_clear; + } + + .route { + @include div_for_object; + + /* to create multi-column index */ + width: 350px; + padding-right: 10px; + + .wayback { + width: 16px; + height: 16px; + float: left; + margin-right: 10px; + + a{ margin:0px;} + } + + .name { + line-height: 16px; + float: left; + } + + } +} + +#workspace.routes.edit, #workspace.routes.new +{ + #route_color{ width: 100px; + color: white; + font-weight: bold;} +} + +#workspace.routes.show +{ + .route_color{ color: white; + font-weight: bold; + padding: 0 5px 0 5px;} + + .summary p label { + font-weight: bold; + } + + .stop_area:after { + @include after_div_for_object; + } + + .stop_areas { + margin-top: 20px; + } + + .stop_areas:after { + @include content_to_clear; + } + + .stop_area { + @include div_for_object; + /* to create multi-column index */ + width: 350px; + float: left; + padding-right: 10px; + + .area_type { + width: 25px; + height: 64px; + float: left; + margin-right: 10px; + + + a { + text-decoration: none; + } + } + } + +} + diff --git a/app/assets/stylesheets/stop_areas.css.scss b/app/assets/stylesheets/stop_areas.css.scss index 691fddaa2..60fba8749 100644 --- a/app/assets/stylesheets/stop_areas.css.scss +++ b/app/assets/stylesheets/stop_areas.css.scss @@ -45,8 +45,59 @@ padding-left:15px; } - .summary p label { - font-weight: bold; + .summary{ + height: 400px; + + p label { + font-weight: bold; + } + } + + .genealogical{ + margin-top: 20px; + + .parent{ + border: 2px solid black; + float: left; + padding: 3px 15px 3px 3px; + height: 25px; + * { vertical-align:middle; } + span { margin-left: 7px; } + img { margin: 0px 5px 0px 5px;} + } + + .target{ + border: 2px solid #86b41d; + float: left; + padding: 3px 15px 3px 3px; + height: 25px; + font-weight: bold; + * { vertical-align:middle; } + span { margin-left: 7px; } + img { margin: 0px 5px 0px 5px;} + } + + .children{ + float: left; + + .child{ + border: 2px solid black; + padding: 3px 15px 3px 3px; + height: 25px; + margin-bottom: 5px; + * { vertical-align:middle; } + span { margin-left: 7px; } + img { margin: 0px 5px 0px 5px;} + } + } + + .link{ + float: left; + padding: 7px; + margin-right: 10px; + margin-left: 10px; + height: 25px; + } } } diff --git a/app/controllers/lines_controller.rb b/app/controllers/lines_controller.rb index ac441f3ad..42a126169 100644 --- a/app/controllers/lines_controller.rb +++ b/app/controllers/lines_controller.rb @@ -8,6 +8,7 @@ class LinesController < ChouetteController def show @map = LineMap.new referential, resource + @routes = @line.routes show! end diff --git a/app/controllers/routes_controller.rb b/app/controllers/routes_controller.rb new file mode 100644 index 000000000..55a700315 --- /dev/null +++ b/app/controllers/routes_controller.rb @@ -0,0 +1,53 @@ +class RoutesController < ChouetteController + defaults :resource_class => Chouette::Route + + respond_to :html, :xml, :json + + belongs_to :referential do + belongs_to :line, :parent_class => Chouette::Line, :optional => true, :polymorphic => true + end + + def index + index! do |format| + format.html { redirect_to referential_line_path(@referential,@line) } + end + end + + def show + @stop_areas = resource.stop_areas.paginate(:page => params[:page], :per_page => 10) + show! + end + + def destroy + destroy! do |success, failure| + success.html { redirect_to referential_line_path(@referential,@line) } + end + end + + def create + create! do |success, failure| + success.html { redirect_to referential_line_path(@referential,@line) } + end + end + + def update + update! do |success, failure| + success.html { redirect_to referential_line_path(@referential,@line) } + end + end + protected + + alias_method :route, :resource + + def collection + @q = parent.routes.search(params[:q]) + @routes ||= + begin + routes = @q.result(:distinct => true).order(:name) + routes = routes.paginate(:page => params[:page], :per_page => @per_page) if @per_page.present? + routes + end + end + +end + diff --git a/app/controllers/stop_areas_controller.rb b/app/controllers/stop_areas_controller.rb index 7c73553a8..baca38598 100644 --- a/app/controllers/stop_areas_controller.rb +++ b/app/controllers/stop_areas_controller.rb @@ -6,7 +6,7 @@ class StopAreasController < ChouetteController belongs_to :network, :parent_class => Chouette::Network, :optional => true, :polymorphic => true end - respond_to :html, :kml + respond_to :html, :kml, :xml, :json # def complete # @stop_areas = line.stop_areas diff --git a/app/helpers/routes_helper.rb b/app/helpers/routes_helper.rb new file mode 100644 index 000000000..72915fd2f --- /dev/null +++ b/app/helpers/routes_helper.rb @@ -0,0 +1,7 @@ +module RoutesHelper + def line_formatted_name( line) + return line.publishedname if line.number.blank? + "#{line.publishedname} [#{line.number}]" + end +end + diff --git a/app/views/lines/show.html.erb b/app/views/lines/show.html.erb index cd0e6b2ac..e5a2d5d7f 100644 --- a/app/views/lines/show.html.erb +++ b/app/views/lines/show.html.erb @@ -51,10 +51,17 @@ </div> </div> +<h3 class="routes"><%= t('.itineraries') %></h3> + +<div class="routes paginated_content"> + <%= render :partial => "routes/route", :collection => @routes %> +</div> + <% content_for :sidebar do %> <ul class="actions"> <li><%= link_to t('lines.actions.edit'), edit_referential_line_path(@referential, @line), :class => "edit" %></li> <li><%= link_to t('lines.actions.destroy'), referential_line_path(@referential, @line), :method => :delete, :confirm => t('lines.actions.destroy_confirm'), :class => "remove" %></li> + <li><%= link_to t('routes.actions.new'), new_referential_line_route_path(@referential, @line), :class => "add" %></li> <br> </ul> <% end %> diff --git a/app/views/routes/_form.html.erb b/app/views/routes/_form.html.erb new file mode 100644 index 000000000..96a681b13 --- /dev/null +++ b/app/views/routes/_form.html.erb @@ -0,0 +1,26 @@ +<%= semantic_form_for [@referential, @line, @route] do |form| %> + <%= form.inputs do %> + <%= form.input :name %> + <%= form.input :published_name %> + <%= form.input :number %> + <%= form.input :comment %> + <%= form.input :opposite_route, :as => :select, :collection => Hash[@line.routes.map{|r| [r.name,r.id]}] %> + <%= form.input :direction_code, :as => :select, :collection => Chouette::Route.directions, :include_blank => false, :member_label => Proc.new { |mode| t("directions.label.#{mode}") } %> + <%= form.input :wayback_code, :as => :select, :collection => Chouette::Route.waybacks, :include_blank => false, :member_label => Proc.new { |mode| t("waybacks.label.#{mode}") } %> + <% if @route.new_record? %> + <%= form.input :objectid %> + <% else %> + <li> + <label><%= @route.human_attribute_name("objectid") %>: </label> + <%= @route.objectid %> + </li> + <% end %> + <% end %> + + <%= form.buttons do %> + <%= form.commit_button true %> + <li><%= t('or') %></li> + <li><%= link_to t('cancel'), :back %></li> + <% end %> +<% end %> + diff --git a/app/views/routes/_route.html.erb b/app/views/routes/_route.html.erb new file mode 100644 index 000000000..7804ec068 --- /dev/null +++ b/app/views/routes/_route.html.erb @@ -0,0 +1,9 @@ +<%= div_for(route) do %> + <div class="wayback"> + <%= link_to image_tag("icons/#{route.wayback}.png"), referential_line_route_path( @referential, @line, route) %> + </div> + <div class="route"> + <%= link_to route.name, referential_line_route_path( @referential, @line, route) %> + </div> +<% end %> + diff --git a/app/views/routes/edit.html.erb b/app/views/routes/edit.html.erb new file mode 100644 index 000000000..dcfa0e8da --- /dev/null +++ b/app/views/routes/edit.html.erb @@ -0,0 +1,4 @@ +<%= title_tag t('routes.edit.title', :route => @route.name ) %> + +<%= render "form" %> + diff --git a/app/views/routes/new.html.erb b/app/views/routes/new.html.erb new file mode 100644 index 000000000..a144fcdee --- /dev/null +++ b/app/views/routes/new.html.erb @@ -0,0 +1,4 @@ +<%= title_tag t('routes.new.title') %> + +<%= render "form" %> + diff --git a/app/views/routes/show.html.erb b/app/views/routes/show.html.erb new file mode 100644 index 000000000..2b48f8829 --- /dev/null +++ b/app/views/routes/show.html.erb @@ -0,0 +1,80 @@ +<%= title_tag t('routes.show.title', :route => @route.name, :line => @line.name ) %> + +<div class="route_show"> + + <div class="summary"> + <p> + <label><%= @route.human_attribute_name(:line) %>: </label> + <%= link_to line_formatted_name( @line), [@referential, @line] %> + </p> + <p> + <label><%= @route.human_attribute_name(:name) %>: </label> + <%= @route.name %> + </p> + <p> + <label><%= @route.human_attribute_name(:published_name) %>: </label> + <%= @route.published_name %> + </p> + <p> + <label><%= @route.human_attribute_name(:number) %>: </label> + <%= @route.number %> + </p> + <p> + <label><%= @route.human_attribute_name(:comment) %>: </label> + <%= @route.comment %> + </p> + <p> + <label><%= @route.human_attribute_name(:direction_code) %>: </label> + <% if @route.direction_code %> + <%= t("directions.label.#{@route.direction_code}").capitalize %> + <% else %> + <%= t(".undefined") %> + <% end %> + </p> + <p> + <label><%= @route.human_attribute_name(:wayback_code) %>: </label> + <% if @route.wayback_code %> + <%= t("waybacks.label.#{@route.wayback_code}").capitalize %> + <% else %> + <%= t(".undefined") %> + <% end %> + </p> + <p> + <label><%= @route.human_attribute_name(:opposite_route) %>: </label> + <% if @route.opposite_route %> + <%= link_to @route.opposite_route.name, [@referential, @line, @route] %> + <% else %> + <%= t(".no_opposite_route") %> + <% end %> + </p> + <p> + <label><%= @route.human_attribute_name("objectid") %>: </label> + <%= @route.objectid %> + </p> + <p> + <label><%= @route.human_attribute_name("creation_time") %>: </label> + <%= l @route.creation_time %> + </p> + <p> + <label><%= @route.human_attribute_name("creator_id") %>: </label> + <%= @route.creator_id %> + </p> + </div> + +</div> + +<h3><%= t('.stop_areas') %></h3> +<%= will_paginate @stop_areas %> +<div class="stop_areas paginated_content"> + <%= render :partial => "stop_areas/stop_area", :collection => @stop_areas %> +</div> +<%= will_paginate @stop_areas %> + +<% content_for :sidebar do %> +<ul class="actions"> + <li><%= link_to t('routes.actions.edit'), edit_referential_line_route_path(@referential, @line, @route), :class => "edit" %></li> + <li><%= link_to t('routes.actions.destroy'), referential_line_route_path(@referential, @line, @route), :method => :delete, :confirm => t('routes.actions.destroy_confirm'), :class => "remove" %></li> + <br> +</ul> +<% end %> + diff --git a/app/views/stop_areas/_stop_area.html.erb b/app/views/stop_areas/_stop_area.html.erb index 56c153226..cd4f71456 100644 --- a/app/views/stop_areas/_stop_area.html.erb +++ b/app/views/stop_areas/_stop_area.html.erb @@ -1,7 +1,7 @@ <%= div_for(stop_area) do %> <%= link_to([@referential, stop_area], :class => "preview") do %> <div class="area_type"> - <%= image_tag "map/" + stop_area.area_type.to_s.downcase + ".png" %> + <%= image_tag "map/" + stop_area.type + ".png" %> </div> <% end %> <%= link_to stop_area.name, [@referential, stop_area] %> diff --git a/app/views/stop_areas/index.html.erb b/app/views/stop_areas/index.html.erb index d9587f36b..deb5b1643 100644 --- a/app/views/stop_areas/index.html.erb +++ b/app/views/stop_areas/index.html.erb @@ -25,7 +25,7 @@ <ul class="selection"> <% Chouette::StopArea.types.each do |area_type| %> -<li><%= link_with_search (image_tag("map/" + area_type.name.downcase + ".png")+t("area_types.label.#{area_type.to_s}")), "areatype_eq" => area_type.name %></li> +<li><%= link_with_search (image_tag("map/" + area_type + ".png")+t("area_types.label.#{area_type.to_s}")), "areatype_eq" => area_type.name %></li> <% end %> <li><%= link_with_search (image_tag("map/all.png")+t(".selection_all")), {"areatype_eq" => nil}, :class => "all" %></li> </ul> diff --git a/app/views/stop_areas/index.kml.erb b/app/views/stop_areas/index.kml.erb index a40e99a6c..0d8e85d2c 100644 --- a/app/views/stop_areas/index.kml.erb +++ b/app/views/stop_areas/index.kml.erb @@ -4,7 +4,7 @@ <% @stop_areas.where("latitude is not null and longitude is not null").each do |stop_area| %> <Placemark id="<%= stop_area.id %>" > <name><%= stop_area.name %></name> - <stop_area_type><%= stop_area.area_type %></stop_area_type> + <stop_area_type><%= stop_area.type %></stop_area_type> <%= stop_area.geometry.kml_representation.html_safe %> </Placemark> <% end %> diff --git a/app/views/stop_areas/show.html.erb b/app/views/stop_areas/show.html.erb index 108a69a2b..b786eec34 100644 --- a/app/views/stop_areas/show.html.erb +++ b/app/views/stop_areas/show.html.erb @@ -79,12 +79,48 @@ <p> <label><%= @stop_area.human_attribute_name("creator_id") %>: </label> <%= @stop_area.creator_id %> - </p> - + </p> + </div> + + + <div class="genealogical"> + <% if @stop_area.parent.present? || @stop_area.children.present? %> + <h3><%= t(".genealogical") %></h3> + <% end %> + + <% if @stop_area.parent.present? %> + <div class="parent"> + <%= link_to([@referential, stop_area.parent]) do %> + <%= image_tag "map/" + @stop_area.parent.type + ".png" %><span><%= @stop_area.parent.name %></span> + <% end %> + <%= link_to image_tag("user_interface/ui/remove.png"), referential_stop_area_path(@referential, @stop_area.parent), :method => :delete, :confirm => t('stop_areas.actions.destroy_confirm'), :class => "remove" %> + </div> + <div class="link"><%= image_tag "icons/link.png"%></div> + <% end %> + + <% if @stop_area.parent.present? || @stop_area.children.present? %> + <div class="target"> + <%= image_tag "map/" + @stop_area.type + ".png"%><span><%= @stop_area.name %></span> + </div> + <% end %> + <% if @stop_area.children.present? %> + <div class="link"><%= image_tag "icons/link.png"%></div> + <div class="children"> + <% @stop_area.children.each do |child| %> + <div class="child"> + <%= link_to([@referential, child]) do %> + <%= image_tag "map/" + child.type + ".png" %><span><%= child.name %></span> + <% end %> + <%= link_to image_tag("user_interface/ui/remove.png"), referential_stop_area_path(@referential, child), :method => :delete, :confirm => t('stop_areas.actions.destroy_confirm'), :class => "remove" %> + </div> + <% end %> + </div> + <% end %> </div> + </div> - + <% content_for :sidebar do %> <ul class="actions"> <li><%= link_to t('stop_areas.actions.edit'), edit_referential_stop_area_path(@referential, @stop_area), :class => "edit" %></li> diff --git a/app/views/stop_areas/show.kml.erb b/app/views/stop_areas/show.kml.erb index f30597f24..60ea5f612 100644 --- a/app/views/stop_areas/show.kml.erb +++ b/app/views/stop_areas/show.kml.erb @@ -3,7 +3,7 @@ <Document> <Placemark id="<%= @stop_area.id %>" > <name><%= @stop_area.name %></name> - <stop_area_type><%= @stop_area.area_type %></stop_area_type> + <stop_area_type><%= @stop_area.type %></stop_area_type> <%= @stop_area.geometry.kml_representation.html_safe %> </Placemark> </Document> diff --git a/config/locales/directions.yml b/config/locales/directions.yml new file mode 100644 index 000000000..82b87673a --- /dev/null +++ b/config/locales/directions.yml @@ -0,0 +1,31 @@ +en: + directions: + label: + straight_forward: straight forward + backward: backward + clockwise: clockwise + anti_clockwise: anticlockwise + north: north + north_west: north west + west: west + south_west: south west + south: south + south_east: south east + east: east + north_east: north east +fr: + directions: + label: + straight_forward: aller + backward: retour + clockwise: sens horaire + anti_clockwise: sens anti horaire + north: nord + north_west: nord ouest + west: ouest + south_west: sud ouest + south: sud + south_east: sud est + east: est + north_east: nord est + diff --git a/config/locales/lines.yml b/config/locales/lines.yml index a24422b9b..490a7b630 100644 --- a/config/locales/lines.yml +++ b/config/locales/lines.yml @@ -11,6 +11,7 @@ en: title: Update line %{line} show: title: Line %{line} + itineraries: "Line's route list" index: title: Lines name_or_number: Name or number @@ -52,6 +53,7 @@ fr: title: Modifier la ligne %{line} show: title: Ligne %{line} + itineraries: "Liste des itinéraires de la ligne" index: name_or_number: Nom ou indice title: Lignes diff --git a/config/locales/routes.yml b/config/locales/routes.yml new file mode 100644 index 000000000..a4cd3a366 --- /dev/null +++ b/config/locales/routes.yml @@ -0,0 +1,77 @@ +en: + routes: + actions: + new: Add a new route + edit: Edit this route + destroy: Remove this route + destroy_confirm: Are you sure you want destroy this route? + new: + title: Add a new route + edit: + title: Update route %{route} + show: + title: Route %{route} + stop_areas: "Routes's stop areas list" + no_opposite_route: No reversed route associated + undefined: Undefined + index: + title: Routes + selection: Selection + selection_all: All + activerecord: + models: + route: Route + attributes: + route: + line: Line + name: Name + published_name: Published name + comment: Comments + number: Number + direction_code: Direction + wayback_code: Wayback + opposite_route: Reversed route + objectid: Neptune identifier + object_version: Version + creation_time: Created on + creator_id: Created by + +fr: + routes: + actions: + new: Ajouter un itinéraire + edit: Modifier cet itinéraire + destroy: Supprimer cet itinéraire + destroy_confirm: Etes vous sûr de détruire cet itinéraire ? + new: + title: Ajouter un itinéraire + edit: + title: "Modifier l'itinéraire %{route}" + show: + title: Itinéraire %{route} de la ligne %{line} + stop_areas: "Liste des arrêts de l'itinéraire" + no_opposite_route: Aucun itinéraire associé en sens opposé + undefined: Non défini + index: + title: Itinéraires + selection: Sélection + selection_all: Tous + activerecord: + models: + route: Itinéraire + attributes: + route: + line: Ligne + name: Nom + published_name: Nom public + number: Indice + comment: Commentaire + direction_code: Direction + wayback_code: Sens + opposite_route: Itinéraire associé en sens opposé + objectid: Identifiant Neptune + object_version: Version + creation_time: Créé le + creator_id: Créé par + + diff --git a/config/locales/stop_areas.yml b/config/locales/stop_areas.yml index bc1254ac9..ca4751dbe 100644 --- a/config/locales/stop_areas.yml +++ b/config/locales/stop_areas.yml @@ -16,6 +16,7 @@ en: title: Stop %{stop_area} geographic_data: Geographic data no_geographic_data: None + genealogical: Links between stop area index: title: Stop areas name_or_country_code: Name or Country code @@ -69,6 +70,7 @@ fr: title: Arrêt %{stop_area} geographic_data: Données géographiques no_geographic_data: Aucune + genealogical: Lien entre arrêts index: name_or_country_code: Nom ou Code Postal title: Arrêts diff --git a/config/locales/waybacks.yml b/config/locales/waybacks.yml new file mode 100644 index 000000000..6891b844d --- /dev/null +++ b/config/locales/waybacks.yml @@ -0,0 +1,11 @@ +en: + waybacks: + label: + straight_forward: straight forward + backward: backward +fr: + waybacks: + label: + straight_forward: aller + backward: retour + diff --git a/config/routes.rb b/config/routes.rb index df64353d0..4aaedc87b 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -17,6 +17,7 @@ ChouetteIhm::Application.routes.draw do resources :referentials do resources :lines, :networks do resources :stop_areas + resources :routes end resources :companies, :stop_areas, :time_tables diff --git a/db/migrate/20120425080337_create_chouette_route.rb b/db/migrate/20120425080337_create_chouette_route.rb new file mode 100644 index 000000000..98d0f3c11 --- /dev/null +++ b/db/migrate/20120425080337_create_chouette_route.rb @@ -0,0 +1,21 @@ +class CreateChouetteRoute < ActiveRecord::Migration + def up + create_table "route", :force => true do |t| + t.integer "lineid", :limit => 8 + t.string "objectid" + t.integer "objectversion" + t.datetime "creationtime" + t.string "creatorid" + t.string "name" + t.string "comment" + t.integer "oppositerouteid", :limit => 8 + t.string "publishedname" + t.string "number" + t.string "direction" + t.string "wayback" + end + end + + def down + end +end diff --git a/db/migrate/20120425125542_create_chouette_stop_point.rb b/db/migrate/20120425125542_create_chouette_stop_point.rb new file mode 100644 index 000000000..07e7861a8 --- /dev/null +++ b/db/migrate/20120425125542_create_chouette_stop_point.rb @@ -0,0 +1,16 @@ +class CreateChouetteStopPoint < ActiveRecord::Migration + def up + create_table "stoppoint", :force => true do |t| + t.integer "routeid", :limit => 8 + t.integer "stopareaid", :limit => 8 + t.string "objectid" + t.integer "objectversion" + t.datetime "creationtime" + t.string "creatorid" + t.integer "position" + end + end + + def down + end +end diff --git a/db/schema.rb b/db/schema.rb index 89a3326fd..07dc4922d 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended to check this file into your version control system. -ActiveRecord::Schema.define(:version => 20120416095046) do +ActiveRecord::Schema.define(:version => 20120425125542) do create_table "company", :force => true do |t| t.string "objectid" @@ -75,6 +75,21 @@ ActiveRecord::Schema.define(:version => 20120416095046) do t.datetime "updated_at" end + create_table "route", :force => true do |t| + t.integer "lineid", :limit => 8 + t.string "objectid" + t.integer "objectversion" + t.datetime "creationtime" + t.string "creatorid" + t.string "name" + t.string "comment" + t.integer "oppositerouteid", :limit => 8 + t.string "publishedname" + t.string "number" + t.string "direction" + t.string "wayback" + end + create_table "stoparea", :force => true do |t| t.integer "parentid", :limit => 8 t.string "objectid" @@ -101,6 +116,16 @@ ActiveRecord::Schema.define(:version => 20120416095046) do add_index "stoparea", ["objectid"], :name => "stoparea_objectid_key", :unique => true add_index "stoparea", ["parentid"], :name => "index_stoparea_on_parentid" + create_table "stoppoint", :force => true do |t| + t.integer "routeid", :limit => 8 + t.integer "stopareaid", :limit => 8 + t.string "objectid" + t.integer "objectversion" + t.datetime "creationtime" + t.string "creatorid" + t.integer "position" + end + create_table "timetable", :force => true do |t| t.string "objectid", :null => false t.integer "objectversion", :default => 1 diff --git a/spec/factories.rb b/spec/factories.rb index b09e41c5c..b77102321 100644 --- a/spec/factories.rb +++ b/spec/factories.rb @@ -1,36 +1,4 @@ FactoryGirl.define do - factory :company, :class => "Chouette::Company" do |company| - company.sequence(:name) { |n| "Company #{n}" } - company.sequence(:objectid) { |n| "test:Company:#{n}" } - company.sequence(:registration_number) { |n| "test-#{n}" } - - end - - factory :line, :class => "Chouette::Line" do |line| - line.sequence(:name) { |n| "Line #{n}" } - line.sequence(:objectid) { |n| "test:Line:#{n}" } - line.sequence(:transport_mode_name) { |n| "Bus" } - - line.association :network, :factory => :network - line.association :company, :factory => :company - - line.sequence(:registration_number) { |n| "test-#{n}" } - end - - factory :network, :class => "Chouette::Network" do |network| - network.sequence(:name) { |n| "Network #{n}" } - network.sequence(:objectid) { |n| "test:GroupOfLine:#{n}" } - network.sequence(:registration_number) { |n| "test-#{n}" } - - end - - # factory :chouette_stop_area, :class => "Chouette::StopArea" do |f| - # f.latitude 10 * rand - # f.longitude 10 * rand - # f.sequence(:name) { |n| "StopArea #{n}" } - # f.areatype "CommercialStopPoint" - # f.objectid - # end factory :referential do |f| f.sequence(:name) { |n| "Test #{n}" } diff --git a/spec/requests/companies_spec.rb b/spec/requests/companies_spec.rb index 77a08743b..d464fd307 100644 --- a/spec/requests/companies_spec.rb +++ b/spec/requests/companies_spec.rb @@ -1,3 +1,4 @@ +# -*- coding: utf-8 -*- require 'spec_helper' describe "Companies" do @@ -5,11 +6,47 @@ describe "Companies" do let!(:referential) { create(:referential).switch } let!(:companies) { referential; Array.new(2) { create(:company) } } + subject { companies.first } - describe "GET /companies" do - it "should display company names" do + describe "list" do + it "display companies" do visit referential_companies_path(referential) page.should have_content(companies.first.name) + page.should have_content(companies.last.name) + end + + end + + describe "show" do + it "display company" do + visit referential_companies_path(referential) + click_link "#{companies.first.name}" + page.should have_content(companies.first.name) + end + + end + + describe "new" do + it "creates company and return to show" do + visit referential_companies_path(referential) + click_link "Ajouter un transporteur" + fill_in "Nom", :with => "Company 1" + fill_in "Numéro d'enregistrement", :with => "test-1" + fill_in "Identifiant Neptune", :with => "test:Company:1" + click_button("Créer Transporteur") + page.should have_content("Company 1") + end + end + + describe "edit and return to show" do + it "edit company" do + visit referential_company_path(referential, subject) + click_link "Modifier ce transporteur" + fill_in "Nom", :with => "Company Modified" + fill_in "Numéro d'enregistrement", :with => "test-1" + click_button("Modifier Transporteur") + page.should have_content("Company Modified") end end + end diff --git a/spec/requests/lines_spec.rb b/spec/requests/lines_spec.rb index 00048361c..3a5e4d507 100644 --- a/spec/requests/lines_spec.rb +++ b/spec/requests/lines_spec.rb @@ -1,16 +1,64 @@ +# -*- coding: utf-8 -*- require 'spec_helper' describe "Lines" do login_user let!(:referential) { create(:referential).switch } - let!(:lines) { referential; Array.new(2) { create(:line) } } + let!(:network) { Factory(:network) } + let!(:company) { Factory(:company) } + let!(:lines) { referential; Array.new(2) { Factory(:line, :network => network, :company => company) } } + subject { lines.first } - describe "GET /lines" do - it "works! (now write some real specs)" do - # Run the generator again with the --webrat flag if you want to use webrat methods/matchers + describe "list" do + it "display lines" do visit referential_lines_path(referential) page.should have_content(lines.first.name) + page.should have_content(lines.last.name) + end + + end + + + describe "show" do + it "display line" do + subject.stub(:stop_areas).and_return(Array.new(2) { Factory(:stop_area) }) + visit referential_lines_path(referential) + click_link "#{lines.first.name}" + page.should have_content(lines.first.name) + end + + it "display map" do + subject.stub(:stop_areas).and_return(Array.new(2) { Factory(:stop_area) }) + visit referential_lines_path(referential) + click_link "#{lines.first.name}" + page.should have_selector("#map", :class => 'line') + end + + end + + describe "new" do + it "creates line and return to show" do + subject.stub(:stop_areas).and_return(Array.new(2) { Factory(:stop_area) }) + visit referential_lines_path(referential) + click_link "Ajouter une ligne" + fill_in "Nom", :with => "Line 1" + fill_in "Numéro d'enregistrement", :with => "test-1" + fill_in "Identifiant Neptune", :with => "test:Line:1" + click_button("Créer Ligne") + page.should have_content("Line 1") + end + end + + describe "edit and return to show" do + it "edit line" do + subject.stub(:stop_areas).and_return(Array.new(2) { Factory(:stop_area) }) + visit referential_line_path(referential, subject) + click_link "Modifier cette ligne" + fill_in "Nom", :with => "Line Modified" + fill_in "Numéro d'enregistrement", :with => "test-1" + click_button("Modifier Ligne") + page.should have_content("Line Modified") end end diff --git a/spec/requests/networks_spec.rb b/spec/requests/networks_spec.rb index dddf6e09b..b48f0312c 100644 --- a/spec/requests/networks_spec.rb +++ b/spec/requests/networks_spec.rb @@ -1,15 +1,83 @@ +# -*- coding: utf-8 -*- require 'spec_helper' describe "Networks" do login_user let!(:referential) { create(:referential).switch } - let!(:networks) { referential; Array.new(2) { create(:network) } } + let!(:networks) { referential; Array.new(2) { Factory(:network) } } + subject { networks.first } - describe "GET /networks" do - it "works! (now write some real specs)" do + describe "list" do + it "display networks" do visit referential_networks_path(referential) page.should have_content(networks.first.name) + page.should have_content(networks.last.name) end + + end + + describe "show" do + it "display network" do + subject.stub(:stop_areas).and_return(Array.new(2) { Factory(:stop_area) }) + visit referential_networks_path(referential) + click_link "#{networks.first.name}" + page.should have_content(networks.first.name) + end + + it "display map" do + subject.stub(:stop_areas).and_return(Array.new(2) { Factory(:stop_area) }) + visit referential_networks_path(referential) + click_link "#{networks.first.name}" + page.should have_selector("#map", :class => 'network') + end + + end + + describe "new" do + it "creates network and return to show" do + subject.stub(:stop_areas).and_return(Array.new(2) { Factory(:stop_area) }) + visit referential_networks_path(referential) + click_link "Ajouter un réseau" + fill_in "Nom", :with => "Network 1" + fill_in "Numéro d'enregistrement", :with => "test-1" + fill_in "Identifiant Neptune", :with => "test:GroupOfLine:1" + click_button("Créer Réseau") + page.should have_content("Network 1") + end + end + + describe "edit and return to show" do + it "edit network" do + subject.stub(:stop_areas).and_return(Array.new(2) { Factory(:stop_area) }) + visit referential_network_path(referential, subject) + click_link "Modifier ce réseau" + fill_in "Nom", :with => "Network Modified" + fill_in "Numéro d'enregistrement", :with => "test-1" + click_button("Modifier Réseau") + page.should have_content("Network Modified") + end + end + + describe "delete", :js => true do + it "delete network and return to the list" do + # subject.stub(:stop_areas).and_return(Array.new(2) { Factory(:stop_area) }) + + # visit referential_networks_path(referential) + # puts page.body + # click_link "#{networks.first.name}" + # click_link "Modifier ce réseau" + # fill_in "Nom", :with => "Network 1" + # fill_in "Numéro d'enregistrement", :with => "test-1" + # click_button("Modifier Réseau") + # page.should have_content("Network 1") + # visit referential_network_path(referential, subject) + # puts page.body.inspect + # click_link "Supprimer ce réseau" + # page.evaluate_script('window.confirm = function() { return true; }') + # click_button "Valider" + # page.should have_no_content("Network 1") + end + end end diff --git a/spec/requests/stop_areas_spec.rb b/spec/requests/stop_areas_spec.rb new file mode 100644 index 000000000..bd01c59ba --- /dev/null +++ b/spec/requests/stop_areas_spec.rb @@ -0,0 +1,59 @@ +# -*- coding: utf-8 -*- +require 'spec_helper' + +describe "StopAreas" do + login_user + + let!(:referential) { create(:referential).switch } + let!(:stop_areas) { referential; Array.new(2) { Factory(:stop_area) } } + subject { stop_areas.first } + + describe "list" do + it "display stop_areas" do + visit referential_stop_areas_path(referential) + page.should have_content(stop_areas.first.name) + page.should have_content(stop_areas.last.name) + end + + end + + + describe "show" do + it "display stop_area" do + visit referential_stop_areas_path(referential) + click_link "#{stop_areas.first.name}" + page.should have_content(stop_areas.first.name) + end + + it "display map" do + visit referential_stop_areas_path(referential) + click_link "#{stop_areas.first.name}" + page.should have_selector("#map", :class => 'stop_area') + end + + end + + describe "new" do + it "creates stop_area and return to show" do + visit referential_stop_areas_path(referential) + click_link "Ajouter un arrêt" + fill_in "Nom", :with => "StopArea 1" + fill_in "Numéro d'enregistrement", :with => "test-1" + #fill_in "Identifiant Neptune", :with => "test:StopArea:1" + click_button("Créer Arrêt") + page.should have_content("StopArea 1") + end + end + + describe "edit and return to show" do + it "edit stop_area" do + visit referential_stop_area_path(referential, subject) + click_link "Modifier cet arrêt" + fill_in "Nom", :with => "StopArea Modified" + fill_in "Numéro d'enregistrement", :with => "test-1" + click_button("Modifier Arrêt") + page.should have_content("StopArea Modified") + end + end + +end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index ba28c1557..ce52830b4 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -13,6 +13,7 @@ unless defined?(FactoryGirl) require 'factory_girl' require 'spec/factories.rb' end +require 'chouette_factories' # Requires supporting ruby files with custom matchers and macros, etc, # in spec/support/ and its subdirectories. diff --git a/spec/views/lines/show.html.erb_spec.rb b/spec/views/lines/show.html.erb_spec.rb index f11727a81..42261005a 100644 --- a/spec/views/lines/show.html.erb_spec.rb +++ b/spec/views/lines/show.html.erb_spec.rb @@ -4,6 +4,7 @@ describe "/lines/show" do let!(:referential) { assign :referential, create(:referential) } let!(:line) { assign :line, create(:line) } + let!(:routes) { assign :routes, Array.new(2) { create(:route, :line => line) }.paginate } let!(:map) { assign(:map, mock(:to_html => '<div id="map"/>')) } it "should render h2 with the line name" do diff --git a/spec/views/routes/show.html.erb_spec.rb b/spec/views/routes/show.html.erb_spec.rb new file mode 100644 index 000000000..05d783eb0 --- /dev/null +++ b/spec/views/routes/show.html.erb_spec.rb @@ -0,0 +1,32 @@ +require 'spec_helper' + +describe "/routes/show" do + + let!(:referential) { assign :referential, create(:referential) } + let!(:line) { assign :line, create(:line) } + let!(:route) { assign :route, create(:route, :line => line) } + let!(:stop_areas) { assign :stop_areas, Array.new(2) { create(:stop_area) }.paginate } + let!(:map) { assign(:map, mock(:to_html => '<div id="map"/>')) } + + it "should render h2 with the route name" do + render + rendered.should have_selector("h2", :text => Regexp.new(line.name)) + end + + # it "should display a map with class 'line'" do + # render + # rendered.should have_selector("#map", :class => 'line') + # end + + it "should render a link to edit the route" do + render + view.content_for(:sidebar).should have_selector(".actions a[href='#{view.edit_referential_line_route_path(referential, line, route)}']") + end + + it "should render a link to remove the route" do + render + view.content_for(:sidebar).should have_selector(".actions a[href='#{view.referential_line_route_path(referential, line, route)}'][class='remove']") + end + +end + |
