aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarc Florisson2012-09-05 17:32:00 +0200
committerMarc Florisson2012-09-05 17:32:00 +0200
commit3e36a149597bc152ca2387945d4db7c74c3395f7 (patch)
tree022e15dd1564e462723ab55fa46e33ef9388b648
parent1a3e3ed00d4bef09a3a86e84a9f3d74e7ffb4993 (diff)
parente524f087ae7fe7543bffbdf281ed9e07c00b9418 (diff)
downloadchouette-core-3e36a149597bc152ca2387945d4db7c74c3395f7.tar.bz2
merge
-rw-r--r--app/assets/stylesheets/routes.css.scss5
-rw-r--r--app/assets/stylesheets/vehicle_journeys.css.scss20
-rw-r--r--app/controllers/application_controller.rb7
-rw-r--r--app/controllers/file_validations_controller.rb14
-rw-r--r--app/models/file_validation.rb3
-rw-r--r--app/models/organisation.rb1
-rw-r--r--app/models/user.rb9
-rw-r--r--config/locales/connection_links.yml2
-rw-r--r--db/migrate/20120905125251_add_organisation_id_to_file_validation.rb12
-rw-r--r--db/schema.rb5
-rw-r--r--spec/factories.rb11
11 files changed, 81 insertions, 8 deletions
diff --git a/app/assets/stylesheets/routes.css.scss b/app/assets/stylesheets/routes.css.scss
index 72670197b..2ecfef0a5 100644
--- a/app/assets/stylesheets/routes.css.scss
+++ b/app/assets/stylesheets/routes.css.scss
@@ -74,10 +74,15 @@
@include content_to_clear;
}
+ .route_journey_patterns {
+ cursor: pointer;
+ }
+
.route_stop_points {
clear: both;
margin: 0px;
padding: 0px;
+ cursor: pointer;
}
.stop_point {
diff --git a/app/assets/stylesheets/vehicle_journeys.css.scss b/app/assets/stylesheets/vehicle_journeys.css.scss
index 3843f15d0..76d78dd39 100644
--- a/app/assets/stylesheets/vehicle_journeys.css.scss
+++ b/app/assets/stylesheets/vehicle_journeys.css.scss
@@ -65,6 +65,21 @@
}
#workspace.vehicle_journeys.show, #workspace.vehicle_journeys.edit, #workspace.vehicle_journeys.update, #workspace.vehicle_journeys.create, #workspace.vehicle_journeys.new {
+
+ h3 {
+ .vehicle_journey_at_stops {
+ cursor: pointer;
+ }
+ }
+
+ .to_departures {
+ cursor: pointer;
+ }
+
+ .to_arrivals {
+ cursor: pointer;
+ }
+
.vehicle_journey_at_stops {
thead {
th { text-align: center; }
@@ -117,6 +132,11 @@
@include content_to_clear;
}
+ h3 {
+ .vehicle_journey_time_tables {
+ cursor: pointer;
+ }
+ }
.vehicle_journey_time_tables {
clear: both;
margin: 0px;
diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb
index 3cb217b9c..64a706557 100644
--- a/app/controllers/application_controller.rb
+++ b/app/controllers/application_controller.rb
@@ -1,7 +1,12 @@
class ApplicationController < ActionController::Base
protect_from_forgery
before_filter :authenticate_user!
-
+ before_filter :set_locale
+
+ def set_locale
+ I18n.locale = session[:language] || I18n.default_locale
+ end
+
protected
def current_organisation
diff --git a/app/controllers/file_validations_controller.rb b/app/controllers/file_validations_controller.rb
index f56cf8ceb..cc50a7499 100644
--- a/app/controllers/file_validations_controller.rb
+++ b/app/controllers/file_validations_controller.rb
@@ -18,9 +18,15 @@ class FileValidationsController < InheritedResources::Base
end
protected
-
- def collection
- @file_validations ||= end_of_association_chain.paginate(:page => params[:page])
+ def resource
+ @file_validation ||= current_organisation.file_validations.find_by_id(params[:id])
end
-
+ def collection
+ @file_validations ||= current_organisation.file_validations.paginate(:page => params[:page])
+ end
+ def create_resource(file_validation)
+ file_validation.organisation = current_organisation
+ super
+ end
+
end
diff --git a/app/models/file_validation.rb b/app/models/file_validation.rb
index 30569a092..a4c76ebf0 100644
--- a/app/models/file_validation.rb
+++ b/app/models/file_validation.rb
@@ -6,6 +6,9 @@ class FileValidation < ActiveRecord::Base
attr_accessor :resources,:uncheck_count,:ok_count,:warning_count,:error_count,:fatal_count,:log_message_tree
attr_accessor :validator
+ belongs_to :organisation
+ validates_presence_of :organisation
+
has_many :log_messages, :class_name => "FileValidationLogMessage", :order => :position, :dependent => :destroy
serialize :options
diff --git a/app/models/organisation.rb b/app/models/organisation.rb
index a57d9f5a5..2cc6a9c3c 100644
--- a/app/models/organisation.rb
+++ b/app/models/organisation.rb
@@ -2,6 +2,7 @@
class Organisation < ActiveRecord::Base
has_many :users, :dependent => :destroy
has_many :referentials, :dependent => :destroy
+ has_many :file_validations, :dependent => :destroy
validates_presence_of :name
validates_uniqueness_of :name
diff --git a/app/models/user.rb b/app/models/user.rb
index cc880759e..77aa02c68 100644
--- a/app/models/user.rb
+++ b/app/models/user.rb
@@ -14,4 +14,13 @@ class User < ActiveRecord::Base
before_validation(:on => :create) do
self.password ||= Devise.friendly_token.first(6)
end
+
+ # remove organisation and referentials if last user of it
+ after_destroy :check_destroy_organisation
+ def check_destroy_organisation
+ if organisation.users.empty?
+ organisation.destroy
+ end
+ end
+
end
diff --git a/config/locales/connection_links.yml b/config/locales/connection_links.yml
index 53d18ff00..6c7426f82 100644
--- a/config/locales/connection_links.yml
+++ b/config/locales/connection_links.yml
@@ -14,7 +14,7 @@ en:
title: Connection link %{connection_link}
durations: "Durations (hh mm ss):"
index:
- title: Connection_ links
+ title: Connection links
name: Name
departure: Start of link
arrival: End of link
diff --git a/db/migrate/20120905125251_add_organisation_id_to_file_validation.rb b/db/migrate/20120905125251_add_organisation_id_to_file_validation.rb
new file mode 100644
index 000000000..996bf8dba
--- /dev/null
+++ b/db/migrate/20120905125251_add_organisation_id_to_file_validation.rb
@@ -0,0 +1,12 @@
+class AddOrganisationIdToFileValidation < ActiveRecord::Migration
+ def change
+ change_table :file_validations do |f|
+ f.belongs_to :organisation
+ end
+
+ FileValidation.reset_column_information
+ organisation = Organisation.find_or_create_by_name!("Chouette")
+ FileValidation.update_all :organisation_id => organisation.id
+
+ end
+end
diff --git a/db/schema.rb b/db/schema.rb
index 044415bce..2895423a1 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 => 20120830095442) do
+ActiveRecord::Schema.define(:version => 20120905125251) do
create_table "access_links", :force => true do |t|
t.integer "access_point_id", :limit => 8
@@ -192,11 +192,12 @@ ActiveRecord::Schema.define(:version => 20120830095442) do
create_table "file_validations", :force => true do |t|
t.string "status"
- t.string "options", :limit => 2000
+ t.string "options", :limit => 2000
t.string "file_name"
t.string "file_type"
t.datetime "created_at"
t.datetime "updated_at"
+ t.integer "organisation_id"
end
create_table "group_of_lines", :force => true do |t|
diff --git a/spec/factories.rb b/spec/factories.rb
index 87387f3f5..cbdb97440 100644
--- a/spec/factories.rb
+++ b/spec/factories.rb
@@ -44,4 +44,15 @@ FactoryGirl.define do
f.duration 1
end
+ factory :file_validation do |f|
+ f.resources { Rack::Test::UploadedFile.new 'spec/fixtures/neptune.zip', 'application/zip', false }
+ f.association :organisation
+ end
+
+ factory :file_validation_log_message do |f|
+ f.association :file_validation
+ f.sequence(:key) { "key_#{n}" }
+ end
+
+
end