Skip to content

Commit

Permalink
Convert a diary to a new in the moderation pipe
Browse files Browse the repository at this point in the history
  • Loading branch information
nono committed Mar 21, 2011
1 parent 018c8ff commit 6a8984b
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 0 deletions.
16 changes: 16 additions & 0 deletions app/controllers/diaries_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,22 @@ def destroy
redirect_to diaries_url, :notice => "Le journal a bien été supprimé"
end

def convert
enforce_update_permission(@diary)
@news = News.new(:title => @diary.title, :wiki_body => @diary.wiki_body, :section_id => Section.where(:title => "LinuxFR").first.id)
@news.author_name = @diary.owner.try(:name)
@news.author_email = @diary.owner.try(:account).try(:email)
if @news.save
@news.node.update_attribute(:cc_licenced => true) if @diary.node.cc_licensed?
@news.links.create :title => "Journal à l'origine de la dépêche", :url => "#{MY_DOMAIN}/users/#{@diary.owner.to_param}/journaux/#{@diary.to_param}", :lang => "fr"
@news.submit!
redirect_to [:moderation, @news]
else
flash.now[:alert] = "Impossible de proposer ce journal en dépêche"
render :edit
end
end

def move
enforce_destroy_permission(@diary)
@post = Post.new(params[:post])
Expand Down
1 change: 1 addition & 0 deletions app/views/diaries/edit.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
= form.select :forum_id, forums_select_list, { :include_blank => true }, { :required => "required" }
%p
= form.submit "Déplacer vers les forums", :confirm => "Êtes-vous sûr de vouloir déplacer ce journal ?"
= button_to "Proposer en dépêche", convert_user_diary_path(:user_id => @diary.owner, :id => @diary)
= button_to "Supprimer", [@diary.owner, @diary], :method => :delete, :confirm => "Êtes-vous sûr de vouloir supprimer ce journal ?"

= render 'shared/wiki_help'
1 change: 1 addition & 0 deletions config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
# Diaries & Users
resources :users, :only => [:show] do
resources :journaux, :controller => "diaries", :as => "diaries", :except => [:index, :new, :create] do
post :convert, :on => :member
post :move, :on => :member
end
get :news, :on => :member
Expand Down

0 comments on commit 6a8984b

Please sign in to comment.