From 0117c1eb1060394780fcd20f1ec3eb0a883bccdf Mon Sep 17 00:00:00 2001 From: Nicolas Bally Date: Wed, 14 May 2014 20:01:20 +0200 Subject: [PATCH] ordre articles --- app/controllers/admin/articles_controller.rb | 2 +- app/models/article.rb | 9 ++++++++- app/views/admin/articles/_article.html.haml | 2 +- app/views/admin/events/_event.html.haml | 4 ++-- 4 files changed, 12 insertions(+), 5 deletions(-) diff --git a/app/controllers/admin/articles_controller.rb b/app/controllers/admin/articles_controller.rb index 00c85eb..d7bab63 100644 --- a/app/controllers/admin/articles_controller.rb +++ b/app/controllers/admin/articles_controller.rb @@ -112,7 +112,7 @@ class Admin::ArticlesController < ApplicationController private def article_params - params.require(:article).permit(:frontpage, :enabled, :published_at, :title, :slug, :tags_cache, :description, :image_file_id) + params.require(:article).permit(:frontpage, :enabled, :published_at, :end_at, :title, :slug, :tags_cache, :description, :image_file_id, :priority_level) diff --git a/app/models/article.rb b/app/models/article.rb index 627aff9..51506b4 100644 --- a/app/models/article.rb +++ b/app/models/article.rb @@ -12,6 +12,13 @@ class Article < ActiveRecord::Base HUMAN_NAME = "lien vers un article." before_validation do + if self.published_at? + self.published_at = self.published_at.beginning_of_day + end + if self.end_at? + self.end_at = self.end_at.beginning_of_day + end + self.slug = [self.published_at.year,self.published_at.month,self.published_at.day].join("-")+"-"+self.title.to_slug #self.tags_cache = self.tags_cache.gsub(/ +/, ' ').gsub(/, /,',').gsub(/ ,/,',').gsub(/,+/, ',') #self.tags_cache = self.tags_cache.to_s.gsub(/ +/, ' ').gsub(/, /,',').gsub(/ ,/,',').gsub(/,+/, ',') @@ -34,7 +41,7 @@ class Article < ActiveRecord::Base end scope :frontpage, where("frontpage = ?",true ) - scope :recents, where("enabled = ?",true ).order("published_at DESC, priority_level ASC") + scope :recents, where("enabled = ?",true ).order("published_at DESC, priority_level DESC") scope :between, lambda { |start, stop| after(start).before(stop) diff --git a/app/views/admin/articles/_article.html.haml b/app/views/admin/articles/_article.html.haml index 71dfd25..71f8b02 100644 --- a/app/views/admin/articles/_article.html.haml +++ b/app/views/admin/articles/_article.html.haml @@ -13,7 +13,7 @@ = link_to i(:trash), [:admin, article], :confirm => 'Voulez-vous vraiment supprimer cet article ?', :method => :delete, :remote => true = link_to i(:pencil), edit_admin_article_path(article), :style => "padding:0px 0px 0px 0px;", :remote => true - = link_to i(:info), edit_admin_article_path(article), :style => "padding:0px 0px 0px 0px;" + = link_to i(:plus), edit_admin_article_path(article), :style => "padding:0px 0px 0px 0px;" =#link_to i(:"level-down"), admin_article_path(:id => article.id, :format => "js"), :class => "set_tag" diff --git a/app/views/admin/events/_event.html.haml b/app/views/admin/events/_event.html.haml index be31e09..f95ae85 100644 --- a/app/views/admin/events/_event.html.haml +++ b/app/views/admin/events/_event.html.haml @@ -7,7 +7,7 @@ %td.actions{:style => "width:200px;text-align:right;"} = link_to i(:copy), new_admin_event_path(:event_id => event), :remote => true, :style => "padding-right:5px;" = link_to i(:trash), [:admin, event], :confirm => 'Voulez-vous vraiment supprimer cet événement ?', :method => :delete, :remote => true - - = link_to i(:plus), edit_admin_event_path(event), :style => "padding:5px;", :class => "show_details" = link_to i(:pencil), edit_admin_event_path(event), :remote => true + = link_to i(:plus), edit_admin_event_path(event), :style => "padding:5px;", :class => "show_details" +