Permalink
Browse files

Add an option and a permission to delete doodles. #804

  • Loading branch information...
1 parent af1fc9d commit 0f07fc6ced7fabcfb44f31d73c5c3e3cc98da0c4 @thegcat committed Nov 7, 2010
@@ -1,5 +1,7 @@
class DoodleAnswersController < ApplicationController
unloadable
+
+ menu_item :doodles
before_filter :find_doodle, :only => [:create]
before_filter :find_doodle_answer, :only => [:update]
@@ -37,6 +37,8 @@ def show
end
def destroy
+ @doodle.destroy
+ redirect_to :action => 'index', :project_id => @project
end
def create
@@ -7,7 +7,7 @@ class Doodle < ActiveRecord::Base
belongs_to :author, :class_name => 'User', :foreign_key => 'author_id'
has_and_belongs_to_many :should_answer, :class_name => 'User', :join_table => "#{table_name_prefix}users_should_answer_doodles#{table_name_suffix}"
has_many :comments, :as => :commented, :dependent => :delete_all, :order => "created_on"
- has_many :responses, :class_name => 'DoodleAnswers', :dependent => :destroy, :order => "updated_on", :include => [:author]
+ has_many :responses, :class_name => 'DoodleAnswers', :dependent => :delete_all, :order => "updated_on", :include => [:author]
acts_as_watchable
acts_as_event :title => Proc.new {|o| "#{l(:label_doodle)} ##{o.id}: #{o.title}"},
@@ -5,7 +5,7 @@ class DoodleAnswers < ActiveRecord::Base
belongs_to :doodle
belongs_to :author, :class_name => 'User', :foreign_key => 'author_id'
- has_many :edits, :class_name => 'DoodleAnswersEdits'
+ has_many :edits, :class_name => 'DoodleAnswersEdits', :dependent => :delete_all
validates_presence_of :answers
@@ -1 +0,0 @@
-<h2>Doodles#destroy</h2>
@@ -7,6 +7,7 @@
:class => 'icon icon-edit',
:accesskey => accesskey(:edit),
:onclick => 'Element.show("edit-doodle"); return false;' %>
+<%= link_to_if_authorized(l(:button_delete), {:action => 'destroy'}, :method => :delete, :confirm => l(:text_are_you_sure), :class => 'icon icon-del') %>
</div>
<h2>Doodle #<%= @doodle.id %></h2>
@@ -18,6 +18,7 @@ en:
field_options: "Options"
field_missing_answers: "Pending answers"
permission_manage_doodles: "Manage doodles"
+ permission_create_doodles: "Delete doodles"
permission_create_doodles: "Create doodles"
permission_view_doodles: "View doodles"
permission_answer_doodles: "Answer doodles"
View
@@ -20,12 +20,13 @@
project_module :doodles do
permission :manage_doodles, {:doodles => [:lock, :edit, :update]}, :require => :member
+ permission :delete_doodles, {:doodles => [:destroy]}, :require => :member
permission :create_doodles, {:doodles => [:new, :create, :preview]}, :require => :member
permission :answer_doodles, {:doodle_answers => [:create, :update]}, :require => :loggedin
permission :view_doodles, {:doodles => [:index, :show]}
end
- menu :project_menu, :doodles, { :controller => 'doodles', :action => 'index' }, :caption => :label_doodle_plural, :param => :project_id
+ menu :project_menu, :doodles, {:controller => 'doodles', :action => 'index'}, :caption => :label_doodle_plural, :param => :project_id
activity_provider :doodles, :default => false, :class_name => ['Doodle', 'DoodleAnswersEdits']
end

0 comments on commit 0f07fc6

Please sign in to comment.