Skip to content
Snippets Groups Projects
Commit d2519328 authored by Mauricio Giacomini Girardello's avatar Mauricio Giacomini Girardello
Browse files

refactoring learning objects controller

parent 2e542a8b
No related branches found
No related tags found
No related merge requests found
class LearningObjectsController < ApplicationController class LearningObjectsController < ApplicationController
include Reportable
before_action :set_learning_object, only: [:show, :edit, :update, :destroy, :like, :bookmark] before_action :set_learning_object, only: [:show, :edit, :update, :destroy, :like, :bookmark]
after_action :increment_learning_object_views, only: [:show] after_action :increment_learning_object_views, only: [:show]
before_action :authenticate_user!, except: [:index, :show, :like] before_action :authenticate_user!, except: [:index, :show, :like]
before_action :set_complaint_messages, only: :show
# GET /learning_objects # GET /learning_objects
# GET /learning_objects.json # GET /learning_objects.json
...@@ -14,13 +13,6 @@ class LearningObjectsController < ApplicationController ...@@ -14,13 +13,6 @@ class LearningObjectsController < ApplicationController
# GET /learning_objects/1 # GET /learning_objects/1
# GET /learning_objects/1.json # GET /learning_objects/1.json
def show def show
@complaint = Complaint.new
@messages = [
Complaint.copyrights,
Complaint.ofensive_content,
Complaint.ofensive_user,
Complaint.fake_user
]
end end
# GET /learning_objects/new # GET /learning_objects/new
...@@ -68,6 +60,10 @@ class LearningObjectsController < ApplicationController ...@@ -68,6 +60,10 @@ class LearningObjectsController < ApplicationController
end end
end end
def report_object
learning_object_repository.report current_user, @learning_object, message, description
end
# POST /learning_objects/1/like # POST /learning_objects/1/like
def like def like
if @learning_object.liked? current_user if @learning_object.liked? current_user
...@@ -81,11 +77,7 @@ class LearningObjectsController < ApplicationController ...@@ -81,11 +77,7 @@ class LearningObjectsController < ApplicationController
end end
end end
# POST /learning_objects/1/bookmarks
def report_object
learning_object_repository.report current_user, @learning_object, message, description
end
def bookmarks def bookmarks
bookmarks = current_user.bookmarks bookmarks = current_user.bookmarks
bookmarks.add @learning_object bookmarks.add @learning_object
...@@ -114,4 +106,14 @@ class LearningObjectsController < ApplicationController ...@@ -114,4 +106,14 @@ class LearningObjectsController < ApplicationController
end end
end end
def set_complaint_messages
@complaint = Complaint.new
@messages = [
Complaint.copyrights,
Complaint.ofensive_content,
Complaint.ofensive_user,
Complaint.fake_user
]
end
end end
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment