From da4c4ecfaee7029774b1cd0b7e048c60b7eecf62 Mon Sep 17 00:00:00 2001 From: Nicolas Bally Date: Fri, 6 Nov 2015 16:56:19 +0100 Subject: [PATCH] =?UTF-8?q?echo=20du=20r=C3=A9seau?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/admin/articles_controller.rb | 2 +- app/controllers/public/articles_controller.rb | 12 ++++- app/views/admin/articles/_form.html.haml | 2 + app/views/admin/articles/reseau.html.haml | 54 +++++++++++++++++++ app/views/public/articles/index.html.haml | 2 + app/views/public/articles/reseau.html.haml | 7 +++ config/routes.rb | 1 + .../20151106153327_add_reseau_to_articles.rb | 5 ++ db/schema.rb | 3 +- 9 files changed, 85 insertions(+), 3 deletions(-) create mode 100644 app/views/admin/articles/reseau.html.haml create mode 100644 app/views/public/articles/reseau.html.haml create mode 100644 db/migrate/20151106153327_add_reseau_to_articles.rb diff --git a/app/controllers/admin/articles_controller.rb b/app/controllers/admin/articles_controller.rb index 095e5a1..8d82622 100644 --- a/app/controllers/admin/articles_controller.rb +++ b/app/controllers/admin/articles_controller.rb @@ -113,7 +113,7 @@ class Admin::ArticlesController < ApplicationController private def article_params - params.require(:article).permit(:author_id, :category_id, :enabled, :published_at, :title, :slug, :tags_cache, :description, :image_file_id, :title_cached) + params.require(:article).permit(:author_id, :category_id, :echo, :enabled, :published_at, :title, :slug, :tags_cache, :description, :image_file_id, :title_cached) diff --git a/app/controllers/public/articles_controller.rb b/app/controllers/public/articles_controller.rb index a230c60..4a28282 100644 --- a/app/controllers/public/articles_controller.rb +++ b/app/controllers/public/articles_controller.rb @@ -10,13 +10,23 @@ class Public::ArticlesController < ApplicationController def index - @articles = Article.before(Date.today).recents + @articles = Article.where(:echo => false).before(Date.today).recents @articles = @articles.page(params[:page]).per(12) @index_title = "Actualités du Pic Vert" end + + def reseau + + @articles = Article.where(:echo => true).before(Date.today).recents + + @articles = @articles.page(params[:page]).per(12) + + + @index_title = "Echo du réseau" + end def feed # this will be the name of the feed displayed on the feed reader diff --git a/app/views/admin/articles/_form.html.haml b/app/views/admin/articles/_form.html.haml index 489f3d1..ae2ca87 100644 --- a/app/views/admin/articles/_form.html.haml +++ b/app/views/admin/articles/_form.html.haml @@ -1,11 +1,13 @@ = semantic_form_for [:admin,@article], :remote => true do |form| .content = form.inputs do + = form.input :echo, :label => "Echo du réseau ?" =form.input :image_file_id, :as => :qi_image_select =form.input :author_id, :as => :select, :collection => Author.order(:name), :include_blank => false =form.input :category_id, :as => :select, :collection => Category.order(:name) = form.input :enabled,:as => :boolean , :label => "Actif" = form.input :published_at, :label => "Date de publication : ",:as => :qi_date_picker + = form.input :title, :label => "Titre :" = form.input :title_cached,:as => :boolean , :label => "Titre masqué ?" diff --git a/app/views/admin/articles/reseau.html.haml b/app/views/admin/articles/reseau.html.haml new file mode 100644 index 0000000..f3e99b1 --- /dev/null +++ b/app/views/admin/articles/reseau.html.haml @@ -0,0 +1,54 @@ +.row{:style => "max-width:inherit;"} + .col-xs-9 + .right= link_to 'Ajouter un article', new_admin_article_path(), :class => "btn btn-primary", :remote => true + %h1 Liste des articles + + #articles_index=render :partial => "index_block" + + .col-xs-3 + %h3 Tags + =render :partial => "tags" + + + :coffeescript + root = exports ? this + root.tag_id = [] + + + $(document.body).on "click", "#tags .tag_label", -> + + if $(this).hasClass("active") + $(this).removeClass "active" + + else + $(this).addClass "active" + + root.tag_id = [] + + $("#tags .tag_label.active").each -> + root.tag_id.push $(this).data "tag_id" + + if root.tag_id.length > 0 + $(".set_tag").show() + else + $(".set_tag").hide() + + + $(document.body).on "click", ".set_tag", -> + + $.ajax({ + url:$(this).attr("href"), + type: "PUT", + data: { + tag_id : tag_id + } + + }) + + return false + + + + + + diff --git a/app/views/public/articles/index.html.haml b/app/views/public/articles/index.html.haml index 4f085b3..a4e5781 100644 --- a/app/views/public/articles/index.html.haml +++ b/app/views/public/articles/index.html.haml @@ -1,4 +1,6 @@ %h1=@index_title +%p=link_to "Actualités du réseau", reseau_path + =render :partial => "index" -content_for :sidebar do diff --git a/app/views/public/articles/reseau.html.haml b/app/views/public/articles/reseau.html.haml new file mode 100644 index 0000000..7c4d7b7 --- /dev/null +++ b/app/views/public/articles/reseau.html.haml @@ -0,0 +1,7 @@ +%h1=@index_title +%p=link_to "Actualités du Pic Vert", articles_path + +=render :partial => "index" + +-content_for :sidebar do + =render :partial => "sidebar_archives" \ No newline at end of file diff --git a/config/routes.rb b/config/routes.rb index fd053b9..1c04fff 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -6,6 +6,7 @@ Survey::Application.routes.draw do get "agenda.html" => "public/events#index", :as => "public_events" get 'actualites/:id.html' => "public/articles#show", :as => "public_article" get 'actualites.html' => "public/articles#index", :as => "articles" + get 'actualite-du-reseau.html' => "public/articles#reseau", :as => "reseau" get 'faqs/:id.html' => "public/faqs#show", :as => "public_faq" get 'faqs.html' => "public/faqs#index", :as => "faqs" diff --git a/db/migrate/20151106153327_add_reseau_to_articles.rb b/db/migrate/20151106153327_add_reseau_to_articles.rb new file mode 100644 index 0000000..71eed2f --- /dev/null +++ b/db/migrate/20151106153327_add_reseau_to_articles.rb @@ -0,0 +1,5 @@ +class AddReseauToArticles < ActiveRecord::Migration + def change + add_column :articles, :echo, :boolean, :default => 0 + end +end diff --git a/db/schema.rb b/db/schema.rb index 8681da9..dbfaa18 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 20151021135332) do +ActiveRecord::Schema.define(version: 20151106153327) do create_table "admins", force: true do |t| t.string "email", default: "", null: false @@ -82,6 +82,7 @@ ActiveRecord::Schema.define(version: 20151021135332) do t.datetime "created_at" t.datetime "updated_at" t.integer "author_id" + t.boolean "echo", default: false end add_index "articles", ["author_id"], name: "index_articles_on_author_id", using: :btree