diff options
Diffstat (limited to 'app')
39 files changed, 264 insertions, 203 deletions
| diff --git a/app/assets/stylesheets/base/_config.sass b/app/assets/stylesheets/base/_config.sass index 65444479f..ec1c43e7f 100644 --- a/app/assets/stylesheets/base/_config.sass +++ b/app/assets/stylesheets/base/_config.sass @@ -16,6 +16,7 @@ $blue: #007fbb  $darkgrey: #4b4b4b  $grey: #a4a4a4 +$lightgrey: rgba($grey, 0.15)  $green: #70b12b  $red: #da2f36 diff --git a/app/assets/stylesheets/components/_forms.sass b/app/assets/stylesheets/components/_forms.sass index 9a363ab97..47faf19b1 100644 --- a/app/assets/stylesheets/components/_forms.sass +++ b/app/assets/stylesheets/components/_forms.sass @@ -229,6 +229,13 @@ $cbx-size-xs: 15px      &[type='checkbox']:checked + label:before        background-color: $blue +    &[type='checkbox']:disabled + label +      &:before +        border-color: $grey +        background-color: $lightgrey +        cursor: not-allowed +      &:after +        display: none  // Table adjustments  table, .table    .td, td, .th, th diff --git a/app/assets/stylesheets/components/_panels.sass b/app/assets/stylesheets/components/_panels.sass index e9f615081..ab25d8184 100644 --- a/app/assets/stylesheets/components/_panels.sass +++ b/app/assets/stylesheets/components/_panels.sass @@ -34,6 +34,7 @@          a            text-decoration: none            color: $blue +          text-transform: capitalize            &:hover, &:focus              color: $darkblue diff --git a/app/controllers/autocomplete_stop_areas_controller.rb b/app/controllers/autocomplete_stop_areas_controller.rb index 233012028..be1badff0 100644 --- a/app/controllers/autocomplete_stop_areas_controller.rb +++ b/app/controllers/autocomplete_stop_areas_controller.rb @@ -18,7 +18,7 @@ class AutocompleteStopAreasController < ChouetteController        scope = scope.possible_parents if relation_children?      end      args = [].tap{|arg| 4.times{arg << "%#{params[:q]}%"}} -    @stop_areas = scope.where("name ILIKE ? OR city_name ILIKE ? OR registration_number ILIKE ? OR objectid ILIKE ?", *args).limit(50) +    @stop_areas = scope.where("unaccent(name) ILIKE unaccent(?) OR unaccent(city_name) ILIKE unaccent(?) OR registration_number ILIKE ? OR objectid ILIKE ?", *args).limit(50)      @stop_areas    end diff --git a/app/controllers/line_referentials_controller.rb b/app/controllers/line_referentials_controller.rb index 39c2cdb89..03dab3f8f 100644 --- a/app/controllers/line_referentials_controller.rb +++ b/app/controllers/line_referentials_controller.rb @@ -3,6 +3,7 @@ class LineReferentialsController < ChouetteController    defaults :resource_class => LineReferential    def sync +    authorize resource, :synchronize?      @sync = resource.line_referential_syncs.build      if @sync.save        flash[:notice] = t('notice.line_referential_sync.created') diff --git a/app/controllers/referentials_controller.rb b/app/controllers/referentials_controller.rb index ee1236912..40e8264ce 100644 --- a/app/controllers/referentials_controller.rb +++ b/app/controllers/referentials_controller.rb @@ -17,6 +17,8 @@ class ReferentialsController < ChouetteController        build_referenial        if !!@referential.created_from_id +        flash[:notice] = t('notice.referentials.duplicate') +          format.html { redirect_to workbench_path(@referential.workbench) }        end      end @@ -60,7 +62,7 @@ class ReferentialsController < ChouetteController    def validate      ComplianceControlSetCopyWorker.perform_async(params[:compliance_control_set], params[:id]) -    flash[:notice] = I18n.t("referentials.operation_in_progress") +    flash[:notice] = t('notice.referentials.validate')      redirect_to(referential_path)    end diff --git a/app/controllers/stop_area_referentials_controller.rb b/app/controllers/stop_area_referentials_controller.rb index 85541230d..f2d375e49 100644 --- a/app/controllers/stop_area_referentials_controller.rb +++ b/app/controllers/stop_area_referentials_controller.rb @@ -2,6 +2,7 @@ class StopAreaReferentialsController < ChouetteController    defaults :resource_class => StopAreaReferential    def sync +    authorize resource, :synchronize?      @sync = resource.stop_area_referential_syncs.build      if @sync.save        flash[:notice] = t('notice.stop_area_referential_sync.created') diff --git a/app/controllers/stop_areas_controller.rb b/app/controllers/stop_areas_controller.rb index 133518324..d4d996adb 100644 --- a/app/controllers/stop_areas_controller.rb +++ b/app/controllers/stop_areas_controller.rb @@ -171,7 +171,7 @@ class StopAreasController < ChouetteController    helper_method :current_referential    def stop_area_params -    params.require(:stop_area).permit( :routing_stop_ids, :routing_line_ids, :children_ids, :stop_area_type, :parent_id, :objectid, :object_version, :name, :comment, :area_type, :registration_number, :nearest_topic_name, :fare_code, :longitude, :latitude, :long_lat_type, :country_code, :street_name, :zip_code, :city_name, :mobility_restricted_suitability, :stairs_availability, :lift_availability, :int_user_needs, :coordinates, :url, :time_zone ) +    params.require(:stop_area).permit( :routing_stop_ids, :routing_line_ids, :children_ids, :parent_id, :objectid, :object_version, :name, :comment, :area_type, :registration_number, :nearest_topic_name, :fare_code, :longitude, :latitude, :long_lat_type, :country_code, :street_name, :zip_code, :city_name, :mobility_restricted_suitability, :stairs_availability, :lift_availability, :int_user_needs, :coordinates, :url, :time_zone )    end  end diff --git a/app/decorators/company_decorator.rb b/app/decorators/company_decorator.rb index 9416c73ae..50b82d276 100644 --- a/app/decorators/company_decorator.rb +++ b/app/decorators/company_decorator.rb @@ -18,13 +18,6 @@ class CompanyDecorator < Draper::Decorator    def action_links      links = [] -    if h.policy(Chouette::Company).create? -      links << Link.new( -        content: h.t('companies.actions.new'), -        href: h.new_line_referential_company_path(context[:referential]) -      ) -    end -      if h.policy(object).update?        links << Link.new(          content: h.t('companies.actions.edit'), @@ -37,7 +30,7 @@ class CompanyDecorator < Draper::Decorator      if h.policy(object).destroy?        links << Link.new( -        content: t('companies.actions.destroy'), +        content: h.destroy_link_content('companies.actions.destroy'),          href: h.line_referential_company_path(            context[:referential],            object diff --git a/app/decorators/compliance_check_set_decorator.rb b/app/decorators/compliance_check_set_decorator.rb index 096596b19..c58e14d88 100644 --- a/app/decorators/compliance_check_set_decorator.rb +++ b/app/decorators/compliance_check_set_decorator.rb @@ -3,15 +3,6 @@ class ComplianceCheckSetDecorator < Draper::Decorator    def action_links      links = [] - -    links << Link.new( -      content: h.destroy_link_content, -      href: h.workbench_compliance_check_sets_path(object.id), -      method: :delete, -      data: {confirm: h.t('imports.actions.destroy_confirm')} -    ) - -    links    end    def lines_status diff --git a/app/decorators/referential_line_decorator.rb b/app/decorators/referential_line_decorator.rb index 55acf7ed9..654f68bf5 100644 --- a/app/decorators/referential_line_decorator.rb +++ b/app/decorators/referential_line_decorator.rb @@ -24,21 +24,6 @@ class ReferentialLineDecorator < Draper::Decorator        )      ) -    if h.policy(Chouette::Line).create? && -        context[:referential].organisation == context[:current_organisation] -      links << Link.new( -        content: h.t('actions.new'), -        href: h.new_referential_line_path(context[:referential]) -      ) -    end - -    if h.policy(object).update? -      links << Link.new( -        content: h.t('actions.edit'), -        href: h.edit_referential_line_path(context[:referential], object) -      ) -    end -      if h.policy(object).destroy?        links << Link.new(          content: h.destroy_link_content('actions.destroy'), diff --git a/app/decorators/stop_area_decorator.rb b/app/decorators/stop_area_decorator.rb index 4e777292d..8b2ebf490 100644 --- a/app/decorators/stop_area_decorator.rb +++ b/app/decorators/stop_area_decorator.rb @@ -7,15 +7,6 @@ class StopAreaDecorator < Draper::Decorator      links = []      stop_area ||= object -    if h.policy(Chouette::StopArea).new? -      links << Link.new( -        content: h.t('stop_areas.actions.new'), -        href: h.new_stop_area_referential_stop_area_path( -          stop_area.stop_area_referential -        ) -      ) -    end -      if h.policy(stop_area).update?        links << Link.new(          content: h.t('stop_areas.actions.edit'), diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 124604cd9..713542ff4 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -23,12 +23,18 @@ module ApplicationHelper    end    def page_header_meta(object) -    info = t('last_update', time: l(object.updated_at, format: :short)) -    if object.try(:versions) -      author = object.versions.try(:last).try(:whodunnit) || t('default_whodunnit') -      info   = "#{info} <br/> #{t('whodunnit', author: author)}" +    out = "" +    display = true +    display = policy(object).synchronize? if policy(object).respond_to?(:synchronize?) rescue false +    if display +      info = t('last_update', time: l(object.updated_at, format: :short)) +      if object.try(:versions) +        author = object.versions.try(:last).try(:whodunnit) || t('default_whodunnit') +        info   = "#{info} <br/> #{t('whodunnit', author: author)}" +      end +      out += content_tag :div, info.html_safe, class: 'small last-update'      end -    content_tag :div, info.html_safe, class: 'small' +    out.html_safe    end    def page_header_content_for(object) diff --git a/app/helpers/table_builder_helper.rb b/app/helpers/table_builder_helper.rb index 37f01ce0d..de78e903d 100644 --- a/app/helpers/table_builder_helper.rb +++ b/app/helpers/table_builder_helper.rb @@ -95,6 +95,18 @@ module TableBuilderHelper        class: cls    end +  def self.item_row_class_name collection +    if collection.respond_to?(:model) +      model_name = collection.model.name +    elsif collection.respond_to?(:first) +      model_name = collection.first.class.name +    else +      model_name = "item" +    end + +    model_name.split("::").last.parameterize +  end +    private    def thead(collection, columns, sortable, selectable, has_links, overhead, model ) @@ -187,86 +199,92 @@ module TableBuilderHelper      end    end -  def tbody(collection, columns, selectable, links, overhead) -    content_tag :tbody do -      collection.map do |item| - -        content_tag :tr do -          bcont = [] - -          if selectable -            bcont << content_tag( -              :td, -              checkbox(id_name: item.try(:id), value: item.try(:id)) -            ) -          end - -          columns.each do |column| -            value = column.value(item) +  def tr item, columns, selectable, links, overhead, model_name +    klass = "#{model_name}-#{item.id}" +    content_tag :tr, class: klass do +      bcont = [] +      if selectable +        disabled = selectable.respond_to?(:call) && !selectable.call(item) +        bcont << content_tag( +          :td, +          checkbox(id_name: item.try(:id), value: item.try(:id), disabled: disabled) +        ) +      end -            if column.linkable? -              path = column.link_to(item) -              link = link_to(value, path) +      columns.each do |column| +        value = column.value(item) -              if overhead.empty? -                bcont << content_tag(:td, link, title: 'Voir') +        if column.linkable? +          path = column.link_to(item) +          link = link_to(value, path) -              else -                i = columns.index(column) - -                if overhead[i].blank? -                  if (i > 0) && (overhead[i - 1][:width] > 1) -                    clsArrayAlt = overhead[i - 1][:cls].split +          if overhead.empty? +            bcont << content_tag(:td, link, title: 'Voir') -                    bcont << content_tag(:td, link, title: 'Voir', class: td_cls(clsArrayAlt)) +          else +            i = columns.index(column) -                  else -                    bcont << content_tag(:td, link, title: 'Voir') -                  end +            if overhead[i].blank? +              if (i > 0) && (overhead[i - 1][:width] > 1) +                clsArrayAlt = overhead[i - 1][:cls].split -                else -                  clsArray = overhead[columns.index(column)][:cls].split +                bcont << content_tag(:td, link, title: 'Voir', class: td_cls(clsArrayAlt)) -                  bcont << content_tag(:td, link, title: 'Voir', class: td_cls(clsArray)) -                end +              else +                bcont << content_tag(:td, link, title: 'Voir')                end              else -              if overhead.empty? -                bcont << content_tag(:td, value) +              clsArray = overhead[columns.index(column)][:cls].split -              else -                i = columns.index(column) +              bcont << content_tag(:td, link, title: 'Voir', class: td_cls(clsArray)) +            end +          end -                if overhead[i].blank? -                  if (i > 0) && (overhead[i - 1][:width] > 1) -                    clsArrayAlt = overhead[i - 1][:cls].split +        else +          if overhead.empty? +            bcont << content_tag(:td, value) -                    bcont << content_tag(:td, value, class: td_cls(clsArrayAlt)) +          else +            i = columns.index(column) -                  else -                    bcont << content_tag(:td, value) -                  end +            if overhead[i].blank? +              if (i > 0) && (overhead[i - 1][:width] > 1) +                clsArrayAlt = overhead[i - 1][:cls].split -                else -                  clsArray = overhead[i][:cls].split +                bcont << content_tag(:td, value, class: td_cls(clsArrayAlt)) -                  bcont << content_tag(:td, value, class: td_cls(clsArray)) -                end +              else +                bcont << content_tag(:td, value)                end + +            else +              clsArray = overhead[i][:cls].split + +              bcont << content_tag(:td, value, class: td_cls(clsArray))              end            end +        end +      end -          if links.any? || item.try(:action_links).try(:any?) -            bcont << content_tag( -              :td, -              build_links(item, links), -              class: 'actions' -            ) -          end +      if links.any? || item.try(:action_links).try(:any?) +        bcont << content_tag( +          :td, +          build_links(item, links), +          class: 'actions' +        ) +      end -          bcont.join.html_safe -        end +      bcont.join.html_safe +    end +  end + +  def tbody(collection, columns, selectable, links, overhead) +    model_name = TableBuilderHelper.item_row_class_name collection + +    content_tag :tbody do +      collection.map do |item| +        tr item, columns, selectable, links, overhead, model_name        end.join.html_safe      end    end @@ -341,13 +359,14 @@ module TableBuilderHelper      end    end -  def checkbox(id_name:, value:) +  def checkbox(id_name:, value:, disabled: false)      content_tag :div, '', class: 'checkbox' do -      check_box_tag(id_name, value).concat( +      check_box_tag(id_name, value, nil, disabled: disabled).concat(          content_tag(:label, '', for: id_name)        )      end    end +    def gear_menu_link(link)      content_tag(        :li, diff --git a/app/models/chouette/area_type.rb b/app/models/chouette/area_type.rb new file mode 100644 index 000000000..f295fe7ae --- /dev/null +++ b/app/models/chouette/area_type.rb @@ -0,0 +1,37 @@ +class Chouette::AreaType + +  ALL = %i(zdep zder zdlp zdlr lda).freeze + +  @@all = ALL +  mattr_accessor :all + +  def self.all=(values) +    @@all = ALL & values +    reset_caches! +  end + +  @@instances = {} +  def self.find(code) +    code = code.to_sym +    @@instances[code] ||= new(code) if ALL.include? code +  end + +  def self.reset_caches! +    @@instances = {} +    @@options = nil +  end + +  def self.options +    @@options ||= all.map { |c| find(c) }.map { |t| [ t.label, t.code ] } +  end + +  attr_reader :code +  def initialize(code) +    @code = code +  end + +  def label +    I18n.translate code, scope: 'area_types.label' +  end + +end diff --git a/app/models/chouette/stop_area.rb b/app/models/chouette/stop_area.rb index cc7170728..f216ce449 100644 --- a/app/models/chouette/stop_area.rb +++ b/app/models/chouette/stop_area.rb @@ -9,7 +9,7 @@ module Chouette      include ObjectidSupport      extend Enumerize -    enumerize :area_type, in: %i(zdep zder zdlp zdlr lda) +    enumerize :area_type, in: Chouette::AreaType::ALL      with_options dependent: :destroy do |assoc|        assoc.has_many :stop_points @@ -196,10 +196,12 @@ module Chouette        GeoRuby::SimpleFeatures::Envelope.from_coordinates coordinates      end +    # DEPRECATED use StopArea#area_type      def stop_area_type        area_type ? area_type : " "      end +    # DEPRECATED use StopArea#area_type      def stop_area_type=(stop_area_type)        self.area_type = (stop_area_type ? stop_area_type.camelcase : nil)      end diff --git a/app/models/referential_cloning.rb b/app/models/referential_cloning.rb index 5bf283814..24117e6c8 100644 --- a/app/models/referential_cloning.rb +++ b/app/models/referential_cloning.rb @@ -2,14 +2,27 @@ class ReferentialCloning < ActiveRecord::Base    include AASM    belongs_to :source_referential, class_name: 'Referential'    belongs_to :target_referential, class_name: 'Referential' -  after_commit :perform_clone, :on => :create +  after_commit :clone, on: :create -  private -  def perform_clone +  def clone      ReferentialCloningWorker.perform_async(id) -    # ReferentialCloningWorker.new.perform(id)    end +  def clone! +    run! + +    AF83::SchemaCloner +      .new(source_referential.slug, target_referential.slug) +      .clone_schema + +    successful! +  rescue Exception => e +    Rails.logger.error "Clone failed : #{e}" +    failed! +  end + +  private +    aasm column: :status do      state :new, :initial => true      state :pending diff --git a/app/models/user.rb b/app/models/user.rb index 37d35209a..1342f60ed 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -36,7 +36,7 @@ class User < ActiveRecord::Base      self.name         = extra[:full_name]      self.email        = extra[:email]      self.organisation = Organisation.sync_update extra[:organisation_code], extra[:organisation_name], extra[:functional_scope] -    self.permissions  = Stif::PermissionTranslator.translate(extra[:permissions]) +    self.permissions  = Stif::PermissionTranslator.translate(extra[:permissions], self.organisation)    end    def self.portail_api_request diff --git a/app/policies/calendar_policy.rb b/app/policies/calendar_policy.rb index 074c41d8d..c2da8c924 100644 --- a/app/policies/calendar_policy.rb +++ b/app/policies/calendar_policy.rb @@ -5,18 +5,15 @@ class CalendarPolicy < ApplicationPolicy      end    end -  def create?  -    !archived? && user.has_permission?('calendars.create') -  end -  def destroy? -    !archived? & organisation_match? && user.has_permission?('calendars.destroy') -  end -  def update? -    !archived? && organisation_match? && user.has_permission?('calendars.update') +  def create? +    user.has_permission?('calendars.create')    end +  def destroy?; instance_permission("destroy") end +  def update?; instance_permission("update") end +  def share?; instance_permission("share") end -  def share? -    user.organisation.name == 'STIF' # FIXME +  private +  def instance_permission permission +    organisation_match? && user.has_permission?("calendars.#{permission}")    end -  end diff --git a/app/policies/line_referential_policy.rb b/app/policies/line_referential_policy.rb new file mode 100644 index 000000000..ee742a083 --- /dev/null +++ b/app/policies/line_referential_policy.rb @@ -0,0 +1,14 @@ +class LineReferentialPolicy < ApplicationPolicy +  class Scope < Scope +    def resolve +      scope +    end +  end + +  def synchronize?; instance_permission("synchronize") end + +  private +  def instance_permission permission +    user.has_permission?("line_referentials.#{permission}") +  end +end diff --git a/app/policies/stop_area_referential_policy.rb b/app/policies/stop_area_referential_policy.rb new file mode 100644 index 000000000..e370babf8 --- /dev/null +++ b/app/policies/stop_area_referential_policy.rb @@ -0,0 +1,14 @@ +class StopAreaReferentialPolicy < ApplicationPolicy +  class Scope < Scope +    def resolve +      scope +    end +  end + +  def synchronize?; instance_permission("synchronize") end + +  private +  def instance_permission permission +    user.has_permission?("stop_area_referentials.#{permission}") +  end +end diff --git a/app/views/companies/index.html.slim b/app/views/companies/index.html.slim index 5d746642f..e031f3776 100644 --- a/app/views/companies/index.html.slim +++ b/app/views/companies/index.html.slim @@ -34,7 +34,7 @@                  end \                ) \              ], -            links: [:show, :edit], +            links: [:show],              cls: 'table has-search'            = new_pagination @companies, 'pull-right' diff --git a/app/views/compliance_check_sets/index.html.slim b/app/views/compliance_check_sets/index.html.slim index f5d1bd777..f109845b4 100644 --- a/app/views/compliance_check_sets/index.html.slim +++ b/app/views/compliance_check_sets/index.html.slim @@ -12,7 +12,7 @@                [ \                  TableBuilderHelper::Column.new( \                    key: :ref, \ -                  attribute: 'compliance_check_set_id' \ +                  attribute: 'id' \                  ), \                  TableBuilderHelper::Column.new( \                    key: :creation_date, \ @@ -41,5 +41,3 @@        .row.mt-xs          .col-lg-12            = replacement_msg t('compliance_check_sets.search_no_results') - - diff --git a/app/views/dashboards/_dashboard.html.slim b/app/views/dashboards/_dashboard.html.slim index f03301e23..7d547bf4c 100644 --- a/app/views/dashboards/_dashboard.html.slim +++ b/app/views/dashboards/_dashboard.html.slim @@ -5,7 +5,7 @@          .panel-heading            h3.panel-title.with_actions              div -              = workbench.name +              = link_to workbench.name, workbench_path(workbench)                span.badge.ml-xs = workbench.referentials.count if workbench.referentials.present?              div @@ -22,7 +22,7 @@      .panel.panel-default        .panel-heading          h3.panel-title.with_actions -          = "Modèles de calendrier" +          = link_to I18n.t("activerecord.models.calendar", count: @dashboard.current_organisation.calendars.size), calendars_path            div              = link_to '', calendars_path, class: ' fa fa-chevron-right pull-right'        - if @dashboard.current_organisation.calendars.present? diff --git a/app/views/devise/invitations/edit.html.slim b/app/views/devise/invitations/edit.html.slim index 6c9a6f436..7a22146c0 100644 --- a/app/views/devise/invitations/edit.html.slim +++ b/app/views/devise/invitations/edit.html.slim @@ -1,14 +1,19 @@ -.col-md-offset-2.col-md-8 -  .panel.panel-default -    .panel-heading = t('devise.invitations.edit.header') -     -    .panel-body -      = simple_form_for resource, as: resource_name, :url => invitation_path(resource_name), :html => { :method => :put, class: "form-horizontal" } do |form| -        = form.hidden_field :invitation_token - -        = form.input :name -        = form.input :password, as: :password -        = form.input :password_confirmation, as: :password - -        .submit -          = form.button :submit, value: t('devise.invitations.edit.submit_button'), class: 'btn-info'
\ No newline at end of file +/ PageHeader + +- content_for :page_header_title, t('.title') + +/ PageContent +.page_content +  .container-fluid +    .row +      .col-lg-8.col-lg-offset-2.col-md-8.col-md-offset-2.col-sm-10.col-sm-offset-1 +        = simple_form_for resource, as: resource_name, :url => invitation_path(resource_name), :html => { :method => :put, class: "form-horizontal", id: 'invitation_form' } do |form| +            .row +              .col-lg-12 +                = form.hidden_field :invitation_token + +                = form.input :name +                = form.input :password, as: :password +                = form.input :password_confirmation, as: :password + +            = form.button :submit, value: t('devise.invitations.edit.submit_button'), class: 'btn-info btn-default formSubmitr', form: 'invitation_form' diff --git a/app/views/devise/passwords/edit.html.slim b/app/views/devise/passwords/edit.html.slim index 864a44499..0d18f657c 100644 --- a/app/views/devise/passwords/edit.html.slim +++ b/app/views/devise/passwords/edit.html.slim @@ -1,13 +1,17 @@ -.col-md-offset-2.col-md-8 -  .panel.panel-default -    .panel-heading = t('.title') -    .panel-body -      = simple_form_for(resource, :as => resource_name, :url => password_path(resource_name), :html => { :method => :put, class: "form-horizontal" }) do |f| +/ PageHeader -        = f.input :reset_password_token, as: :hidden -        = f.input :password, as: :password -        = f.input :password_confirmation, as: :password -         -        .form-actions -          = link_to t("cancel"), unauthenticated_root_path, class: 'btn btn-default' -          = f.button :submit, :value => t("devise.passwords.edit.commit"), class: 'btn-info'
\ No newline at end of file +- content_for :page_header_title, t('.title') + +/ PageContent +.page_content +  .container-fluid +    .row +      .col-lg-8.col-lg-offset-2.col-md-8.col-md-offset-2.col-sm-10.col-sm-offset-1 +        = simple_form_for(resource, :as => resource_name, :url => password_path(resource_name), :html => { :method => :put, class: "form-horizontal", id: 'password_form' }) do |f| +          .row +            .col-lg-12 +              = f.input :reset_password_token, as: :hidden +              = f.input :password, as: :password +              = f.input :password_confirmation, as: :password + +          = f.button :submit, :value => t("devise.passwords.edit.commit"), class: 'btn btn-default formSubmitr', form: 'password_form' diff --git a/app/views/devise/passwords/new.html.slim b/app/views/devise/passwords/new.html.slim index 6e03595fc..303f78f0e 100644 --- a/app/views/devise/passwords/new.html.slim +++ b/app/views/devise/passwords/new.html.slim @@ -1,6 +1,6 @@  / PageHeader -= pageheader '', t('.title') +- content_for :page_header_title, t('.title')  / PageContent  .page_content @@ -12,4 +12,4 @@              .col-lg-12                = form.input :email, :as => :email, placeholder: 'user@domain.com' -          = form.button :submit, :value => t("devise.passwords.new.commit"), class: 'btn btn-default formSubmitr', form: 'invitation_form' +          = form.button :submit, :value => t("devise.passwords.new.commit"), class: 'btn btn-default formSubmitr', form: 'password_form' diff --git a/app/views/devise/sessions/new.html.slim b/app/views/devise/sessions/new.html.slim index 0ed17e24a..a812726e5 100644 --- a/app/views/devise/sessions/new.html.slim +++ b/app/views/devise/sessions/new.html.slim @@ -1,3 +1,5 @@ +- content_for :page_header_title, t('.title') +  .page_content#devise    .container-fluid      #sessions_new.row diff --git a/app/views/layouts/navigation/_main_nav_top.html.slim b/app/views/layouts/navigation/_main_nav_top.html.slim index d6c849d3f..363a89b48 100644 --- a/app/views/layouts/navigation/_main_nav_top.html.slim +++ b/app/views/layouts/navigation/_main_nav_top.html.slim @@ -11,7 +11,7 @@            span.fa.fa-lg.fa-tasks          = link_to '#', class: 'menu-item', data: { panel: 'toggle', target: '#profile_panel' }, title: 'Profil' do -          span = current_user.username +          span = current_user.name            span.fa.fa-lg.fa-user diff --git a/app/views/line_referentials/show.html.slim b/app/views/line_referentials/show.html.slim index b4b32bc52..763eb076e 100644 --- a/app/views/line_referentials/show.html.slim +++ b/app/views/line_referentials/show.html.slim @@ -1,7 +1,8 @@  - breadcrumb :line_referential, @line_referential  - page_header_content_for @line_referential -- content_for :page_header_actions do -  = link_to(t('actions.sync'), sync_line_referential_path(@line_referential), method: :post, class: 'btn btn-default') +- if policy(@line_referential).synchronize? +  - content_for :page_header_actions do +    = link_to(t('actions.sync'), sync_line_referential_path(@line_referential), method: :post, class: 'btn btn-default')  - content_for :page_header_content do    .row.mb-md diff --git a/app/views/referential_companies/index.html.slim b/app/views/referential_companies/index.html.slim index de0f7de69..07de2bc9d 100644 --- a/app/views/referential_companies/index.html.slim +++ b/app/views/referential_companies/index.html.slim @@ -46,7 +46,7 @@                  attribute: 'url' \                ) \              ], -            links: [:show, :edit], +            links: [:show],              cls: 'table has-search'            = new_pagination @companies, 'pull-right' diff --git a/app/views/stop_area_referentials/show.html.slim b/app/views/stop_area_referentials/show.html.slim index d43333fd9..911006c39 100644 --- a/app/views/stop_area_referentials/show.html.slim +++ b/app/views/stop_area_referentials/show.html.slim @@ -1,13 +1,14 @@  - breadcrumb :stop_area_referential, @stop_area_referential -- content_for :page_header_actions do -  = link_to(t('actions.sync'), sync_stop_area_referential_path(@stop_area_referential), method: :post, class: 'btn btn-default') +- if policy(@stop_area_referential).synchronize? +  - content_for :page_header_actions do +    = link_to(t('actions.sync'), sync_stop_area_referential_path(@stop_area_referential), method: :post, class: 'btn btn-default')  - content_for :page_header_content do    .row.mb-md      .col-lg-12.text-right        = link_to stop_area_referential_stop_areas_path(@stop_area_referential), class: 'btn btn-primary' do          = Referential.human_attribute_name(:stop_areas) -        em.small = " (#{@stop_area_referential.stop_areas.size})" +        em.small = " (#{@stop_area_referential.stop_areas.count})"  - page_header_content_for @stop_area_referential  .page_content diff --git a/app/views/stop_areas/_filters.html.slim b/app/views/stop_areas/_filters.html.slim index 3b99f377c..90368dff4 100644 --- a/app/views/stop_areas/_filters.html.slim +++ b/app/views/stop_areas/_filters.html.slim @@ -12,7 +12,7 @@      .form-group.togglable        = f.label Chouette::StopArea.human_attribute_name(:area_type), required: false, class: 'control-label' -      = f.input :area_type_eq_any, collection: Chouette::StopArea.area_type.options.sort, as: :check_boxes, label: false, label_method: lambda{|w| ("<span>" + t("enumerize.stop_area.area_type.#{w[1]}") + "</span>").html_safe}, required: false, wrapper_html: { class: 'checkbox_list' } +      = f.input :area_type_eq_any, collection: Chouette::AreaType.options, as: :check_boxes, label: false, label_method: lambda{|w| ("<span>" + w[0] + "</span>").html_safe}, required: false, wrapper_html: { class: 'checkbox_list' }    .actions      = link_to 'Effacer', @workbench, class: 'btn btn-link' diff --git a/app/views/stop_areas/_form.html.slim b/app/views/stop_areas/_form.html.slim index 20c7c0468..ac2cb4e87 100644 --- a/app/views/stop_areas/_form.html.slim +++ b/app/views/stop_areas/_form.html.slim @@ -6,7 +6,7 @@          /= @map.to_html          = f.input :id, as: :hidden          = f.input :name, :input_html => {:title => t("formtastic.titles#{format_restriction_for_locales(@referential)}.stop_area.name")} -        = f.input :area_type, as: :select, :input_html => {:disabled => !@stop_area.new_record?}, :collection => Chouette::StopArea.area_type.options, :include_blank => false +        = f.input :area_type, as: :select, :input_html => {:disabled => !@stop_area.new_record?}, :collection => Chouette::AreaType.options, :include_blank => false          .location_info            h3 = t("stop_areas.stop_area.localisation") diff --git a/app/views/stop_areas/index.html.slim b/app/views/stop_areas/index.html.slim index c4d880081..63e99fd75 100644 --- a/app/views/stop_areas/index.html.slim +++ b/app/views/stop_areas/index.html.slim @@ -24,7 +24,7 @@                  key: :name, \                  attribute: 'name', \                  link_to: lambda do |stop_area| \ -                  referential_stop_area_path( \ +                  stop_area_referential_stop_area_path( \                      @stop_area_referential, \                      stop_area \                    ) \ @@ -48,10 +48,10 @@                ), \                TableBuilderHelper::Column.new( \                  key: :area_type, \ -                attribute: Proc.new { |s| (s.area_type.nil? ? '-' : t("enumerize.stop_area.area_type.#{s.try(:area_type)}")) } \ +                attribute: Proc.new { |s| Chouette::AreaType.find(s.area_type).try :label } \                ), \              ], -            links: [:show, :edit, :delete], +            links: [:show],              cls: 'table has-filter has-search'            = new_pagination @stop_areas, 'pull-right' diff --git a/app/views/stop_areas/show.html.slim b/app/views/stop_areas/show.html.slim index af673bb25..1b1209a68 100644 --- a/app/views/stop_areas/show.html.slim +++ b/app/views/stop_areas/show.html.slim @@ -17,7 +17,7 @@        .col-lg-6.col-md-6.col-sm-12.col-xs-12          = definition_list t('metadatas'),            { t('id_reflex') => @stop_area.get_objectid.short_id, -            @stop_area.human_attribute_name(:stop_area_type) => t("area_types.label.#{@stop_area.stop_area_type}"), +            @stop_area.human_attribute_name(:stop_area_type) => Chouette::AreaType.find(@stop_area.area_type).try(:label),              @stop_area.human_attribute_name(:registration_number) => @stop_area.registration_number,              'Coordonnées' => geo_data(@stop_area, @stop_area_referential),              @stop_area.human_attribute_name(:zip_code) => @stop_area.zip_code, diff --git a/app/views/stop_points/_stop_point.html.slim b/app/views/stop_points/_stop_point.html.slim index ca86e339a..e54158cef 100644 --- a/app/views/stop_points/_stop_point.html.slim +++ b/app/views/stop_points/_stop_point.html.slim @@ -5,7 +5,7 @@          = link_to [@referential, stop_point.stop_area], class: "preview", title: "#{Chouette::StopArea.model_name.human.capitalize} #{stop_point.stop_area.name}" do            span.name              span.label.label-primary = stop_point.position + 1 -            = image_tag "map/" + stop_point.stop_area.stop_area_type + ".png" +            = image_tag "map/" + stop_point.stop_area.area_type + ".png"              = truncate(stop_point.stop_area.name, length: 20)    .panel-body @@ -27,4 +27,4 @@          = t(".no_object")        - else          - stop_point.stop_area.lines.each do |line| -          span.label.label-default.line = line.number || truncate( line.name, length: 4 )
\ No newline at end of file +          span.label.label-default.line = line.number || truncate( line.name, length: 4 ) diff --git a/app/views/workbenches/show.html.slim b/app/views/workbenches/show.html.slim index af312fc08..1c82c34b7 100644 --- a/app/views/workbenches/show.html.slim +++ b/app/views/workbenches/show.html.slim @@ -57,7 +57,7 @@                    attribute: '' \                  ) \                ], -              selectable: true, +              selectable: ->(ref){ @workbench.referentials.include?(ref) },                links: [:show, :edit],                cls: 'table has-filter has-search' diff --git a/app/workers/referential_cloning_worker.rb b/app/workers/referential_cloning_worker.rb index 6592160ec..e20148055 100644 --- a/app/workers/referential_cloning_worker.rb +++ b/app/workers/referential_cloning_worker.rb @@ -1,32 +1,7 @@  class ReferentialCloningWorker    include Sidekiq::Worker -  # Replace default apartment created schema with clone schema from source referential    def perform(id) -    ref_cloning = ReferentialCloning.find id - -    source_schema = ref_cloning.source_referential.slug -    target_schema = ref_cloning.target_referential.slug - -    clone_schema ref_cloning, source_schema, target_schema -  end - -  private - -  def clone_schema ref_cloning, source_schema, target_schema -    ref_cloning.run! - -    AF83::SchemaCloner -      .new(source_schema, target_schema)  -      .clone_schema - -    ref_cloning.successful! -  rescue Exception => e -    Rails.logger.error "ReferentialCloningWorker : #{e}" -    ref_cloning.failed! -  end - -  def execute_sql sql -    ActiveRecord::Base.connection.execute sql +    ReferentialCloning.find(id).clone!    end  end | 
