diff --git a/app/assets/stylesheets/RonRonnement.css.scss b/app/assets/stylesheets/RonRonnement.css.scss index 805adbbc4..af2f58f40 100644 --- a/app/assets/stylesheets/RonRonnement.css.scss +++ b/app/assets/stylesheets/RonRonnement.css.scss @@ -521,7 +521,7 @@ button, input[type='submit'] { /* article titre */ #phare article { /* enleve la liste des liens de la boite d'en-tete pour ne garder que le contenu "texte" de l'article, pour gain de place. */ - .content ul { + .content ul.links { display: none; } diff --git a/app/controllers/home_controller.rb b/app/controllers/home_controller.rb index 2f1994b5b..11cc2dea1 100644 --- a/app/controllers/home_controller.rb +++ b/app/controllers/home_controller.rb @@ -13,7 +13,7 @@ def index default = current_account.try(:sort_by_date_on_home) ? "created_at" : "interest" @order = params[:order] @order = default unless VALID_ORDERS.include?(@order) - @ppp = News.ppp + @ppp = Node.ppp @banner = Banner.random @poll = Poll.current @nodes = Node.public_listing(@types, @order).page(params[:page]) diff --git a/app/controllers/moderation/polls_controller.rb b/app/controllers/moderation/polls_controller.rb index d240c0a84..2c38f6179 100644 --- a/app/controllers/moderation/polls_controller.rb +++ b/app/controllers/moderation/polls_controller.rb @@ -38,6 +38,12 @@ def update end end + def ppp + enforce_accept_permission(@poll) + @poll.set_on_ppp + redirect_to root_url, :notice => "Le sondage a bien été mis en phare" + end + protected def find_poll diff --git a/app/models/content.rb b/app/models/content.rb index 801b5181b..7686749f0 100644 --- a/app/models/content.rb +++ b/app/models/content.rb @@ -13,7 +13,7 @@ class Content < ActiveRecord::Base # /!\ No scope here /!\ - delegate :score, :user, :to => :node + delegate :score, :user, :set_on_ppp, :on_ppp?, :to => :node class << self; attr_accessor :type; end diff --git a/app/models/news.rb b/app/models/news.rb index 021217bb7..1eb63fc48 100644 --- a/app/models/news.rb +++ b/app/models/news.rb @@ -348,19 +348,4 @@ def locker User.find(locker_id).name if locker_id end -### PPP ### - - def self.ppp - id = $redis.get("news/ppp") - id && find(id) - end - - def set_on_ppp - $redis.set("news/ppp", self.id) - end - - def on_ppp? - self.id == $redis.get("news/ppp").to_i - end - end diff --git a/app/models/node.rb b/app/models/node.rb index 6fbf77ccb..9b1ac541b 100644 --- a/app/models/node.rb +++ b/app/models/node.rb @@ -41,6 +41,21 @@ class Node < ActiveRecord::Base paginates_per 15 +### PPP ### + + def self.ppp + id = $redis.get("nodes/ppp") + find(id).try(:content) if id + end + + def set_on_ppp + $redis.set("nodes/ppp", self.id) + end + + def on_ppp? + self.id == $redis.get("nodes/ppp").to_i + end + ### Interest ### after_create :compute_interest diff --git a/app/views/moderation/polls/edit.html.haml b/app/views/moderation/polls/edit.html.haml index e81544634..d2e061cc3 100644 --- a/app/views/moderation/polls/edit.html.haml +++ b/app/views/moderation/polls/edit.html.haml @@ -1,7 +1,10 @@ =h1 "Éditer un sondage" -= button_to "Publier", accept_moderation_poll_path(@poll), :data => { :confirm => "Publier le sondage ?" }, :class => "ok_button" -= button_to "Refuser", refuse_moderation_poll_path(@poll), :data => { :confirm => "Refuser le sondage ?" }, :class => "delete_button" +- if @poll.draft? + = button_to "Publier", accept_moderation_poll_path(@poll), :data => { :confirm => "Publier le sondage ?" }, :class => "ok_button" + = button_to "Refuser", refuse_moderation_poll_path(@poll), :data => { :confirm => "Refuser le sondage ?" }, :class => "delete_button" +- else + = button_to "Mettre en phare", ppp_moderation_poll_path(@poll), :class => "ppp_poll" = form_for [:moderation, setup_poll(@poll)] do |form| = render form diff --git a/app/views/news/_news.html.haml b/app/views/news/_news.html.haml index 312c97270..6ad9fca78 100644 --- a/app/views/news/_news.html.haml +++ b/app/views/news/_news.html.haml @@ -6,7 +6,7 @@ - c.actions = link_to("Modifier", [:moderation, news], :class => 'action') - c.body = capture do = news.body - %ul + %ul.links = render news.links.select([:id, :lang, :title, :url]) - if defined?(with_second_part) && with_second_part = news.second_part diff --git a/app/views/news/_preview.html.haml b/app/views/news/_preview.html.haml index 9e78bcb12..e87ba5bbe 100644 --- a/app/views/news/_preview.html.haml +++ b/app/views/news/_preview.html.haml @@ -4,6 +4,6 @@ - c.image = link_to(image_tag(preview.section.image, :alt => preview.section.title), preview.section) - c.body = capture do = spellcheck(preview.body) - %ul + %ul.links = render preview.links = spellcheck(preview.second_part) diff --git a/config/routes.rb b/config/routes.rb index bf292cb8b..581ce9e9e 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -145,6 +145,7 @@ member do post :refuse post :accept + post :ppp end end resources :plonk, :only => [:create]