From d5787f492c7e0e5178ce584d9f3e81f6e9570941 Mon Sep 17 00:00:00 2001 From: Nicolas Bally Date: Mon, 22 Aug 2011 12:09:17 +0200 Subject: [PATCH] =?UTF-8?q?fonction=20dossier=20th=C3=A9matique=20vs=20pre?= =?UTF-8?q?stations?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/folder.rb | 2 ++ app/models/portlets/dynamic_content.rb | 2 +- app/views/admin/folders/_form.html.haml | 1 + app/views/admin/folders/_show.html.haml | 5 +++++ app/views/admin/promotions/show.html.haml | 2 -- .../portlets/dynamic_contents/_folder_list.html.haml | 2 +- .../_folder_list_prestation.html.haml | 1 + app/views/public/articles/show.html.haml | 7 +++++-- app/views/public/folders/show.html.haml | 7 +++++-- .../20110822091539_add_folder_type_to_folders.rb | 5 +++++ db/migrate/20110822092003_set_folder_default.rb | 12 ++++++++++++ 11 files changed, 38 insertions(+), 8 deletions(-) delete mode 100644 app/views/admin/promotions/show.html.haml create mode 100644 app/views/portlets/dynamic_contents/_folder_list_prestation.html.haml create mode 100644 db/migrate/20110822091539_add_folder_type_to_folders.rb create mode 100644 db/migrate/20110822092003_set_folder_default.rb diff --git a/app/models/folder.rb b/app/models/folder.rb index c098f98..f1b0f41 100644 --- a/app/models/folder.rb +++ b/app/models/folder.rb @@ -14,8 +14,10 @@ class Folder < ActiveRecord::Base has_many :articles validates :title, :presence => true + validates :folder_type_id, :presence => true validates :slug, :presence => true, :uniqueness => true + FOLDER_TYPES = [["Dossier thématique",1], ["Prestation",2]] def cible_url diff --git a/app/models/portlets/dynamic_content.rb b/app/models/portlets/dynamic_content.rb index 95d5575..e641ec9 100644 --- a/app/models/portlets/dynamic_content.rb +++ b/app/models/portlets/dynamic_content.rb @@ -4,6 +4,6 @@ class DynamicContent < ActiveRecord::Base belongs_to :item - NAMES = {"formulaire_ordonnances" => "Formulaire dépôt ordonnances", "folder_list" => "Liste des dossiers", "promotions-list" => "Liste des promotions"} + NAMES = {"formulaire_ordonnances" => "Formulaire dépôt ordonnances", "folder_list" => "Liste des dossiers thématiques", "promotions-list" => "Liste des promotions", "folder_list_prestation" => "Liste des prestations"} end diff --git a/app/views/admin/folders/_form.html.haml b/app/views/admin/folders/_form.html.haml index 7be5914..b053d15 100644 --- a/app/views/admin/folders/_form.html.haml +++ b/app/views/admin/folders/_form.html.haml @@ -1,6 +1,7 @@ = semantic_form_for [:admin,@folder], :remote => true do |form| .content = form.inputs do + = form.input :folder_type_id, :collection => Folder::FOLDER_TYPES, :label => "Type :", :as => :select = form.input :enabled,:as => :boolean , :label => "Actif" = form.input :title, :label => "Titre :" = form.input :slug, :label => "Slug :" diff --git a/app/views/admin/folders/_show.html.haml b/app/views/admin/folders/_show.html.haml index 79469fb..a27a028 100644 --- a/app/views/admin/folders/_show.html.haml +++ b/app/views/admin/folders/_show.html.haml @@ -6,6 +6,11 @@ =image_tag @folder.image_file.file.large.medium.small.thumb.url if @folder.image_file %td{:style => "width:150px;"} Nom : %td=@folder.title + %tr + %td Type de dossier : + %td + =Folder::FOLDER_TYPES[@folder.folder_type_id.to_i-1][0] if @folder.folder_type_id + =@folder.folder_type_id %tr %td Permalink : %td=@folder.slug diff --git a/app/views/admin/promotions/show.html.haml b/app/views/admin/promotions/show.html.haml deleted file mode 100644 index c85d9f9..0000000 --- a/app/views/admin/promotions/show.html.haml +++ /dev/null @@ -1,2 +0,0 @@ -%h1 Admin::Promotions#show -%p Find me in app/views/admin/promotions/show.html.haml \ No newline at end of file diff --git a/app/views/portlets/dynamic_contents/_folder_list.html.haml b/app/views/portlets/dynamic_contents/_folder_list.html.haml index 669fb53..73a9533 100644 --- a/app/views/portlets/dynamic_contents/_folder_list.html.haml +++ b/app/views/portlets/dynamic_contents/_folder_list.html.haml @@ -1 +1 @@ -=render(:partial => "public/folders/folder",:collection => Folder.where(:enabled => true).order(:title)) \ No newline at end of file +=render(:partial => "public/folders/folder",:collection => Folder.where(:enabled => true, :folder_type_id => 1).order(:title)) \ No newline at end of file diff --git a/app/views/portlets/dynamic_contents/_folder_list_prestation.html.haml b/app/views/portlets/dynamic_contents/_folder_list_prestation.html.haml new file mode 100644 index 0000000..0ae4f82 --- /dev/null +++ b/app/views/portlets/dynamic_contents/_folder_list_prestation.html.haml @@ -0,0 +1 @@ +=render(:partial => "public/folders/folder",:collection => Folder.where(:enabled => true, :folder_type_id => 2).order(:title)) \ No newline at end of file diff --git a/app/views/public/articles/show.html.haml b/app/views/public/articles/show.html.haml index 5d3579c..73a63a6 100644 --- a/app/views/public/articles/show.html.haml +++ b/app/views/public/articles/show.html.haml @@ -6,7 +6,7 @@ #menu_left %h3= link_to "Dossiers", "/pages/dossiers.html" %ul - -Folder.where(:enabled => true).order(:title).each do |folder| + -Folder.where(:enabled => true, :folder_type_id => @folder.folder_type_id).order(:title).each do |folder| %li =link_to folder.title, folder_path(:slug => folder.slug) -if folder == @folder @@ -17,7 +17,10 @@ #breadcrumb =link_to "Accueil", "/" > - =link_to "Dossiers", "/pages/dossiers.html" + -if @folder.folder_type_id == 1 + =link_to "Dossiers", "/pages/dossiers.html" + -else + =link_to "Nos prestations", "/pages/nos-prestations.html" > =link_to @folder.title, folder_path(:slug => @folder.slug) > diff --git a/app/views/public/folders/show.html.haml b/app/views/public/folders/show.html.haml index 33bedbb..fd268b7 100644 --- a/app/views/public/folders/show.html.haml +++ b/app/views/public/folders/show.html.haml @@ -6,13 +6,16 @@ #menu_left %h3= link_to "Dossiers", "/pages/dossiers.html" %ul - -Folder.where(:enabled => true).order(:title).each do |folder| + -Folder.where(:enabled => true, :folder_type_id => @folder.folder_type_id).order(:title).each do |folder| %li=link_to folder.title, folder_path(:slug => folder.slug) #content #breadcrumb =link_to "Accueil", "/" > - =link_to "Dossiers", "/pages/dossiers.html" + -if @folder.folder_type_id == 1 + =link_to "Dossiers", "/pages/dossiers.html" + -else + =link_to "Nos prestations", "/pages/nos-prestations.html" > =@folder.title =render @folder.block diff --git a/db/migrate/20110822091539_add_folder_type_to_folders.rb b/db/migrate/20110822091539_add_folder_type_to_folders.rb new file mode 100644 index 0000000..a60ab97 --- /dev/null +++ b/db/migrate/20110822091539_add_folder_type_to_folders.rb @@ -0,0 +1,5 @@ +class AddFolderTypeToFolders < ActiveRecord::Migration + def change + add_column :folders, :folder_type_id, :integer + end +end diff --git a/db/migrate/20110822092003_set_folder_default.rb b/db/migrate/20110822092003_set_folder_default.rb new file mode 100644 index 0000000..4324d1c --- /dev/null +++ b/db/migrate/20110822092003_set_folder_default.rb @@ -0,0 +1,12 @@ +class SetFolderDefault < ActiveRecord::Migration + def up + Folder.all.each do |f| + f.folder_type_id = 1 + f.save + end + + end + + def down + end +end