Class: DmForum::Admin::ForumsController
- Inherits:
-
AdminController
- Object
- AdminController
- DmForum::Admin::ForumsController
- Includes:
- PermittedParams
- Defined in:
- app/controllers/dm_forum/admin/forums_controller.rb
Instance Method Summary collapse
-
#create ⇒ Object
POST /admin/fms/forums ——————————————————————————.
-
#destroy ⇒ Object
DELETE /admin/fms/forums/1 ——————————————————————————.
-
#edit ⇒ Object
GET /admin/fms/forums/1/edit ——————————————————————————.
-
#forum_add_member ⇒ Object
Add user(s) to forum.
-
#forum_delete_member ⇒ Object
——————————————————————————.
-
#forum_users ⇒ Object
——————————————————————————.
-
#index ⇒ Object
GET /admin/fms/forums ——————————————————————————.
-
#new ⇒ Object
GET /admin/fms/forums/new ——————————————————————————.
-
#show ⇒ Object
——————————————————————————.
-
#sort ⇒ Object
——————————————————————————.
-
#update ⇒ Object
PUT /admin/fms/forums/1 ——————————————————————————.
Methods included from PermittedParams
#forum_category_params, #forum_comment_params, #forum_params, #forum_site_params, #forum_topic_params
Instance Method Details
#create ⇒ Object
POST /admin/fms/forums
36 37 38 39 40 41 42 43 44 45 |
# File 'app/controllers/dm_forum/admin/forums_controller.rb', line 36 def create @forum = @forum_category.forums.new(forum_params) @forum.forum_site = ForumSite.site if @forum.save redirect_to admin_forum_category_url(@forum_category), notice: 'Forum was successfully created.' else render action: :new end end |
#destroy ⇒ Object
DELETE /admin/fms/forums/1
59 60 61 62 63 |
# File 'app/controllers/dm_forum/admin/forums_controller.rb', line 59 def destroy @forum.destroy redirect_to admin_forum_category_url(@forum.forum_category) end |
#edit ⇒ Object
GET /admin/fms/forums/1/edit
31 32 |
# File 'app/controllers/dm_forum/admin/forums_controller.rb', line 31 def edit end |
#forum_add_member ⇒ Object
Add user(s) to forum.
> user_id: add a single user
83 84 85 86 87 88 89 90 91 |
# File 'app/controllers/dm_forum/admin/forums_controller.rb', line 83 def forum_add_member if !params[:user_id].blank? user = User.find(params[:user_id]) @forum.add_member(user) redirect_to admin_forum_url(@forum), notice: "Forum access granted for #{user.full_name}" else redirect_to admin_forum_url(@forum), alert: "Incorrect parameters supplied" end end |
#forum_delete_member ⇒ Object
94 95 96 97 98 |
# File 'app/controllers/dm_forum/admin/forums_controller.rb', line 94 def forum_delete_member user = User.find(params[:user_id]) @forum.remove_member(user) redirect_to admin_forum_url(@forum), notice: "Forum access removed for #{user.full_name}" end |
#forum_users ⇒ Object
74 75 76 77 78 |
# File 'app/controllers/dm_forum/admin/forums_controller.rb', line 74 def forum_users respond_to do |format| format.json { render json: ForumUserDatatable.new(view_context, @forum) } end end |
#index ⇒ Object
GET /admin/fms/forums
10 11 12 13 14 15 16 |
# File 'app/controllers/dm_forum/admin/forums_controller.rb', line 10 def index if ForumSite.first @forums = @forum_category.forums.ordered else redirect_to admin_forum_site_path, notice: "Please configure the Forum system first" end end |
#new ⇒ Object
GET /admin/fms/forums/new
25 26 27 |
# File 'app/controllers/dm_forum/admin/forums_controller.rb', line 25 def new @forum = @forum_category.forums.build end |
#show ⇒ Object
19 20 21 |
# File 'app/controllers/dm_forum/admin/forums_controller.rb', line 19 def show end |
#sort ⇒ Object
66 67 68 69 70 71 |
# File 'app/controllers/dm_forum/admin/forums_controller.rb', line 66 def sort @forum.update_attribute(:row_order_position, params[:item][:row_order_position]) #--- this action will be called via ajax render nothing: true end |
#update ⇒ Object
PUT /admin/fms/forums/1
49 50 51 52 53 54 55 |
# File 'app/controllers/dm_forum/admin/forums_controller.rb', line 49 def update if @forum.update_attributes(forum_params) redirect_to admin_forum_url(@forum), notice: 'Forum was successfully updated.' else render action: :edit end end |