ordre articles

This commit is contained in:
Nicolas Bally 2014-05-14 20:01:20 +02:00
parent b0b1c47fb2
commit 0117c1eb10
4 changed files with 12 additions and 5 deletions

View File

@ -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)

View File

@ -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)

View File

@ -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"

View File

@ -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"