aboutsummaryrefslogtreecommitdiffstats
path: root/app
diff options
context:
space:
mode:
Diffstat (limited to 'app')
-rw-r--r--app/controllers/referentials_controller.rb10
-rw-r--r--app/controllers/stop_area_referentials_controller.rb11
-rw-r--r--app/models/organisation.rb7
-rw-r--r--app/models/stop_area_referential.rb10
-rw-r--r--app/models/stop_area_referential_membership.rb4
-rw-r--r--app/views/referentials/index.html.erb7
-rw-r--r--app/views/stop_area_referentials/show.html.erb10
7 files changed, 51 insertions, 8 deletions
diff --git a/app/controllers/referentials_controller.rb b/app/controllers/referentials_controller.rb
index b03aec7e1..34ba37380 100644
--- a/app/controllers/referentials_controller.rb
+++ b/app/controllers/referentials_controller.rb
@@ -11,7 +11,7 @@ class ReferentialsController < BreadcrumbController
@referential.data_format = current_organisation.data_format
end
end
-
+
def show
resource.switch
show! do |format|
@@ -34,18 +34,18 @@ class ReferentialsController < BreadcrumbController
def resource
@referential ||= current_organisation.referentials.find_by_id(params[:id])
end
-
+
def collection
@referentials ||= current_organisation.referentials.order(:name)
end
-
+
def build_resource
super.tap do |referential|
referential.user_id = current_user.id
referential.user_name = current_user.name
end
end
-
+
def create_resource(referential)
referential.organisation = current_organisation
super
@@ -54,6 +54,6 @@ class ReferentialsController < BreadcrumbController
private
def referential_params
params.require(:referential).permit( :id, :name, :slug, :prefix, :time_zone, :upper_corner, :lower_corner, :organisation_id, :projection_type, :data_format )
- end
+ end
end
diff --git a/app/controllers/stop_area_referentials_controller.rb b/app/controllers/stop_area_referentials_controller.rb
new file mode 100644
index 000000000..3abd53892
--- /dev/null
+++ b/app/controllers/stop_area_referentials_controller.rb
@@ -0,0 +1,11 @@
+class StopAreaReferentialsController < BreadcrumbController
+
+ defaults :resource_class => StopAreaReferential
+
+ protected
+
+ def begin_of_chain
+ current_organisation
+ end
+
+end
diff --git a/app/models/organisation.rb b/app/models/organisation.rb
index f0904d51d..8b35982e2 100644
--- a/app/models/organisation.rb
+++ b/app/models/organisation.rb
@@ -1,15 +1,18 @@
# -*- coding: utf-8 -*-
class Organisation < ActiveRecord::Base
include DataFormatEnumerations
-
+
has_many :users, :dependent => :destroy
has_many :referentials, :dependent => :destroy
has_many :rule_parameter_sets, :dependent => :destroy
+ has_many :stop_area_referential_memberships
+ has_many :stop_area_referentials, through: :stop_area_referential_memberships
+
validates :name, :presence => true, :uniqueness => true
after_create :add_rule_parameter_set
-
+
def add_rule_parameter_set
RuleParameterSet.default_for_all_modes( self).save
end
diff --git a/app/models/stop_area_referential.rb b/app/models/stop_area_referential.rb
new file mode 100644
index 000000000..e8cfbaa1f
--- /dev/null
+++ b/app/models/stop_area_referential.rb
@@ -0,0 +1,10 @@
+class StopAreaReferential < ActiveRecord::Base
+ has_many :stop_area_referential_memberships
+ has_many :organisations, through: :stop_area_referential_memberships
+
+ def add_member(organisation, options = {})
+ attributes = options.merge organisation: organisation
+ stop_area_referential_memberships.build attributes
+ end
+
+end
diff --git a/app/models/stop_area_referential_membership.rb b/app/models/stop_area_referential_membership.rb
new file mode 100644
index 000000000..435970961
--- /dev/null
+++ b/app/models/stop_area_referential_membership.rb
@@ -0,0 +1,4 @@
+class StopAreaReferentialMembership < ActiveRecord::Base
+ belongs_to :organisation
+ belongs_to :stop_area_referential
+end
diff --git a/app/views/referentials/index.html.erb b/app/views/referentials/index.html.erb
index cf4eaa245..7f1604b7c 100644
--- a/app/views/referentials/index.html.erb
+++ b/app/views/referentials/index.html.erb
@@ -1,4 +1,4 @@
-<%= title_tag Referential.model_name.human(:count => 2) %>
+<%= title_tag Referential.model_name.human(:count => 2) %>
<div class="referentials paginated_content">
<%= paginated_content @referentials %>
@@ -8,4 +8,9 @@
<ul class="actions">
<li><%= link_to t('referentials.actions.new'), new_referential_path, :class => "add" %></li>
</ul>
+<ul>
+ <!-- FIXME #820 -->
+ <!-- Don't blame me. See #820 -->
+ <li><%= link_to 'Arrêts Reflex', stop_area_referential_path(1) %></li>
+</ul>
<% end %>
diff --git a/app/views/stop_area_referentials/show.html.erb b/app/views/stop_area_referentials/show.html.erb
new file mode 100644
index 000000000..92b37d451
--- /dev/null
+++ b/app/views/stop_area_referentials/show.html.erb
@@ -0,0 +1,10 @@
+<!-- FIXME #820 -->
+<%= title_tag "Référentiel d'arrêts #{@stop_area_referential.name}" %>
+
+<div class="summary">
+</div>
+
+<% content_for :sidebar do %>
+<ul class="actions">
+</ul>
+<% end %>