Class: CamaleonCms::Admin::CommentsController
- Inherits:
-
CamaleonCms::AdminController
- Object
- CamaleonCms::AdminController
- CamaleonCms::Admin::CommentsController
show all
- Includes:
- CommentHelper
- Defined in:
- app/controllers/camaleon_cms/admin/comments_controller.rb
Instance Method Summary
collapse
#cama_comments_get_common_data, #cama_comments_render_html
Instance Method Details
#answer ⇒ Object
render a form to register a new comment
22
23
24
25
|
# File 'app/controllers/camaleon_cms/admin/comments_controller.rb', line 22
def answer
@answer = @comment.children.new
render 'form_answer', layout: false
end
|
#create ⇒ Object
57
58
59
60
61
|
# File 'app/controllers/camaleon_cms/admin/comments_controller.rb', line 57
def create
= @post..create(.merge({post_id: @post.id, content: params[:comment][:content]}))
flash[:notice] = t('camaleon_cms.admin.comments.message.responses')
redirect_to action: :index
end
|
#destroy ⇒ Object
63
64
65
66
|
# File 'app/controllers/camaleon_cms/admin/comments_controller.rb', line 63
def destroy
flash[:notice] = t('camaleon_cms.admin.comments.message.destroy') if @comment.destroy
redirect_to action: :index
end
|
#edit ⇒ Object
17
18
19
|
# File 'app/controllers/camaleon_cms/admin/comments_controller.rb', line 17
def edit
render 'form', layout: false
end
|
#index ⇒ Object
list of post comments for current post
13
14
15
|
# File 'app/controllers/camaleon_cms/admin/comments_controller.rb', line 13
def index
@comments = @post..main.paginate(:page => params[:page], :per_page => current_site.admin_per_page)
end
|
#list ⇒ Object
8
9
10
|
# File 'app/controllers/camaleon_cms/admin/comments_controller.rb', line 8
def list
@posts = current_site.posts.no_trash.joins(:comments).select("#{CamaleonCms::Post.table_name}.*, #{CamaleonCms::PostComment.table_name}.post_id").uniq.paginate(:page => params[:page], :per_page => current_site.admin_per_page)
end
|
#new ⇒ Object
52
53
54
55
|
# File 'app/controllers/camaleon_cms/admin/comments_controller.rb', line 52
def new
@comment = @post..new
render 'form', layout: false
end
|
#save_answer ⇒ Object
save a new anwer for this comment
28
29
30
31
32
|
# File 'app/controllers/camaleon_cms/admin/comments_controller.rb', line 28
def save_answer
answer = @comment.children.create(.merge({post_id: @post.id, content: params[:comment][:content]}))
flash[:notice] = t('camaleon_cms.admin.comments.message.responses')
redirect_to action: :index
end
|
#toggle_status ⇒ Object
toggle status of a comment
35
36
37
38
39
40
41
|
# File 'app/controllers/camaleon_cms/admin/comments_controller.rb', line 35
def toggle_status
_s = {a: "approved", s: "spam", p: "pending"}
k = _s[params[:s].to_sym]
@comment.update(approved: k)
flash[:notice] = "#{t('camaleon_cms.admin.comments.message.change_status')} #{t("camaleon_cms.admin.comments.message.#{k}")}"
redirect_to action: :index
end
|
#update ⇒ Object
43
44
45
46
47
48
49
50
|
# File 'app/controllers/camaleon_cms/admin/comments_controller.rb', line 43
def update
if @comment.update(content: params[:comment][:content])
flash[:notice] = t('camaleon_cms.admin.comments.message.updated')
redirect_to action: :index
else
render 'form'
end
end
|