suite url

This commit is contained in:
Nicolas Bally 2020-06-29 11:34:40 +02:00
parent d213ea6535
commit 44f57de50e
13 changed files with 75 additions and 13 deletions

View File

@ -30,8 +30,16 @@ class Public::CircuitsController < ApplicationController
def show
@circuit = Circuit.find(params[:id])
@circuits_active = true
if @circuit = Circuit.where(:id => params[:id]).first
elsif @circuit = Circuit.where(:slug => params[:id]).first
else
redirect_to public_circuits_path
end
end

View File

@ -72,14 +72,14 @@ class Public::MenuItemsController < ApplicationController
menu_id = 1
@menu_item_lang = @lang.menu_item_langs.joins(:menu_item).where(:menu_items => {:menu_id => menu_id}).find_by_permalink("index")
@menu_item = @menu_item_lang.menu_item
if cookies.permanent[:visites_enquete]
cookies.permanent[:visites_enquete] =cookies.permanent[:visites_enquete].to_i + 1
if @menu_item_lang
@menu_item = @menu_item_lang.menu_item
else
cookies.permanent[:visites_enquete] = 1
redirect_to "/"
end
end
if @menu_item and @menu_item.menu_content and @menu_item.menu_content.class.to_s == "Page"

View File

@ -33,8 +33,15 @@ class Public::OrganisateursController < ApplicationController
def show
@organisateur = Organisateur.find(params[:id])
@organisateurs_active = true
if @organisateur = Organisateur.where(:id => params[:id]).first
elsif @organisateur = Organisateur.where(:slug => params[:id]).first
else
redirect_to public_organisateurs_path
end
end

View File

@ -57,5 +57,9 @@ class Circuit < ApplicationRecord
#end
before_save do
self.slug = "#{self.name} #{self.cp} #{self.city}".to_slug if !self.slug
end
end

View File

@ -41,5 +41,9 @@ class Organisateur < ApplicationRecord
def member_label
"#{self.name}"
end
before_save do
self.slug = "#{self.name} #{self.cp} #{self.city}".to_slug if !self.slug
end
end

View File

@ -9,6 +9,7 @@
= f.input :circuit_region, :label => "Région :"
= f.input :name, :label => "Nom :"
= f.input :slug, :label => "Lien permanent :"
= f.input :website, :label => "Site web :"
= f.input :description, :label => "Description :"
= f.input :person_civilite, :label => "Civilité :"

View File

@ -10,6 +10,7 @@
= f.input :name, :label => "Nom :"
= f.input :slug, :label => "Lien permanent :"
= f.input :website, :label => "Site web :"
= f.input :description, :label => "Description :"
= f.input :person_civilite, :label => "Civilité :"

View File

@ -3,7 +3,7 @@
=# %h3=circuit.name
=link_to [:public, circuit], :class => "circuit" do
=link_to public_circuit_path(:id => circuit.slug), :class => "circuit" do
-img = ""
-img = circuit.logo.file.large.medium.url if circuit.logo
-img = circuit.image_file.file.large.medium.url if circuit.image_file

View File

@ -1,5 +1,5 @@
=link_to [:public, organisateur], :class => "organisateur" do
=link_to public_organisateur_path(:id => organisateur.slug), :class => "organisateur" do
-img = ""
-img = organisateur.logo.file.large.medium.url if organisateur.logo
.img{:style => ("background-image:url('#{img}');" if img)}

View File

@ -1,5 +1,22 @@
Rails.application.routes.draw do
get "/USER_CREATION/1/104--36-mon-compte.html" => redirect("/fr/mon-compte.html")
get "/:lang/mon-compte.html" => "public/my_account#index", :as => :public_my_account
get "/:lang/se-connecter.html" => "public/p_customer_auths#new", :as => :new_public_p_customer_auth
get "/:lang/creer-mon-compte.html" => "public/p_customers#new", :as => :new_public_p_customer
post "/:lang/creer-mon-compte.html" => "public/p_customers#create", :as => :public_p_customers
get "/:lang/circuits/:id.html" => "public/circuits#show", :as => :public_circuit
get "/:lang/circuits.html" => "public/circuits#index", :as => :public_circuits
get "/:lang/organisateurs/:id.html" => "public/organisateurs#show", :as => :public_organisateur
get "/:lang/organisateurs.html" => "public/organisateurs#index", :as => :public_organisateurs
get "/:lang/journees-de-roulage.html" => "public/m_events#index", :as => :public_m_events
namespace :admin do
resources :departement_frances do
member do
@ -623,7 +640,7 @@ Rails.application.routes.draw do
namespace :public do
get "my_account" => "my_account#index", :as => :my_account
get "my_account" => "my_account#index"
resources :particulars
@ -1035,7 +1052,7 @@ Rails.application.routes.draw do
get ':slug.html', to: 'public/m_odrs#show', :as => :public_m_odr
get ':slug.html', to: 'public/menu_items#show', :as => :public_m_odr
root "public/menu_items#index"

View File

@ -0,0 +1,9 @@
class AddSlugToCircuits < ActiveRecord::Migration[6.0]
def change
add_column :circuits, :slug, :string
Circuit.all.each do |circuit|
circuit.save
end
end
end

View File

@ -0,0 +1,9 @@
class AddSlugToOrganisateurs < ActiveRecord::Migration[6.0]
def change
add_column :organisateurs, :slug, :string
Organisateur.all.each do |organisateur|
organisateur.save
end
end
end

View File

@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema.define(version: 2020_06_25_135439) do
ActiveRecord::Schema.define(version: 2020_06_29_091433) do
create_table "accounting_zones", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4", force: :cascade do |t|
t.string "name"
@ -230,6 +230,7 @@ ActiveRecord::Schema.define(version: 2020_06_25_135439) do
t.datetime "created_at", precision: 6, null: false
t.datetime "updated_at", precision: 6, null: false
t.integer "circuit_region_id"
t.string "slug"
t.index ["admin_id"], name: "index_circuits_on_admin_id"
end
@ -319,7 +320,7 @@ ActiveRecord::Schema.define(version: 2020_06_25_135439) do
t.index ["square_image_file_id"], name: "index_data_files_on_square_image_file_id"
end
create_table "departement_frances", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4", force: :cascade do |t|
create_table "departement_frances", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 ROW_FORMAT=DYNAMIC", force: :cascade do |t|
t.string "num_dep"
t.string "dep_name"
t.string "region_name"
@ -1381,6 +1382,7 @@ ActiveRecord::Schema.define(version: 2020_06_25_135439) do
t.datetime "created_at", precision: 6, null: false
t.datetime "updated_at", precision: 6, null: false
t.integer "circuit_region_id"
t.string "slug"
t.index ["admin_id"], name: "index_organisateurs_on_admin_id"
end