diff options
| author | cedricnjanga | 2017-11-22 00:15:30 +0100 | 
|---|---|---|
| committer | cedricnjanga | 2017-11-22 00:15:30 +0100 | 
| commit | 5489c9482cb8658b8540da2b46bfd28f321d866e (patch) | |
| tree | f1b1cdff940319c1b60879a23b232ecd9d4e9284 /app | |
| parent | 763010ced3202c99f705562a373861f926aad9a1 (diff) | |
| download | chouette-core-5489c9482cb8658b8540da2b46bfd28f321d866e.tar.bz2 | |
Fix the delation of the hacking of Chouette::ActiveRecord#model_name to remove the Chouette namespace
off of the construction of link in the app and in other places.
Added a small change in the reflex sync to set the stop_area_referential in the initialization of the object to be in sync with the work on the objectids (need a objectid_formatter)
Diffstat (limited to 'app')
| -rw-r--r-- | app/controllers/companies_controller.rb | 2 | ||||
| -rw-r--r-- | app/controllers/journey_patterns_collections_controller.rb | 2 | ||||
| -rw-r--r-- | app/controllers/lines_controller.rb | 2 | ||||
| -rw-r--r-- | app/controllers/networks_controller.rb | 2 | ||||
| -rw-r--r-- | app/controllers/referential_lines_controller.rb | 2 | ||||
| -rw-r--r-- | app/controllers/routes_controller.rb | 2 | ||||
| -rw-r--r-- | app/controllers/routing_constraint_zones_controller.rb | 2 | ||||
| -rw-r--r-- | app/controllers/stop_areas_controller.rb | 2 | ||||
| -rw-r--r-- | app/controllers/time_tables_controller.rb | 2 | ||||
| -rw-r--r-- | app/controllers/vehicle_journeys_controller.rb | 2 | ||||
| -rw-r--r-- | app/decorators/company_decorator.rb (renamed from app/decorators/chouette/company_decorator.rb) | 2 | ||||
| -rw-r--r-- | app/decorators/line_decorator.rb (renamed from app/decorators/chouette/line_decorator.rb) | 2 | ||||
| -rw-r--r-- | app/decorators/network_decorator.rb (renamed from app/decorators/chouette/network_decorator.rb) | 2 | ||||
| -rw-r--r-- | app/decorators/route_decorator.rb (renamed from app/decorators/chouette/route_decorator.rb) | 2 | ||||
| -rw-r--r-- | app/decorators/routing_constraint_zone_decorator.rb (renamed from app/decorators/chouette/routing_constraint_zone_decorator.rb) | 2 | ||||
| -rw-r--r-- | app/decorators/stop_area_decorator.rb (renamed from app/decorators/chouette/stop_area_decorator.rb) | 2 | ||||
| -rw-r--r-- | app/decorators/stop_point_decorator.rb (renamed from app/decorators/chouette/stop_point_decorator.rb) | 4 | ||||
| -rw-r--r-- | app/decorators/time_table_decorator.rb (renamed from app/decorators/chouette/time_table_decorator.rb) | 2 | ||||
| -rw-r--r-- | app/models/chouette.rb | 5 | ||||
| -rw-r--r-- | app/models/chouette/active_record.rb | 4 | ||||
| -rw-r--r-- | app/models/chouette/stop_point.rb | 2 | ||||
| -rw-r--r-- | app/models/chouette/timeband.rb | 2 | ||||
| -rw-r--r-- | app/policies/access_link_policy.rb (renamed from app/policies/chouette/access_link_policy.rb) | 2 | ||||
| -rw-r--r-- | app/policies/access_point_policy.rb (renamed from app/policies/chouette/access_point_policy.rb) | 2 | ||||
| -rw-r--r-- | app/policies/company_policy.rb (renamed from app/policies/chouette/company_policy.rb) | 2 | ||||
| -rw-r--r-- | app/policies/connection_link_policy.rb (renamed from app/policies/chouette/connection_link_policy.rb) | 2 | ||||
| -rw-r--r-- | app/policies/group_of_line_policy.rb (renamed from app/policies/chouette/group_of_line_policy.rb) | 2 | ||||
| -rw-r--r-- | app/policies/journey_pattern_policy.rb (renamed from app/policies/chouette/journey_pattern_policy.rb) | 2 | ||||
| -rw-r--r-- | app/policies/line_policy.rb (renamed from app/policies/chouette/line_policy.rb) | 2 | ||||
| -rw-r--r-- | app/policies/network_policy.rb (renamed from app/policies/chouette/network_policy.rb) | 2 | ||||
| -rw-r--r-- | app/policies/route_policy.rb (renamed from app/policies/chouette/route_policy.rb) | 2 | ||||
| -rw-r--r-- | app/policies/routing_constraint_zone_policy.rb (renamed from app/policies/chouette/routing_constraint_zone_policy.rb) | 2 | ||||
| -rw-r--r-- | app/policies/stop_area_policy.rb (renamed from app/policies/chouette/stop_area_policy.rb) | 2 | ||||
| -rw-r--r-- | app/policies/time_table_policy.rb (renamed from app/policies/chouette/time_table_policy.rb) | 2 | ||||
| -rw-r--r-- | app/policies/vehicle_journey_policy.rb (renamed from app/policies/chouette/vehicle_journey_policy.rb) | 2 | 
35 files changed, 23 insertions, 54 deletions
| diff --git a/app/controllers/companies_controller.rb b/app/controllers/companies_controller.rb index ec695bcbf..bc5bedd7f 100644 --- a/app/controllers/companies_controller.rb +++ b/app/controllers/companies_controller.rb @@ -77,7 +77,7 @@ class CompaniesController < InheritedResources::Base    def decorate_companies(companies)      ModelDecorator.decorate(        companies, -      with: Chouette::CompanyDecorator, +      with: CompanyDecorator,        context: {          referential: line_referential        } diff --git a/app/controllers/journey_patterns_collections_controller.rb b/app/controllers/journey_patterns_collections_controller.rb index f217dccb3..546158fa8 100644 --- a/app/controllers/journey_patterns_collections_controller.rb +++ b/app/controllers/journey_patterns_collections_controller.rb @@ -48,7 +48,7 @@ class JourneyPatternsCollectionsController < ChouetteController    end    def user_permissions -    policy = policy(:"chouette/journey_pattern") +    policy = policy(:journey_pattern)      @perms =        %w{create destroy update}.inject({}) do | permissions, action |          permissions.merge( "journey_patterns.#{action}" => policy.authorizes_action?(action) ) diff --git a/app/controllers/lines_controller.rb b/app/controllers/lines_controller.rb index 49a8ca2c5..cf2908500 100644 --- a/app/controllers/lines_controller.rb +++ b/app/controllers/lines_controller.rb @@ -15,7 +15,7 @@ class LinesController < InheritedResources::Base      index! do |format|        @lines = ModelDecorator.decorate(          @lines, -        with: Chouette::LineDecorator, +        with: LineDecorator,          context: {            line_referential: @line_referential,            current_organisation: current_organisation diff --git a/app/controllers/networks_controller.rb b/app/controllers/networks_controller.rb index d90af0ed8..98c840777 100644 --- a/app/controllers/networks_controller.rb +++ b/app/controllers/networks_controller.rb @@ -85,7 +85,7 @@ class NetworksController < InheritedResources::Base    def decorate_networks(networks)      ModelDecorator.decorate(        networks, -      with: Chouette::NetworkDecorator, +      with: NetworkDecorator,        context: {          line_referential: line_referential        } diff --git a/app/controllers/referential_lines_controller.rb b/app/controllers/referential_lines_controller.rb index 75e574da3..b9f8c0050 100644 --- a/app/controllers/referential_lines_controller.rb +++ b/app/controllers/referential_lines_controller.rb @@ -29,7 +29,7 @@ class ReferentialLinesController < ChouetteController      @routes = ModelDecorator.decorate(        @routes, -      with: Chouette::RouteDecorator, +      with: RouteDecorator,        context: {          referential: referential,          line: @line diff --git a/app/controllers/routes_controller.rb b/app/controllers/routes_controller.rb index bf3078c59..93f30f4d5 100644 --- a/app/controllers/routes_controller.rb +++ b/app/controllers/routes_controller.rb @@ -48,7 +48,7 @@ class RoutesController < ChouetteController        @route_sp = ModelDecorator.decorate(          @route_sp, -        with: Chouette::StopPointDecorator +        with: StopPointDecorator        )      end    end diff --git a/app/controllers/routing_constraint_zones_controller.rb b/app/controllers/routing_constraint_zones_controller.rb index 8261373a6..6c3da5980 100644 --- a/app/controllers/routing_constraint_zones_controller.rb +++ b/app/controllers/routing_constraint_zones_controller.rb @@ -14,7 +14,7 @@ class RoutingConstraintZonesController < ChouetteController      index! do |format|        @routing_constraint_zones = ModelDecorator.decorate(          @routing_constraint_zones, -        with: Chouette::RoutingConstraintZoneDecorator, +        with: RoutingConstraintZoneDecorator,          context: {            referential: referential,            line: parent diff --git a/app/controllers/stop_areas_controller.rb b/app/controllers/stop_areas_controller.rb index 2732c5f99..1d6f88068 100644 --- a/app/controllers/stop_areas_controller.rb +++ b/app/controllers/stop_areas_controller.rb @@ -56,7 +56,7 @@ class StopAreasController < InheritedResources::Base          @stop_areas = ModelDecorator.decorate(            @stop_areas, -          with: Chouette::StopAreaDecorator +          with: StopAreaDecorator          )        }      end diff --git a/app/controllers/time_tables_controller.rb b/app/controllers/time_tables_controller.rb index 34b1ca89d..0c1769ad7 100644 --- a/app/controllers/time_tables_controller.rb +++ b/app/controllers/time_tables_controller.rb @@ -168,7 +168,7 @@ class TimeTablesController < ChouetteController    def decorate_time_tables(time_tables)      ModelDecorator.decorate(        time_tables, -      with: Chouette::TimeTableDecorator, +      with: TimeTableDecorator,        context: {          referential: @referential        } diff --git a/app/controllers/vehicle_journeys_controller.rb b/app/controllers/vehicle_journeys_controller.rb index e74957ffc..050f2f219 100644 --- a/app/controllers/vehicle_journeys_controller.rb +++ b/app/controllers/vehicle_journeys_controller.rb @@ -158,7 +158,7 @@ class VehicleJourneysController < ChouetteController    end    def user_permissions -    policy = policy(:"chouette/vehicle_journey") +    policy = policy(:vehicle_journey)      @perms =        %w{create destroy update}.inject({}) do | permissions, action |          permissions.merge( "vehicle_journeys.#{action}" => policy.authorizes_action?(action) ) diff --git a/app/decorators/chouette/company_decorator.rb b/app/decorators/company_decorator.rb index e6353f009..a95f90128 100644 --- a/app/decorators/chouette/company_decorator.rb +++ b/app/decorators/company_decorator.rb @@ -1,4 +1,3 @@ -module Chouette    class CompanyDecorator < Draper::Decorator      decorates Chouette::Company @@ -51,4 +50,3 @@ module Chouette        links      end    end -end
\ No newline at end of file diff --git a/app/decorators/chouette/line_decorator.rb b/app/decorators/line_decorator.rb index 3a16dfd94..d465f9321 100644 --- a/app/decorators/chouette/line_decorator.rb +++ b/app/decorators/line_decorator.rb @@ -1,4 +1,3 @@ -module Chouette    class LineDecorator < Draper::Decorator      decorates Chouette::Line @@ -44,4 +43,3 @@ module Chouette        links      end    end -end
\ No newline at end of file diff --git a/app/decorators/chouette/network_decorator.rb b/app/decorators/network_decorator.rb index fb6588689..4f22141e0 100644 --- a/app/decorators/chouette/network_decorator.rb +++ b/app/decorators/network_decorator.rb @@ -1,4 +1,3 @@ -module Chouette    class NetworkDecorator < Draper::Decorator      decorates Chouette::Network @@ -43,4 +42,3 @@ module Chouette        links      end    end -end
\ No newline at end of file diff --git a/app/decorators/chouette/route_decorator.rb b/app/decorators/route_decorator.rb index 479847f00..ca35c2dde 100644 --- a/app/decorators/chouette/route_decorator.rb +++ b/app/decorators/route_decorator.rb @@ -1,4 +1,3 @@ -module Chouette    class RouteDecorator < Draper::Decorator      decorates Chouette::Route @@ -74,4 +73,3 @@ module Chouette        links      end    end -end
\ No newline at end of file diff --git a/app/decorators/chouette/routing_constraint_zone_decorator.rb b/app/decorators/routing_constraint_zone_decorator.rb index bd5ccbf30..1d12cfc25 100644 --- a/app/decorators/chouette/routing_constraint_zone_decorator.rb +++ b/app/decorators/routing_constraint_zone_decorator.rb @@ -1,4 +1,3 @@ -module Chouette    class RoutingConstraintZoneDecorator < Draper::Decorator      decorates Chouette::RoutingConstraintZone @@ -41,4 +40,3 @@ module Chouette        links      end    end -end
\ No newline at end of file diff --git a/app/decorators/chouette/stop_area_decorator.rb b/app/decorators/stop_area_decorator.rb index 7525a9a27..c64ecc9e3 100644 --- a/app/decorators/chouette/stop_area_decorator.rb +++ b/app/decorators/stop_area_decorator.rb @@ -1,4 +1,3 @@ -module Chouette    class StopAreaDecorator < Draper::Decorator      decorates Chouette::StopArea @@ -42,4 +41,3 @@ module Chouette        links      end    end -end
\ No newline at end of file diff --git a/app/decorators/chouette/stop_point_decorator.rb b/app/decorators/stop_point_decorator.rb index a9be5459c..f87db73e8 100644 --- a/app/decorators/chouette/stop_point_decorator.rb +++ b/app/decorators/stop_point_decorator.rb @@ -1,5 +1,4 @@ -module Chouette -  class StopPointDecorator < Chouette::StopAreaDecorator +  class StopPointDecorator < StopAreaDecorator      decorates Chouette::StopPoint      delegate_all @@ -8,4 +7,3 @@ module Chouette        super(object.stop_area)      end    end -end
\ No newline at end of file diff --git a/app/decorators/chouette/time_table_decorator.rb b/app/decorators/time_table_decorator.rb index 86906cbe4..e2a5a7a97 100644 --- a/app/decorators/chouette/time_table_decorator.rb +++ b/app/decorators/time_table_decorator.rb @@ -1,4 +1,3 @@ -module Chouette    class TimeTableDecorator < Draper::Decorator      decorates Chouette::TimeTable @@ -54,4 +53,3 @@ module Chouette        links      end    end -end
\ No newline at end of file diff --git a/app/models/chouette.rb b/app/models/chouette.rb new file mode 100644 index 000000000..fe49300d4 --- /dev/null +++ b/app/models/chouette.rb @@ -0,0 +1,5 @@ +module Chouette +  def self.use_relative_model_naming? +    true +  end +end
\ No newline at end of file diff --git a/app/models/chouette/active_record.rb b/app/models/chouette/active_record.rb index e12f30266..c2aab9d50 100644 --- a/app/models/chouette/active_record.rb +++ b/app/models/chouette/active_record.rb @@ -24,6 +24,10 @@ module Chouette        end      end +    def self.model_name +      ActiveModel::Name.new self, Chouette, self.name.demodulize +    end +      # TODO: Can we remove this?      # class << self      #   alias_method :create_reflection_without_chouette_naming, :create_reflection diff --git a/app/models/chouette/stop_point.rb b/app/models/chouette/stop_point.rb index 86be39d70..f4c9b3800 100644 --- a/app/models/chouette/stop_point.rb +++ b/app/models/chouette/stop_point.rb @@ -2,7 +2,7 @@ module Chouette    class StopPoint < Chouette::TridentActiveRecord      def self.policy_class -      Chouette::RoutePolicy +      RoutePolicy      end      include ForBoardingEnumerations diff --git a/app/models/chouette/timeband.rb b/app/models/chouette/timeband.rb index da8bc3dea..21c81ab1c 100644 --- a/app/models/chouette/timeband.rb +++ b/app/models/chouette/timeband.rb @@ -8,6 +8,8 @@ module Chouette    end    class Timeband < Chouette::TridentActiveRecord +    include ObjectidSupport +      self.primary_key = "id"      validates :start_time, :end_time, presence: true diff --git a/app/policies/chouette/access_link_policy.rb b/app/policies/access_link_policy.rb index 539262458..2b974ee71 100644 --- a/app/policies/chouette/access_link_policy.rb +++ b/app/policies/access_link_policy.rb @@ -1,4 +1,3 @@ -module Chouette    class AccessLinkPolicy < ApplicationPolicy      class Scope < Scope        def resolve @@ -18,4 +17,3 @@ module Chouette        !archived? && organisation_match? && user.has_permission?('access_links.destroy')      end    end -end
\ No newline at end of file diff --git a/app/policies/chouette/access_point_policy.rb b/app/policies/access_point_policy.rb index 2ecd971cd..368cf14e7 100644 --- a/app/policies/chouette/access_point_policy.rb +++ b/app/policies/access_point_policy.rb @@ -1,4 +1,3 @@ -module Chouette    class AccessPointPolicy < ApplicationPolicy      class Scope < Scope        def resolve @@ -18,4 +17,3 @@ module Chouette        !archived? && organisation_match? && user.has_permission?('access_points.destroy')      end    end -end
\ No newline at end of file diff --git a/app/policies/chouette/company_policy.rb b/app/policies/company_policy.rb index f2167b91e..d29836e07 100644 --- a/app/policies/chouette/company_policy.rb +++ b/app/policies/company_policy.rb @@ -1,4 +1,3 @@ -module Chouette    class CompanyPolicy < ApplicationPolicy        class Scope < Scope          def resolve @@ -6,4 +5,3 @@ module Chouette          end        end      end -end
\ No newline at end of file diff --git a/app/policies/chouette/connection_link_policy.rb b/app/policies/connection_link_policy.rb index ac7b1746a..7cf0b7131 100644 --- a/app/policies/chouette/connection_link_policy.rb +++ b/app/policies/connection_link_policy.rb @@ -1,4 +1,3 @@ -module Chouette    class ConnectionLinkPolicy < ApplicationPolicy      class Scope < Scope        def resolve @@ -18,4 +17,3 @@ module Chouette        !archived? && organisation_match? && user.has_permission?('connection_links.update')      end    end -end
\ No newline at end of file diff --git a/app/policies/chouette/group_of_line_policy.rb b/app/policies/group_of_line_policy.rb index f31107452..60c60184c 100644 --- a/app/policies/chouette/group_of_line_policy.rb +++ b/app/policies/group_of_line_policy.rb @@ -1,4 +1,3 @@ -module Chouette    class GroupOfLinePolicy < ApplicationPolicy      class Scope < Scope        def resolve @@ -6,4 +5,3 @@ module Chouette        end      end    end -end
\ No newline at end of file diff --git a/app/policies/chouette/journey_pattern_policy.rb b/app/policies/journey_pattern_policy.rb index add28e0ca..c0c9218c2 100644 --- a/app/policies/chouette/journey_pattern_policy.rb +++ b/app/policies/journey_pattern_policy.rb @@ -1,4 +1,3 @@ -module Chouette    class JourneyPatternPolicy < ApplicationPolicy      class Scope < Scope @@ -19,4 +18,3 @@ module Chouette        !archived? && organisation_match? && user.has_permission?('journey_patterns.update')      end    end -end
\ No newline at end of file diff --git a/app/policies/chouette/line_policy.rb b/app/policies/line_policy.rb index 678191ef7..559f4e2f8 100644 --- a/app/policies/chouette/line_policy.rb +++ b/app/policies/line_policy.rb @@ -1,4 +1,3 @@ -module Chouette    class LinePolicy < ApplicationPolicy      class Scope < Scope @@ -22,4 +21,3 @@ module Chouette      def update_footnote?  ; edit_footnote? end      def new_footnote?     ; create_footnote? end    end -end
\ No newline at end of file diff --git a/app/policies/chouette/network_policy.rb b/app/policies/network_policy.rb index d792645b7..75105b7f8 100644 --- a/app/policies/chouette/network_policy.rb +++ b/app/policies/network_policy.rb @@ -1,4 +1,3 @@ -module Chouette    class NetworkPolicy < ApplicationPolicy      class Scope < Scope        def resolve @@ -6,4 +5,3 @@ module Chouette        end      end    end -end
\ No newline at end of file diff --git a/app/policies/chouette/route_policy.rb b/app/policies/route_policy.rb index 224d3c09e..b49f7bca7 100644 --- a/app/policies/chouette/route_policy.rb +++ b/app/policies/route_policy.rb @@ -1,4 +1,3 @@ -module Chouette    class RoutePolicy < ApplicationPolicy      class Scope < Scope        def resolve @@ -22,4 +21,3 @@ module Chouette        create?      end    end -end
\ No newline at end of file diff --git a/app/policies/chouette/routing_constraint_zone_policy.rb b/app/policies/routing_constraint_zone_policy.rb index ce08cfde5..6bdc69d5c 100644 --- a/app/policies/chouette/routing_constraint_zone_policy.rb +++ b/app/policies/routing_constraint_zone_policy.rb @@ -1,4 +1,3 @@ -module Chouette    class RoutingConstraintZonePolicy < ApplicationPolicy      class Scope < Scope        def resolve @@ -18,4 +17,3 @@ module Chouette        !archived? && organisation_match? && user.has_permission?('routing_constraint_zones.update')      end    end -end
\ No newline at end of file diff --git a/app/policies/chouette/stop_area_policy.rb b/app/policies/stop_area_policy.rb index 1a34b3753..eaf4efe60 100644 --- a/app/policies/chouette/stop_area_policy.rb +++ b/app/policies/stop_area_policy.rb @@ -1,4 +1,3 @@ -module Chouette    class StopAreaPolicy < ApplicationPolicy      class Scope < Scope        def resolve @@ -6,4 +5,3 @@ module Chouette        end      end    end -end
\ No newline at end of file diff --git a/app/policies/chouette/time_table_policy.rb b/app/policies/time_table_policy.rb index 33a5f541a..4638eabd8 100644 --- a/app/policies/chouette/time_table_policy.rb +++ b/app/policies/time_table_policy.rb @@ -1,4 +1,3 @@ -module Chouette    class TimeTablePolicy < ApplicationPolicy      class Scope < Scope @@ -31,4 +30,3 @@ module Chouette        update?      end    end -end
\ No newline at end of file diff --git a/app/policies/chouette/vehicle_journey_policy.rb b/app/policies/vehicle_journey_policy.rb index 744c6f8d4..1aa7a812e 100644 --- a/app/policies/chouette/vehicle_journey_policy.rb +++ b/app/policies/vehicle_journey_policy.rb @@ -1,4 +1,3 @@ -module Chouette    class VehicleJourneyPolicy < ApplicationPolicy      class Scope < Scope        def resolve @@ -18,4 +17,3 @@ module Chouette        !archived? && organisation_match? && user.has_permission?('vehicle_journeys.update')      end    end -end
\ No newline at end of file | 
