Skip to content

Commit

Permalink
Set poll on PPP
Browse files Browse the repository at this point in the history
  • Loading branch information
nono committed Jul 23, 2012
1 parent 0f3cf64 commit 12290d4
Show file tree
Hide file tree
Showing 10 changed files with 32 additions and 22 deletions.
2 changes: 1 addition & 1 deletion app/assets/stylesheets/RonRonnement.css.scss
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
2 changes: 1 addition & 1 deletion app/controllers/home_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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])
Expand Down
6 changes: 6 additions & 0 deletions app/controllers/moderation/polls_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion app/models/content.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
15 changes: 0 additions & 15 deletions app/models/news.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
15 changes: 15 additions & 0 deletions app/models/node.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 5 additions & 2 deletions app/views/moderation/polls/edit.html.haml
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion app/views/news/_news.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion app/views/news/_preview.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -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)
1 change: 1 addition & 0 deletions config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@
member do
post :refuse
post :accept
post :ppp
end
end
resources :plonk, :only => [:create]
Expand Down

0 comments on commit 12290d4

Please sign in to comment.