aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichel Etienne2014-06-30 16:48:43 +0200
committerMichel Etienne2014-06-30 16:48:43 +0200
commitedd3d2aa3db1003f7c7c04afda989aa5563eba25 (patch)
treec4dadd804093cc740a71b4b6f9c26dc1f7fc29e2
parentd09dcf128ff6f1b27f5491e41f57341ed712a068 (diff)
parentb6a52ab261bdff0e403547338b688a41f2e8a77b (diff)
downloadchouette-core-edd3d2aa3db1003f7c7c04afda989aa5563eba25.tar.bz2
merge
-rw-r--r--app/assets/javascripts/plugins/tooltip.js.coffee2
-rw-r--r--app/assets/javascripts/stop_area_imports.js.coffee0
-rw-r--r--app/assets/javascripts/vehicle_journey_import.js.coffee0
-rw-r--r--app/assets/stylesheets/main/calendar.css.scss71
-rw-r--r--app/assets/stylesheets/main/referentials.css.scss21
-rw-r--r--app/controllers/stop_area_imports_controller.rb24
-rw-r--r--app/controllers/vehicle_journey_imports_controller.rb27
-rw-r--r--app/models/stop_area_import.rb9
-rw-r--r--app/models/vehicle_journey_import.rb5
-rw-r--r--app/views/layouts/application.html.erb91
-rw-r--r--app/views/layouts/without_sidebar.html.erb91
-rw-r--r--app/views/routes/show.html.erb6
-rw-r--r--app/views/shared/_footer.erb2
-rw-r--r--app/views/shared/_header.erb93
-rw-r--r--app/views/stop_area_imports/new.html.erb24
-rw-r--r--app/views/stop_areas/index.html.erb3
-rw-r--r--app/views/vehicle_journey_imports/new.html.erb13
-rw-r--r--config/locales/layouts.yml6
-rw-r--r--config/locales/stop_area_import.yml18
-rw-r--r--config/locales/stop_area_imports.yml33
-rw-r--r--config/locales/vehicle_journey_imports.yml27
-rw-r--r--config/routes.rb1
-rw-r--r--spec/controllers/vehicle_journey_imports_controller_spec.rb7
-rw-r--r--spec/fixtures/stop_area_import_invalid.csv14
-rw-r--r--spec/fixtures/stop_area_import_valid.csv14
-rw-r--r--spec/models/stop_area_import_spec.rb2
-rw-r--r--spec/requests/stop_area_imports_spec.rb34
-rw-r--r--spec/requests/vehicle_journey_imports_spec.rb59
28 files changed, 375 insertions, 322 deletions
diff --git a/app/assets/javascripts/plugins/tooltip.js.coffee b/app/assets/javascripts/plugins/tooltip.js.coffee
new file mode 100644
index 000000000..ca521279e
--- /dev/null
+++ b/app/assets/javascripts/plugins/tooltip.js.coffee
@@ -0,0 +1,2 @@
+jQuery ->
+ $('input').tooltip() \ No newline at end of file
diff --git a/app/assets/javascripts/stop_area_imports.js.coffee b/app/assets/javascripts/stop_area_imports.js.coffee
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/app/assets/javascripts/stop_area_imports.js.coffee
diff --git a/app/assets/javascripts/vehicle_journey_import.js.coffee b/app/assets/javascripts/vehicle_journey_import.js.coffee
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/app/assets/javascripts/vehicle_journey_import.js.coffee
diff --git a/app/assets/stylesheets/main/calendar.css.scss b/app/assets/stylesheets/main/calendar.css.scss
index d59da3515..3d86dbfa1 100644
--- a/app/assets/stylesheets/main/calendar.css.scss
+++ b/app/assets/stylesheets/main/calendar.css.scss
@@ -31,49 +31,52 @@
}
.calendar {
- color: white;
- text-align: center;
- margin-left: 30px;
- display: inline-table;
+ font-size: 10px;
+ color: white;
+ text-align: center;
+ margin-left: 15px;
+ display: inline-table;
}
thead tr {
- color: black;
+ color: black;
}
- th.monthName {
- font-weight: bold;
- text-align: center;
- padding-top: 1em;
- padding-bottom: 0.7em;
- color: black;
+th.monthName {
+ font-size: 12px;
+ font-weight: bold;
+ text-align: center;
+ padding-top: 1em;
+ padding-bottom: 0.7em;
+ color: black;
}
.dayName th {
- font-size: 0.7em;
- text-align: center;
- padding-top: 0.6em;
- padding-bottom: 0.3em;
- background-color: #303030;
- color: white;
- border-bottom: 1px solid white;
+ text-align: center;
+ padding-top: 0.6em;
+ padding-bottom: 0.3em;
+ background-color: #303030;
+ color: white;
+ border-bottom: 1px solid white;
}
.otherMonth {
- color: #999999;
- background-color: #4f4f5b;
- padding: 0.7em;
- border-right: 1px solid #111111;
- border-bottom: 1px solid #111111;
+ color: #999999;
+ background-color: #4f4f5b;
+ padding: 0.7em;
+ border-right: 1px solid #111111;
+ border-bottom: 1px solid #111111;
}
-.day { background-color: #333333; }
+.day {
+ background-color: #333333;
+}
.day, .specialDay, .selected_period, .selected_date, .overlap_date {
- border-bottom: 1px solid #111111;
- padding: 0.7em;
- border-right: 1px solid #111111;
- border-bottom: 1px solid #111111;
+ border-bottom: 1px solid #111111;
+ padding: 0.7em;
+ border-right: 1px solid #111111;
+ border-bottom: 1px solid #111111;
}
.specialDay { background-color: #a8a8a8 !important; }
@@ -88,9 +91,9 @@ thead tr {
.specialDay, .selected_period, .selected_date, .overlap_date, .excluded_date {
a, a:visited, a:hover {
- color: white;
- text-decoration: none;
- }
+ color: white;
+ text-decoration: none;
+ }
}
.specialDay a:hover, selected_period a:hover, selected_date a:hover, excluded_date a:hover, overlap_date a:hover {
@@ -98,9 +101,9 @@ thead tr {
}
.weekendDay {
- background-color: #787888;
+ background-color: #787888;
}
.today {
- background-color: white;
- color: black;
+ background-color: white;
+ color: black;
} \ No newline at end of file
diff --git a/app/assets/stylesheets/main/referentials.css.scss b/app/assets/stylesheets/main/referentials.css.scss
index 715b152e8..f5c2fa030 100644
--- a/app/assets/stylesheets/main/referentials.css.scss
+++ b/app/assets/stylesheets/main/referentials.css.scss
@@ -7,17 +7,7 @@
.referentials {
margin-top: 20px;
- }
-
- .referential {
-
- /* to create multi-column index */
- width: 350px;
- float: left;
- padding-right: 10px;
- position: relative;
-
- }
+ }
}
#workspace.referentials.show
{
@@ -64,12 +54,3 @@
}
}
}
-
-ul.logos {
- margin: 30px 30px 0 0;
-
- li {
- display: inline;
- margin: 0 3px;
- }
-}
diff --git a/app/controllers/stop_area_imports_controller.rb b/app/controllers/stop_area_imports_controller.rb
new file mode 100644
index 000000000..ff93dc40e
--- /dev/null
+++ b/app/controllers/stop_area_imports_controller.rb
@@ -0,0 +1,24 @@
+class StopAreaImportsController < ChouetteController
+ belongs_to :referential
+
+ actions :new, :create
+ respond_to :html, :only => :new
+
+ def new
+ @stop_area_import = StopAreaImport.new
+ new!
+ end
+
+ def create
+ @stop_area_import = StopAreaImport.new(params[:stop_area_import])
+ if @stop_area_import.save
+ redirect_to referential_stop_areas_path( @referential ), notice: I18n.t("stop_area_imports.new.success")
+ else
+ flash[:error] = I18n.t("stop_area_imports.errors.import_aborted") + "<br>" + @stop_area_import.errors.full_messages.join("<br>")
+ render :new
+ end
+ end
+
+ protected
+
+end
diff --git a/app/controllers/vehicle_journey_imports_controller.rb b/app/controllers/vehicle_journey_imports_controller.rb
index e3a6dde77..d58b3c2b0 100644
--- a/app/controllers/vehicle_journey_imports_controller.rb
+++ b/app/controllers/vehicle_journey_imports_controller.rb
@@ -10,36 +10,15 @@ class VehicleJourneyImportsController < ChouetteController
def new
@vehicle_journey_import = VehicleJourneyImport.new(:route => route)
- flash[:notice] = "A CSV or Excel file can be used to import records. The first row should be the column name.
-<p>
-The following columns are allowed :
-<ul>
- <li>
- <strong>stop_point_id</strong> -
- Integer type
- </li>
- <li>
- <strong>stop_area_name</strong> -
- String type
- </li>
- <li>
- <strong>published_journey_name </strong> -
- String type
- </li>
- <li>
- <strong>published_journey_name </strong> -
- String type ....
- </li>
-</ul>
-</p>"
new!
end
def create
- @vehicle_journey_import = VehicleJourneyImport.new(params[:vehicle_journey_import].merge({:route => route}))
+ @vehicle_journey_import = VehicleJourneyImport.new( params[:vehicle_journey_import].present? ? params[:vehicle_journey_import].merge({:route => route}) : {:route => route} )
if @vehicle_journey_import.save
- redirect_to referential_line_route_path( @referential, @line, @route ), notice: "Import successful"
+ redirect_to referential_line_route_path( @referential, @line, @route ), notice: I18n.t("vehicle_journey_imports.new.success")
else
+ flash[:error] = I18n.t("stop_area_imports.errors.import_aborted") + "<br>" + @vehicle_journey_import.errors.full_messages.join("<br>")
render :new
end
end
diff --git a/app/models/stop_area_import.rb b/app/models/stop_area_import.rb
index 09fd92ddb..52d8a94bb 100644
--- a/app/models/stop_area_import.rb
+++ b/app/models/stop_area_import.rb
@@ -10,7 +10,7 @@ class StopAreaImport
validates_presence_of :file
def initialize(attributes = {})
- attributes.each { |name, value| send("#{name}=", value) }
+ attributes.each { |name, value| send("#{name}=", value) } if attributes
end
def persisted?
@@ -26,14 +26,15 @@ class StopAreaImport
else
imported_stop_areas.each_with_index do |imported_stop_area, index|
imported_stop_area.errors.full_messages.each do |message|
- errors.add :base, I18n.t("stop_area_import.errors.invalid_stop_area", :column => index+2, :message => message)
+ errors.add :base, I18n.t("stop_area_imports.errors.invalid_stop_area", :column => index+2, :message => message)
end
end
false
end
end
rescue Exception => exception
- errors.add :base, I18n.t("stop_area_import.errors.exception", :message => exception.message)
+ Rails.logger.error(exception.message)
+ errors.add :base, I18n.t("stop_area_imports.errors.exception")
false
end
end
@@ -58,7 +59,7 @@ class StopAreaImport
when '.csv' then Roo::CSV.new(file.path)
when '.xls' then Roo::Excel.new(file.path)
when '.xlsx' then Roo::Excelx.new(file.path)
- else
+ else
raise "Unknown file type: #{file.original_filename}"
end
end
diff --git a/app/models/vehicle_journey_import.rb b/app/models/vehicle_journey_import.rb
index 8da54abc6..15569c3d4 100644
--- a/app/models/vehicle_journey_import.rb
+++ b/app/models/vehicle_journey_import.rb
@@ -11,7 +11,7 @@ class VehicleJourneyImport
validates_presence_of :route
def initialize(attributes = {})
- attributes.each { |name, value| send("#{name}=", value) }
+ attributes.each { |name, value| send("#{name}=", value) } if attributes
end
def persisted?
@@ -34,7 +34,8 @@ class VehicleJourneyImport
end
end
rescue Exception => exception
- errors.add :base, I18n.t("vehicle_journey_imports.errors.exception", :message => exception.message)
+ Rails.logger.error(exception.message)
+ errors.add :base, I18n.t("vehicle_journey_imports.errors.exception")
false
end
end
diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb
index 2e4f98c0b..5ff860a54 100644
--- a/app/views/layouts/application.html.erb
+++ b/app/views/layouts/application.html.erb
@@ -18,96 +18,7 @@
</head>
<body>
<div id="header">
- <nav class="navbar navbar-default navbar-fixed-top" role="navigation">
- <div class="container">
- <!-- Brand and toggle get grouped for better mobile display -->
- <div class="navbar-header">
- <button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
- <span class="sr-only">Toggle navigation</span>
- <span class="icon-bar"></span>
- <span class="icon-bar"></span>
- <span class="icon-bar"></span>
- <span class="icon-bar version"><%= APP_VERSION %></span>
- </button>
- <%= link_to referentials_path, :class =>"navbar-brand" do %>
- <%= image_tag("logo_chouette.png") %> <span class="version"><%= APP_VERSION %></span>
- <% end %>
- </div>
-
- <!-- Collect the nav links, forms, and other content for toggling -->
- <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
- <ul class="nav navbar-nav">
- <% if selected_referential? %>
- <li class="dropdown">
- <a href="#" class="dropdown-toggle" data-toggle="dropdown"><%= @referential.name %><b class="caret"></b></a>
- <ul class="dropdown-menu">
- <li><%= link_to t("layouts.navbar.return_to_referentials"), referentials_path %></li>
- <li class="divider"></li>
- <li role="presentation" class="dropdown-header"><%= t("layouts.navbar.select_referential") %></li>
- <% current_organisation.referentials.each do |referential| %>
- <li>
- <%= link_to @referential.name, referential_path(@referential) %>
- </li>
- <% end %>
- </ul>
- </li>
- <li class="dropdown">
- <a href="#" class="dropdown-toggle" data-toggle="dropdown"><%= t("layouts.navbar.referential_datas") %><b class="caret"></b></a>
- <ul class="dropdown-menu">
- <li><%= link_to referential_networks_path(@referential) do %>
- <%= Referential.human_attribute_name("networks") %><span class="badge pull-right"><%= @referential.networks.size %></span>
- <% end %>
- </li>
- <li><%= link_to referential_companies_path(@referential) do %>
- <%= Referential.human_attribute_name("companies") %><span class="badge pull-right"><%= @referential.companies.size %></span>
- <% end %>
- </li>
- <li><%= link_to referential_group_of_lines_path(@referential) do %>
- <%= Referential.human_attribute_name("group_of_lines") %><span class="badge pull-right"><%= @referential.group_of_lines.size %></span>
- <% end %>
- </li>
- <li><%= link_to referential_lines_path(@referential) do %>
- <%= Referential.human_attribute_name("lines") %><span class="badge pull-right"><%= @referential.lines.size %></span>
- <% end %>
- </li>
- <li><%= link_to referential_stop_areas_path(@referential) do %>
- <%= Referential.human_attribute_name("stop_areas") %><span class="badge pull-right"><%= @referential.stop_areas.size %></span>
- <% end %>
- </li>
- <li><%= link_to referential_connection_links_path(@referential) do %>
- <%= Referential.human_attribute_name("connection_links") %><span class="badge pull-right"><%= @referential.connection_links.size %></span>
- <% end %>
- </li>
- <li><%= link_to referential_time_tables_path(@referential) do %>
- <%= Referential.human_attribute_name("time_tables") %><span class="badge pull-right"><%= @referential.time_tables.size %></span>
- <% end %>
- </li>
- </ul>
- </li>
- <li><%= link_to Referential.human_attribute_name("import_tasks"), referential_import_tasks_path(@referential) %></li>
- <li><%= link_to Referential.human_attribute_name("export_tasks"), referential_exports_path(@referential) %></li>
- <li><%= link_to Referential.human_attribute_name("compliance_check_tasks"), referential_compliance_check_tasks_path(@referential) %></li>
- <% end %>
- </ul>
- <ul class="nav navbar-nav navbar-right">
- <li class="<%= language_class('fr') %>"><%= link_to_language :fr %></li>
- <li class="<%= language_class('en') %>"><%= link_to_language :en %></li>
- <li><%= link_to t('layouts.help'), help_path, :class =>("current" if help_page?), :target => "_blank" %></li>
- <% if user_signed_in? %>
- <li class="dropdown">
- <a href="#" class="dropdown-toggle" data-toggle="dropdown"><span class="gravatar"><%= user_gravatar_image_tag current_user %></span><%= current_user.name %> <b class="caret"></b></a>
- <ul class="dropdown-menu">
- <li><%= link_to t('layouts.user.profile'), edit_user_registration_path %></li>
- <li><%= link_to t('layouts.user.sign_out'), destroy_user_session_path, :method => :delete %></li>
- <li class="divider"></li>
- <li><%= tab_link_to Organisation.model_name.human, organisation_path %></li>
- </ul>
- </li>
- <% end %>
- </ul>
- </div><!-- /.navbar-collapse -->
- </div><!-- /.container-fluid -->
- </nav>
+ <%= render partial: "shared/header" %>
</div>
<div id="middle" class="container">
<div class="row">
diff --git a/app/views/layouts/without_sidebar.html.erb b/app/views/layouts/without_sidebar.html.erb
index 948070695..d07139c2f 100644
--- a/app/views/layouts/without_sidebar.html.erb
+++ b/app/views/layouts/without_sidebar.html.erb
@@ -18,96 +18,7 @@
</head>
<body>
<div id="header">
- <nav class="navbar navbar-default navbar-fixed-top" role="navigation">
- <div class="container">
- <!-- Brand and toggle get grouped for better mobile display -->
- <div class="navbar-header">
- <button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
- <span class="sr-only">Toggle navigation</span>
- <span class="icon-bar"></span>
- <span class="icon-bar"></span>
- <span class="icon-bar"></span>
- <span class="icon-bar version"><%= APP_VERSION %></span>
- </button>
- <%= link_to referentials_path, :class =>"navbar-brand" do %>
- <%= image_tag("logo_chouette.png") %> <span class="version"><%= APP_VERSION %></span>
- <% end %>
- </div>
-
- <!-- Collect the nav links, forms, and other content for toggling -->
- <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
- <ul class="nav navbar-nav">
- <% if selected_referential? %>
- <li class="dropdown">
- <a href="#" class="dropdown-toggle" data-toggle="dropdown"><%= @referential.name %><b class="caret"></b></a>
- <ul class="dropdown-menu">
- <li><%= link_to t("layouts.navbar.return_to_referentials"), referentials_path %></li>
- <li class="divider"></li>
- <li role="presentation" class="dropdown-header"><%= t("layouts.navbar.select_referential") %></li>
- <% current_organisation.referentials.each do |referential| %>
- <li>
- <%= link_to @referential.name, referential_path(@referential) %>
- </li>
- <% end %>
- </ul>
- </li>
- <li class="dropdown">
- <a href="#" class="dropdown-toggle" data-toggle="dropdown"><%= t("layouts.navbar.referential_datas") %><b class="caret"></b></a>
- <ul class="dropdown-menu">
- <li><%= link_to referential_networks_path(@referential) do %>
- <%= Referential.human_attribute_name("networks") %><span class="badge pull-right"><%= @referential.networks.size %></span>
- <% end %>
- </li>
- <li><%= link_to referential_companies_path(@referential) do %>
- <%= Referential.human_attribute_name("companies") %><span class="badge pull-right"><%= @referential.companies.size %></span>
- <% end %>
- </li>
- <li><%= link_to referential_group_of_lines_path(@referential) do %>
- <%= Referential.human_attribute_name("group_of_lines") %><span class="badge pull-right"><%= @referential.group_of_lines.size %></span>
- <% end %>
- </li>
- <li><%= link_to referential_lines_path(@referential) do %>
- <%= Referential.human_attribute_name("lines") %><span class="badge pull-right"><%= @referential.lines.size %></span>
- <% end %>
- </li>
- <li><%= link_to referential_stop_areas_path(@referential) do %>
- <%= Referential.human_attribute_name("stop_areas") %><span class="badge pull-right"><%= @referential.stop_areas.size %></span>
- <% end %>
- </li>
- <li><%= link_to referential_connection_links_path(@referential) do %>
- <%= Referential.human_attribute_name("connection_links") %><span class="badge pull-right"><%= @referential.connection_links.size %></span>
- <% end %>
- </li>
- <li><%= link_to referential_time_tables_path(@referential) do %>
- <%= Referential.human_attribute_name("time_tables") %><span class="badge pull-right"><%= @referential.time_tables.size %></span>
- <% end %>
- </li>
- </ul>
- </li>
- <li><%= link_to Referential.human_attribute_name("import_tasks"), referential_import_tasks_path(@referential) %></li>
- <li><%= link_to Referential.human_attribute_name("export_tasks"), referential_exports_path(@referential) %></li>
- <li><%= link_to Referential.human_attribute_name("compliance_check_tasks"), referential_compliance_check_tasks_path(@referential) %></li>
- <% end %>
- </ul>
- <ul class="nav navbar-nav navbar-right">
- <li class="<%= language_class('fr') %>"><%= link_to_language :fr %></li>
- <li class="<%= language_class('en') %>"><%= link_to_language :en %></li>
- <li><%= link_to t('layouts.help'), help_path, :class =>("current" if help_page?), :target => "_blank" %></li>
- <% if user_signed_in? %>
- <li class="dropdown">
- <a href="#" class="dropdown-toggle" data-toggle="dropdown"><span class="gravatar"><%= user_gravatar_image_tag current_user %></span><%= current_user.name %> <b class="caret"></b></a>
- <ul class="dropdown-menu">
- <li><%= link_to t('layouts.user.profile'), edit_user_registration_path %></li>
- <li><%= link_to t('layouts.user.sign_out'), destroy_user_session_path, :method => :delete %></li>
- <li class="divider"></li>
- <li><%= tab_link_to Organisation.model_name.human, organisation_path %></li>
- </ul>
- </li>
- <% end %>
- </ul>
- </div><!-- /.navbar-collapse -->
- </div><!-- /.container-fluid -->
- </nav>
+ <%= render partial: "shared/header" %>
</div>
<div id="middle" class="container">
<div class="row">
diff --git a/app/views/routes/show.html.erb b/app/views/routes/show.html.erb
index c36ce0e94..63f52974c 100644
--- a/app/views/routes/show.html.erb
+++ b/app/views/routes/show.html.erb
@@ -101,9 +101,9 @@
<%= link_to t('journey_patterns.actions.new'), new_referential_line_route_journey_pattern_path(@referential, @line, @route), :class => "add" %>
</li>
<% end %>
- <!-- <li> -->
- <!-- <%= link_to t('vehicle_journey_imports.new.title'), new_referential_line_route_vehicle_journey_import_path( @referential, @line, @route ), :class => "import" %> -->
- <!-- </li> -->
+ <li>
+ <%= link_to t('vehicle_journey_imports.new.title'), new_referential_line_route_vehicle_journey_import_path( @referential, @line, @route ), :class => "import" %>
+ </li>
<% if @route.journey_patterns.size > 0 %>
<li>
<i class="fa fa-clock-o"></i><%= link_to t('vehicle_journeys.actions.index'), [@referential, @line, @route, :vehicle_journeys], :class => "vehicle_journeys" %>
diff --git a/app/views/shared/_footer.erb b/app/views/shared/_footer.erb
index 059a96d4c..3ad00df77 100644
--- a/app/views/shared/_footer.erb
+++ b/app/views/shared/_footer.erb
@@ -8,7 +8,7 @@
<li><h4><%= t("layouts.footer.product.title") %></h4></li>
<li><%= link_to t("layouts.footer.product.licence"), "http://www.cecill.info/licences/Licence_CeCILL-B_V1-fr.html" %></li>
<li><%= link_to t("layouts.footer.product.source_code"), "https://github.com/afimb/chouette2" %></li>
- <li><%= link_to t("layouts.footer.product.user_group") %></li>
+ <li><%= link_to t("layouts.footer.product.user_group"), "http://www.chouette.mobi/les-utilisateurs/club-utilisateur-des-outils-chouette-et-irys/" %></li>
</ul>
</div>
<div class="col-md-3">
diff --git a/app/views/shared/_header.erb b/app/views/shared/_header.erb
new file mode 100644
index 000000000..a1d05ca38
--- /dev/null
+++ b/app/views/shared/_header.erb
@@ -0,0 +1,93 @@
+<nav class="navbar navbar-default navbar-fixed-top" role="navigation">
+ <div class="container">
+ <!-- Brand and toggle get grouped for better mobile display -->
+ <div class="navbar-header">
+ <button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
+ <span class="sr-only">Toggle navigation</span>
+ <span class="icon-bar"></span>
+ <span class="icon-bar"></span>
+ <span class="icon-bar"></span>
+ <span class="icon-bar version"><%= APP_VERSION %></span>
+ </button>
+ <%= link_to referentials_path, :class =>"navbar-brand" do %>
+ <%= image_tag("logo_chouette.png") %> <span class="version"><%= APP_VERSION %></span>
+ <% end %>
+ </div>
+
+ <!-- Collect the nav links, forms, and other content for toggling -->
+ <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
+ <ul class="nav navbar-nav">
+ <% if selected_referential? %>
+ <li class="dropdown">
+ <a href="#" class="dropdown-toggle" data-toggle="dropdown"><%= @referential.name %><b class="caret"></b></a>
+ <ul class="dropdown-menu">
+ <li><%= link_to t("layouts.navbar.return_to_referentials"), referentials_path %></li>
+ <li class="divider"></li>
+ <li role="presentation" class="dropdown-header"><%= t("layouts.navbar.select_referential") %></li>
+ <% current_organisation.referentials.each do |referential| %>
+ <li>
+ <%= link_to referential.name, referential_path(referential) %>
+ </li>
+ <% end %>
+ </ul>
+ </li>
+ <li class="dropdown">
+ <a href="#" class="dropdown-toggle" data-toggle="dropdown"><%= t("layouts.navbar.referential_datas") %><b class="caret"></b></a>
+ <ul class="dropdown-menu">
+ <li><%= link_to t("layouts.navbar.return_to_dashboard"), referential_path(@referential) %></li>
+ <li class="divider"></li>
+ <li role="presentation" class="dropdown-header"><%= t("layouts.navbar.select_referential_datas") %></li>
+ <li><%= link_to referential_networks_path(@referential) do %>
+ <%= Referential.human_attribute_name("networks") %><span class="badge pull-right"><%= @referential.networks.size %></span>
+ <% end %>
+ </li>
+ <li><%= link_to referential_companies_path(@referential) do %>
+ <%= Referential.human_attribute_name("companies") %><span class="badge pull-right"><%= @referential.companies.size %></span>
+ <% end %>
+ </li>
+ <li><%= link_to referential_group_of_lines_path(@referential) do %>
+ <%= Referential.human_attribute_name("group_of_lines") %><span class="badge pull-right"><%= @referential.group_of_lines.size %></span>
+ <% end %>
+ </li>
+ <li><%= link_to referential_lines_path(@referential) do %>
+ <%= Referential.human_attribute_name("lines") %><span class="badge pull-right"><%= @referential.lines.size %></span>
+ <% end %>
+ </li>
+ <li><%= link_to referential_stop_areas_path(@referential) do %>
+ <%= Referential.human_attribute_name("stop_areas") %><span class="badge pull-right"><%= @referential.stop_areas.size %></span>
+ <% end %>
+ </li>
+ <li><%= link_to referential_connection_links_path(@referential) do %>
+ <%= Referential.human_attribute_name("connection_links") %><span class="badge pull-right"><%= @referential.connection_links.size %></span>
+ <% end %>
+ </li>
+ <li><%= link_to referential_time_tables_path(@referential) do %>
+ <%= Referential.human_attribute_name("time_tables") %><span class="badge pull-right"><%= @referential.time_tables.size %></span>
+ <% end %>
+ </li>
+ </ul>
+ </li>
+ <li><%= link_to Referential.human_attribute_name("import_tasks"), referential_import_tasks_path(@referential) %></li>
+ <li><%= link_to Referential.human_attribute_name("export_tasks"), referential_exports_path(@referential) %></li>
+ <li><%= link_to Referential.human_attribute_name("compliance_check_tasks"), referential_compliance_check_tasks_path(@referential) %></li>
+ <% end %>
+ </ul>
+ <ul class="nav navbar-nav navbar-right">
+ <li class="<%= language_class('fr') %>"><%= link_to_language :fr %></li>
+ <li class="<%= language_class('en') %>"><%= link_to_language :en %></li>
+ <li><%= link_to t('layouts.help'), help_path, :class =>("current" if help_page?), :target => "_blank" %></li>
+ <% if user_signed_in? %>
+ <li class="dropdown">
+ <a href="#" class="dropdown-toggle" data-toggle="dropdown"><span class="gravatar"><%= user_gravatar_image_tag(current_user) %></span><%= current_user.name %> <b class="caret"></b></a>
+ <ul class="dropdown-menu">
+ <li><%= link_to t('layouts.user.profile'), edit_user_registration_path %></li>
+ <li><%= link_to t('layouts.user.sign_out'), destroy_user_session_path, :method => :delete %></li>
+ <li class="divider"></li>
+ <li><%= tab_link_to Organisation.model_name.human, organisation_path %></li>
+ </ul>
+ </li>
+ <% end %>
+ </ul>
+ </div><!-- /.navbar-collapse -->
+ </div><!-- /.container-fluid -->
+</nav>
diff --git a/app/views/stop_area_imports/new.html.erb b/app/views/stop_area_imports/new.html.erb
new file mode 100644
index 000000000..67b02892d
--- /dev/null
+++ b/app/views/stop_area_imports/new.html.erb
@@ -0,0 +1,24 @@
+<%= title_tag t('stop_area_imports.new.title') %>
+
+<div class="main_actions">
+ <div class="btn-group">
+ <button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown">
+ <%= t('stop_area_imports.new.export_stop_areas') %><span class="caret"></span>
+ </button>
+ <ul class="dropdown-menu" role="menu">
+ <li><%= link_to image_tag("icons/file_csv.png") + " Csv" , "/stop_area_imports.csv" %></li>
+ <li><%= link_to image_tag("icons/file_excel.png") + " Excel", "/stop_area_imports.xls" %></li>
+ </ul>
+ </div>
+</div>
+
+<%= semantic_form_for [@referential, @stop_area_import] do |form| %>
+ <br>
+ <%= form.inputs do %>
+ <%= form.input :file, :as => :file, :input_html => { :title => "#{t('.tooltip.file')}", :'data-placement' => "right", :'data-toggle' => "tooltip", :'data-trigger' =>"hover" } %>
+ <% end %>
+ <%= form.actions do %>
+ <%= form.action :submit, :as => :button , :label => t( 'formtastic.import' ) %>
+ <%= form.action :cancel, :as => :link %>
+ <% end %>
+<% end %>
diff --git a/app/views/stop_areas/index.html.erb b/app/views/stop_areas/index.html.erb
index 5519ea55e..1ff6f73d4 100644
--- a/app/views/stop_areas/index.html.erb
+++ b/app/views/stop_areas/index.html.erb
@@ -26,6 +26,9 @@
<ul class="actions">
<li><%= link_to t('stop_areas.actions.new'), new_referential_stop_area_path(@referential), :class => "add" %></li>
<li><%= link_to t('stop_areas.actions.default_geometry'), default_geometry_referential_stop_areas_path(@referential), :method => :put, :class => "calculator_edit" %></li>
+ <li>
+ <%= link_to t('stop_area_imports.new.title'), new_referential_stop_area_import_path( @referential ), :class => "import" %>
+ </li>
</ul>
<h4><%= t(".selection") %></h4>
diff --git a/app/views/vehicle_journey_imports/new.html.erb b/app/views/vehicle_journey_imports/new.html.erb
index a8459848c..65bfd6b17 100644
--- a/app/views/vehicle_journey_imports/new.html.erb
+++ b/app/views/vehicle_journey_imports/new.html.erb
@@ -13,19 +13,8 @@
</div>
<%= semantic_form_for [@referential, @line, @route, @vehicle_journey_import] do |form| %>
- <% if @vehicle_journey_import.errors.any? %>
- <div id="error_explanation">
- <h2><%= pluralize(@vehicle_journey_import.errors.count, "error") %> prohibited this import from completing:</h2>
- <ul>
- <% @vehicle_journey_import.errors.full_messages.each do |msg| %>
- <li><%= msg %></li>
- <% end %>
- </ul>
- </div>
- <% end %>
- <br>
<%= form.inputs do %>
- <%= form.input :file, :as => :file %>
+ <%= form.input :file, :as => :file, :input_html => { :title => "#{t('.tooltip.file')}", :'data-placement' => "right", :'data-toggle' => "tooltip", :'data-trigger' =>"hover" } %>
<% end %>
<%= form.actions do %>
<%= form.action :submit, :as => :button , :label => t( 'formtastic.import' ) %>
diff --git a/config/locales/layouts.yml b/config/locales/layouts.yml
index 5b239e664..081252aec 100644
--- a/config/locales/layouts.yml
+++ b/config/locales/layouts.yml
@@ -8,7 +8,9 @@ en:
sign_out: "Sign out"
navbar:
return_to_referentials: "Return to referentials"
- select_referential: "Sélect referential"
+ select_referential: "Select referential"
+ select_referential_datas: "Select datas"
+ return_to_dashboard: "Return to Dashboard"
referential_datas: "Referential datas"
creation_tag:
title: "Create"
@@ -49,6 +51,8 @@ fr:
navbar:
return_to_referentials: "Retour à la liste des référentiels"
select_referential: "Sélection du référentiel"
+ select_referential_datas: "Sélection des données"
+ return_to_dashboard: "Retour au Tableau de Bord"
referential_datas: "Données du référentiel"
creation_tag:
title: "Création"
diff --git a/config/locales/stop_area_import.yml b/config/locales/stop_area_import.yml
deleted file mode 100644
index cb557b540..000000000
--- a/config/locales/stop_area_import.yml
+++ /dev/null
@@ -1,18 +0,0 @@
-en:
- stop_area_import:
- new:
- title: "Import stop areas"
- form:
- file: "File"
- errors:
- invalid_stop_area: "Error column %{column}, stop_area is invalid : %{message}"
- exception: "An exception occured : %{message}"
-fr:
- stop_area_import:
- new:
- title: "Import des arrêts"
- form:
- file: "Fichier"
- errors:
- invalid_stop_area: "Erreur colonne %{column}, l'arrêt est invalide : %{message}"
- exception: "Une exception est survenu : %{message}" \ No newline at end of file
diff --git a/config/locales/stop_area_imports.yml b/config/locales/stop_area_imports.yml
new file mode 100644
index 000000000..124157cba
--- /dev/null
+++ b/config/locales/stop_area_imports.yml
@@ -0,0 +1,33 @@
+en:
+ stop_area_imports:
+ new:
+ title: "Import stop areas"
+ export_stop_areas: "Export a model"
+ succcess: "Import is a success"
+ tooltip:
+ file: "Select a CSV or Excel file"
+ errors:
+ import_aborted: "Errors prohibited this import from completing: "
+ invalid_stop_area: "Error column %{column}, stop_area is invalid : %{message}"
+ exception: "Invalid file, you must provide valid csv, xls or xlsx file"
+ activemodel:
+ attributes:
+ stop_area_import:
+ file: "File"
+fr:
+ stop_area_imports:
+ new:
+ title: "Import des arrêts"
+ export_stop_areas: "Exporter un modèle"
+ succcess: "L'import des données est un succès"
+ tooltip:
+ file: "Sélectionner un fichier CSV ou Excel"
+ errors:
+ import_aborted: "Des erreurs ont empéchées le bon déroulement de l'import: "
+ invalid_stop_area: "Erreur colonne %{column}, l'arrêt est invalide : %{message}"
+ exception: "Le fichier est invalide, vous devez fournir un fichier csv, xls ou xlsx valide"
+ activemodel:
+ attributes:
+ stop_area_import:
+ file: "Fichier"
+ \ No newline at end of file
diff --git a/config/locales/vehicle_journey_imports.yml b/config/locales/vehicle_journey_imports.yml
index f3d3be918..476996f41 100644
--- a/config/locales/vehicle_journey_imports.yml
+++ b/config/locales/vehicle_journey_imports.yml
@@ -2,24 +2,35 @@ en:
vehicle_journey_imports:
new:
title: "Import vehicle journey at stops"
- export_vehicle_journeys: "Export existing vehicle journey at stops :"
- form:
- file: "File"
+ export_vehicle_journeys: "Export existing vehicle journey at stops"
+ succcess: "Import is a success"
+ tooltip:
+ file: "Select a CSV or Excel file"
errors:
+ import_aborted: "Des erreurs ont empéchées le bon déroulement de l'import: "
not_same_stop_points: "Error column 1 : Not same stop points than in route %{route}"
invalid_vehicle_journey_at_stop: "Error column %{column} line %{line} : vehicle journey at stop invalid %{time}"
invalid_vehicle_journey: "Error column %{column}, vehicle journey is invalid : %{message}"
- exception: "An exception occured : %{message}"
+ exception: "Invalid file, you must provide valid csv, xls or xlsx file"
+ activemodel:
+ attributes:
+ vehicle_journey_import:
+ file: "File"
fr:
vehicle_journey_imports:
new:
title: "Import des horaires à l'arrêt"
export_vehicle_journeys: "Exporter les horaires existants"
- form:
- file: "Fichier"
+ succcess: "L'import des données est un succès"
+ tooltip:
+ file: "Sélectionner un fichier CSV ou Excel"
errors:
+ import_aborted: "Des erreurs ont empéchées le bon déroulement de l'import: "
not_same_stop_points: "Erreur colonne 1 : Pas les mêmes points d'arrêt que sur l'itinéraire %{route}"
invalid_vehicle_journey_at_stop: "Erreur colonne %{column} ligne %{line} : horaire à l'arrêt invalide %{time}"
invalid_vehicle_journey: "Erreur colonne %{column}, la course est invalide : %{message}"
- exception: "Une exception est survenu : %{message}"
- \ No newline at end of file
+ exception: "Le fichier est invalide, vous devez fournir un fichier csv, xls ou xlsx valide"
+ activemodel:
+ attributes:
+ vehicle_journey_import:
+ file: "Fichier" \ No newline at end of file
diff --git a/config/routes.rb b/config/routes.rb
index 12a83eea1..fe4db9a12 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -37,6 +37,7 @@ ChouetteIhm::Application.routes.draw do
end
resources :referentials do
+ resources :stop_area_imports
resources :api_keys
resources :rule_parameter_sets
resources :stop_point_areas
diff --git a/spec/controllers/vehicle_journey_imports_controller_spec.rb b/spec/controllers/vehicle_journey_imports_controller_spec.rb
new file mode 100644
index 000000000..091826205
--- /dev/null
+++ b/spec/controllers/vehicle_journey_imports_controller_spec.rb
@@ -0,0 +1,7 @@
+require 'spec_helper'
+
+describe ImportTasksController do
+ login_user
+
+
+end
diff --git a/spec/fixtures/stop_area_import_invalid.csv b/spec/fixtures/stop_area_import_invalid.csv
index 522bf029c..7fc4caefc 100644
--- a/spec/fixtures/stop_area_import_invalid.csv
+++ b/spec/fixtures/stop_area_import_invalid.csv
@@ -1,7 +1,7 @@
-"id","name","registration_number","longitude","latitude","area_type","comment","country_code","street_name","mobility_restricted_suitability","stairs_availability","lift_availability","int_user_needs"
-,"StopArea1",,"0.1","0.1",,"Comment",,,,,,
-,"StopArea2",,"0.2","0.2",,"Comment",,,,,,
-,"StopArea3",,"0.3","0.3",,"Comment",,,,,,
-,"StopArea4",,"0.4","0.4",,"Comment",,,,,,
-,"StopArea5",,"0.5","0.5",,"Comment",,,,,,
-,"StopArea6",,"0.6","0.6",,"Comment",,,,,,
+"id","name","longitude","latitude","area_type","comment","country_code","street_name","mobility_restricted_suitability","stairs_availability","lift_availability","int_user_needs"
+,"StopArea1","0.1","0.1",,"Comment",,,,,,
+,"StopArea2","0.2","0.2",,"Comment",,,,,,
+,"StopArea3","0.3","0.3",,"Comment",,,,,,
+,"StopArea4","0.4","0.4",,"Comment",,,,,,
+,"StopArea5","0.5","0.5",,"Comment",,,,,,
+,"StopArea6","0.6","0.6",,"Comment",,,,,,
diff --git a/spec/fixtures/stop_area_import_valid.csv b/spec/fixtures/stop_area_import_valid.csv
index 0dc54f215..a929378f9 100644
--- a/spec/fixtures/stop_area_import_valid.csv
+++ b/spec/fixtures/stop_area_import_valid.csv
@@ -1,7 +1,7 @@
-"id","name","registration_number","longitude","latitude","area_type","comment","country_code","street_name","mobility_restricted_suitability","stairs_availability","lift_availability","int_user_needs"
-,"StopArea1","1","0.1","0.1","Quay","Comment",,,,,,
-,"StopArea2","2","0.2","0.2","Quay","Comment",,,,,,
-,"StopArea3","3","0.3","0.3","Quay","Comment",,,,,,
-,"StopArea4","4","0.4","0.4","Quay","Comment",,,,,,
-,"StopArea5","5","0.5","0.5","Quay","Comment",,,,,,
-,"StopArea6","6","0.6","0.6","Quay","Comment",,,,,,
+"id","name","longitude","latitude","area_type","comment","country_code","street_name","mobility_restricted_suitability","stairs_availability","lift_availability","int_user_needs"
+,"StopArea1","0.1","0.1","Quay","Comment",,,,,,
+,"StopArea2","0.2","0.2","Quay","Comment",,,,,,
+,"StopArea3","0.3","0.3","Quay","Comment",,,,,,
+,"StopArea4","0.4","0.4","Quay","Comment",,,,,,
+,"StopArea5","0.5","0.5","Quay","Comment",,,,,,
+,"StopArea6","0.6","0.6","Quay","Comment",,,,,,
diff --git a/spec/models/stop_area_import_spec.rb b/spec/models/stop_area_import_spec.rb
index 1792ba8a3..07f3a111b 100644
--- a/spec/models/stop_area_import_spec.rb
+++ b/spec/models/stop_area_import_spec.rb
@@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-
require 'spec_helper'
-describe VehicleJourneyImport do
+describe StopAreaImport do
let(:valid_file) {
csv_file = File.open(Rails.root.join("spec", "fixtures", "stop_area_import_valid.csv").to_s, "r")
diff --git a/spec/requests/stop_area_imports_spec.rb b/spec/requests/stop_area_imports_spec.rb
new file mode 100644
index 000000000..c0da1edac
--- /dev/null
+++ b/spec/requests/stop_area_imports_spec.rb
@@ -0,0 +1,34 @@
+# -*- coding: utf-8 -*-
+require 'spec_helper'
+
+describe "StopAreaImports" do
+ login_user
+
+ let!(:line) { create :line }
+ let!(:valid_file_path) { Rails.root + "spec/fixtures/stop_area_import_valid.csv" }
+ let!(:invalid_file_path) { Rails.root + "spec/fixtures/stop_area_import_invalid.csv" }
+
+ describe "new" do
+ it "should create stop areas and return to stop areas index page" do
+ visit new_referential_stop_area_import_path(referential)
+ attach_file('Fichier', valid_file_path)
+ click_button "Lancer l'import"
+ expect(page).to have_content(I18n.t("stop_area_imports.new.success"))
+ expect(page).to have_content("StopArea1")
+ end
+
+ it "should return error messages when file is invalid" do
+ visit new_referential_stop_area_import_path(referential)
+ attach_file('Fichier', invalid_file_path)
+ click_button "Lancer l'import"
+ expect(page).to have_content(I18n.t("stop_area_imports.errors.import_aborted"))
+ end
+
+ it "should return error message when file missing on upload" do
+ visit new_referential_stop_area_import_path(referential)
+ click_button "Lancer l'import"
+ expect(page).to have_content(I18n.t("stop_area_imports.errors.import_aborted"))
+ end
+ end
+
+end
diff --git a/spec/requests/vehicle_journey_imports_spec.rb b/spec/requests/vehicle_journey_imports_spec.rb
new file mode 100644
index 000000000..c7a772fd3
--- /dev/null
+++ b/spec/requests/vehicle_journey_imports_spec.rb
@@ -0,0 +1,59 @@
+# -*- coding: utf-8 -*-
+require 'spec_helper'
+
+describe "VehicleJourneyImports" do
+ login_user
+
+ let!(:route) { create :route }
+
+ let(:valid_file_path) {
+ csv_file = update_csv_file_with_factory_data("vehicle_journey_imports_valid.csv")
+ File.path(csv_file)
+ }
+
+ let(:invalid_file_path) {
+ csv_file = update_csv_file_with_factory_data("vehicle_journey_imports_with_vjas_invalid.csv")
+ File.path(csv_file)
+ }
+
+ def update_csv_file_with_factory_data(filename)
+ csv_file = CSV.open("/tmp/#{filename}", "wb") do |csv|
+ counter = 0
+ CSV.foreach( Rails.root.join("spec", "fixtures", "#{filename}").to_s ) do |row|
+ if counter == 0
+ csv << row
+ else
+ csv << ( row[0] = route.stop_points[counter - 1].id; row)
+ end
+ counter += 1
+ end
+
+ end
+
+ File.open("/tmp/#{filename}")
+ end
+
+ describe "new" do
+ it "should create stop areas and return to stop areas index page" do
+ visit new_referential_line_route_vehicle_journey_import_path(referential, route.line, route)
+ attach_file('Fichier', valid_file_path)
+ click_button "Lancer l'import"
+ expect(page).to have_content(I18n.t("vehicle_journey_imports.new.success"))
+ expect(page).to have_content("Séquence d'arrêts #{route.name}")
+ end
+
+ it "should return error messages when file is invalid" do
+ visit new_referential_line_route_vehicle_journey_import_path(referential, route.line, route)
+ attach_file('Fichier', invalid_file_path)
+ click_button "Lancer l'import"
+ expect(page).to have_content(I18n.t("vehicle_journey_imports.errors.import_aborted"))
+ end
+
+ it "should return error message when file missing on upload" do
+ visit new_referential_line_route_vehicle_journey_import_path(referential, route.line, route)
+ click_button "Lancer l'import"
+ expect(page).to have_content(I18n.t("vehicle_journey_imports.errors.import_aborted"))
+ end
+ end
+
+end