From cd4020e48b1eeb35186d77952ddae77d42811032 Mon Sep 17 00:00:00 2001
From: Mauricio Giacomini Girardello <mgg12@inf.ufpr.br>
Date: Tue, 17 May 2016 11:40:50 -0300
Subject: [PATCH] deleting old controllers

---
 app/controllers/old/about_controller.rb       |   4 -
 app/controllers/old/bookmarks_controller.rb   |  46 ----
 app/controllers/old/callbacks_controller.rb   |  33 ---
 app/controllers/old/chunks_controller.rb      | 124 ----------
 app/controllers/old/collections_controller.rb | 229 ------------------
 app/controllers/old/complaints_controller.rb  |  32 ---
 app/controllers/old/feedbacks_controller.rb   |  54 -----
 .../old/institutions_controller.rb            |  83 -------
 .../old/learning_objects/build_controller.rb  |  42 ----
 .../old/learning_objects_controller.rb        | 174 -------------
 app/controllers/old/links_controller.rb       |   2 -
 app/controllers/old/reviews_controller.rb     |  98 --------
 app/controllers/old/search_controller.rb      | 142 -----------
 app/controllers/old/users_controller.rb       |  80 ------
 app/controllers/old/welcome_controller.rb     |  18 --
 15 files changed, 1161 deletions(-)
 delete mode 100644 app/controllers/old/about_controller.rb
 delete mode 100644 app/controllers/old/bookmarks_controller.rb
 delete mode 100644 app/controllers/old/callbacks_controller.rb
 delete mode 100644 app/controllers/old/chunks_controller.rb
 delete mode 100644 app/controllers/old/collections_controller.rb
 delete mode 100644 app/controllers/old/complaints_controller.rb
 delete mode 100644 app/controllers/old/feedbacks_controller.rb
 delete mode 100644 app/controllers/old/institutions_controller.rb
 delete mode 100644 app/controllers/old/learning_objects/build_controller.rb
 delete mode 100644 app/controllers/old/learning_objects_controller.rb
 delete mode 100644 app/controllers/old/links_controller.rb
 delete mode 100644 app/controllers/old/reviews_controller.rb
 delete mode 100644 app/controllers/old/search_controller.rb
 delete mode 100644 app/controllers/old/users_controller.rb
 delete mode 100644 app/controllers/old/welcome_controller.rb

diff --git a/app/controllers/old/about_controller.rb b/app/controllers/old/about_controller.rb
deleted file mode 100644
index a14c5285..00000000
--- a/app/controllers/old/about_controller.rb
+++ /dev/null
@@ -1,4 +0,0 @@
-class AboutController < ApplicationController
-  def index
-  end
-end
diff --git a/app/controllers/old/bookmarks_controller.rb b/app/controllers/old/bookmarks_controller.rb
deleted file mode 100644
index 0dccaf56..00000000
--- a/app/controllers/old/bookmarks_controller.rb
+++ /dev/null
@@ -1,46 +0,0 @@
-class BookmarksController < ApplicationController
-  include Pundit
-
-  before_action :authenticate_user!
-  before_action :set_user
-  before_action :find_object, only: [:add_object, :remove_object]
-
-
-  # GET /bookmarks/1
-  # GET /bookmarks/1.json
-  def show
-    render partial: 'list' if params[:list] == 'true'
-  end
-
-  # POST /bookmarks/1/learning_object
-  def add_object
-    authorize @object
-    Bookmark.create(user: @user, bookmarkable: @object)
-
-    render json: { status: true } if request.xhr?
-  end
-
-  def list
-    render layout: false
-  end
-
-  # DELETE /bookmarks/1/learning_object
-  def remove_object
-    authorize @object
-    Bookmark.destroy Bookmark.where(user: @user, bookmarkable: @object)
-
-    render json: { status: true } if request.xhr?
-  end
-
-  private
-
-  def set_user
-    @user = current_user
-  end
-
-  def find_object
-    klass = params[:type].constantize
-    @object = klass.find params[:id]
-  end
-
-end
diff --git a/app/controllers/old/callbacks_controller.rb b/app/controllers/old/callbacks_controller.rb
deleted file mode 100644
index 56360cbd..00000000
--- a/app/controllers/old/callbacks_controller.rb
+++ /dev/null
@@ -1,33 +0,0 @@
-class CallbacksController < Devise::OmniauthCallbacksController
-
-  def facebook
-    request_data("Facebook","devise.facebook_data")
-  end
-
-  def twitter
-    request_data("Twitter","devise.twitter_data")
-  end
-
-  def google_oauth2
-    request_data("Google","devise.google_oauth2_data")
-  end
-
-  private
-
-  def request_data(provider,provider_session)
-    @user = User.from_omniauth(request.env["omniauth.auth"])
-
-      if @user.persisted?
-        sign_in_and_redirect @user, :event => :authentication
-        flash[:notice] = I18n.t "devise.omniauth_callbacks.success", :kind => provider
-      else
-        session[provider_session] = request.env["omniauth.auth"]
-        redirect_to new_user_registration_url
-      end
-
-      def failure
-        redirect_to root_path
-      end
-  end
-
-end
diff --git a/app/controllers/old/chunks_controller.rb b/app/controllers/old/chunks_controller.rb
deleted file mode 100644
index 460eee16..00000000
--- a/app/controllers/old/chunks_controller.rb
+++ /dev/null
@@ -1,124 +0,0 @@
-class ChunksController < ApplicationController
-  layout nil
-
-  before_action :set_learning_object
-
-  #GET /chunk
-  def show
-    chunk = resumable_chunk chunk_number
-
-    unless valid_mime_type?
-      render :nothing => true, :status => 415
-    else
-      if File.exists?(chunk)
-        post_file_and_create_thumbnail @learning_object, resumable_filename if last_chunk?
-        #Let resumable.js know this chunk already exists
-        render :nothing => true, :status => 200
-      else
-        #Let resumable.js know this chunk doesnt exists and needs to be uploaded
-        render :nothing => true, :status => 404
-      end
-    end
-  end
-  #POST /chunk
-  def create
-
-    unless valid_mime_type?
-      return render :nothing => true, :status => 415
-    end
-
-    #chunk path based on the parameters
-    chunk = resumable_chunk chunk_number
-
-    #Create chunks directory when not present on system
-    if !File.directory?(dir)
-      FileUtils.mkdir(dir, :mode => 0700)
-    end
-
-    #Move the uploaded chunk to the directory
-    FileUtils.mv chunk_tmpfile, chunk
-
-    #Concatenate all the partial files into the original file
-    #When all chunks are uploaded
-    if last_chunk?
-      #Create a target file
-      File.open(resumable_filename, "a") do |target|
-        #Loop trough the chunks
-        for i in 1..chunk_number
-          #Select the chunk
-          chunk = File.open(resumable_chunk(i), 'r').read
-
-          #Write chunk into target file
-          chunk.each_line do |line|
-            target << line
-          end
-
-          #Deleting chunk
-          FileUtils.rm resumable_chunk(i), :force => true
-        end
-        puts "File saved to #{resumable_filename}"
-      end
-
-      post_file_and_create_thumbnail @learning_object, resumable_filename
-    end
-
-    render nothing: true, status: 200
-  end
-
-  private
-
-  def post_file_and_create_thumbnail(learning_object, filename)
-    publisher = LearningObjectPublisher.new(DspaceService.create_client)
-    publisher.post learning_object, filename
-  end
-
-  def chunk_tmpfile
-    chunks_params[:file].tempfile
-  end
-
-  def last_chunk?
-    chunk_number == total_chunks
-  end
-
-  def chunk_size
-    chunks_params[:resumableChunkSize].to_i
-  end
-
-  def total_chunks
-    chunks_params[:resumableTotalChunks].to_i
-  end
-
-  def chunk_number
-    chunks_params[:resumableChunkNumber].to_i
-  end
-
-  def resumable_chunk(part)
-    "#{resumable_filename}.part#{part}"
-  end
-
-  def resumable_filename
-    "#{dir}/#{chunks_params[:resumableFilename]}"
-  end
-
-  def dir
-    "/tmp/#{chunks_params[:resumableIdentifier]}"
-  end
-
-  def set_learning_object
-    @learning_object = LearningObject.find chunks_params[:learning_object_id]
-  end
-
-  def resumable_file_extension
-    File.extname(chunks_params[:resumableFilename])[1..-1]
-  end
-
-  def valid_mime_type?
-    mime_types = @learning_object.object_type.mime_types.map(&:extension)
-    return true if mime_types.empty?
-    mime_types.include? resumable_file_extension
-  end
-  # Never trust parameters from the scary internet, only allow the white list through.
-  def chunks_params
-    params.permit(:file, :learning_object_id, :resumableIdentifier, :resumableFilename, :resumableChunkNumber, :resumableTotalChunks, :resumableChunkSize)
-  end
-end
diff --git a/app/controllers/old/collections_controller.rb b/app/controllers/old/collections_controller.rb
deleted file mode 100644
index 9ae2446a..00000000
--- a/app/controllers/old/collections_controller.rb
+++ /dev/null
@@ -1,229 +0,0 @@
-class CollectionsController < ApplicationController
-  include Pundit
-
-  before_action :set_collection, only: [:show, :update, :destroy, :like, :change_privacy]
-  before_action :set_collections, only: [:list, :add_learning_object, :remove_learning_object]
-  before_action :authenticate_user!, only: [:update, :destroy, :like, :list, :me, :add_learning_object, :remove_learning_object, :change_privacy]
-  before_action :authorize_action, only: [:show, :create, :update, :destroy, :add_learning_object, :remove_learning_object, :change]
-
-  rescue_from Pundit::NotAuthorizedError, with: :user_not_authorized
-
-
-  # GET /collections
-  # GET /collections.json
-  def index
-    respond_to do |format|
-      # for HTML page, returns institutional collections
-      format.html do
-        @collections = Collection.all.where(owner: Institution.all)
-      end
-
-      # returns all collection of logged user as JSON for UI actions
-      if user_signed_in?
-        format.json do
-          @collections = current_user.collections
-        end
-      end
-    end
-  end
-
-  # GET /collections/1
-  # GET /collections/1.json
-  def show
-    if @collection.class == User
-      # bookmark
-      @user = @collection
-      @collection = collection_repository.bookmarks(@user)
-      @own = true
-    else
-      check_collection_privacy! @collection
-
-      @user = @collection.owner
-      @own = user_signed_in? ? @collection.user_own?(current_user) : false
-    end
-
-    @reviews = Review.includes(:user).where(reviewable: @collection)
-
-    render partial: 'list' if params[:list] == 'true'
-  end
-
-  # POST /collections/1/like
-  def like
-    Collection.like @collection
-  end
-
-  # POST /collections
-  # POST /collections.json
-  def create
-    @collection = Collection.new(collection_params)
-    @collection.owner = params[:collection][:owner].blank? ? current_user : Institution.find(params[:collection][:owner])
-
-    respond_to do |format|
-      if @collection.save
-        format.html { redirect_to :back, notice: t('activerecord.attributes.collection.create.notice.successfully_created') }
-      else
-        format.html { render :new }
-      end
-    end
-  end
-
-  # PATCH/PUT /collections/1
-  # PATCH/PUT /collections/1.json
-  def update
-    respond_to do |format|
-      if Collection.update(collection_params)
-        format.html { redirect_to @collection, notice: t('activerecord.attributes.collection.update.notice.successfully_updated') }
-      else
-        format.html { render :edit }
-      end
-    end
-  end
-
-  # DELETE /collections/1
-  # DELETE /collections/1.json
-  def destroy
-    Collection.destroy @collection
-
-    respond_to do |format|
-      format.html { redirect_to user_path(current_user), notice: t('activerecord.attributes.collection.destroy.notice.successfully_destroy') }
-    end
-  end
-
-  def list
-    @collection = @collections.first
-
-    # list all
-    @collection = nil if @collection == 'all'
-
-    @collections = current_user.associated_collections
-    @collections.select! do |c|
-      (!@collection.blank? && c.id != @collection.id) || !include_learning_objects?(c)
-    end
-    @type = params[:type]
-
-    unless @type.blank?
-      @send = case @type
-                when 'add' then
-                  'Adicionar'
-                when 'copy' then
-                  'Copiar'
-                when 'move' then
-                  'Mover'
-                else
-                  'Enviar'
-              end
-
-      @title = (@send == 'Enviar') ? 'Coleções' : @send + '  objeto(s) às coleções'
-    end
-
-    render layout: false
-  end
-
-  def me
-    @new_collection = Collection.new
-
-    @publishers = current_user.institutions
-    @bookmark = (current_user.bookmarks.nil? || current_user.bookmarks.first.nil?) ? [] : [current_user.bookmarks.first]
-
-    @groups = [
-        CollectionsGroup.new(title: 'Coleções Automáticas',
-                             collections: @bookmark),
-        CollectionsGroup.new(title: 'Coleções Adicionadas',
-                             collections: current_user.associated_collections)
-    ]
-
-  end
-
-  # POST /collections/1/learning_object
-  def add_learning_object
-    @collections.each do |collection|
-      next unless collection.user_own?(current_user)
-
-      @learning_objects.each do |learning_object|
-        collection.learning_objects << learning_object unless collection.learning_objects.include? learning_object
-      end
-      collection.save
-    end
-
-    render json: {status: true} if request.xhr?
-  end
-
-  # DELETE /collections/1/learning_object
-  def remove_learning_object
-    @collections.each do |collection|
-      next unless collection.user_own?(current_user)
-
-      @learning_objects.each do |learning_object|
-        collection.learning_objects.destroy(learning_object)
-      end
-      collection.save
-    end
-
-    render json: {status: true} if request.xhr?
-  end
-
-  # change collection privacy
-  def change_privacy
-    @collection.privacy = params[:privacy]
-
-    response = @collection.save
-
-    render json: {status: response} if request.xhr?
-  end
-
-  private
-
-  def include_learning_objects?(collection)
-    @learning_objects.each do |lo|
-      return true if collection.learning_objects.include? lo
-    end
-    false
-  end
-
-  def check_collection_privacy!(collection)
-    if collection.private? && !collection.user_own?(current_user)
-      redirect_to :root, notice: 'Está é uma coleção privada.'
-    end
-  end
-
-  def set_collection
-    @collection = Collection.find params[:id]
-  end
-
-  def set_collections
-    if params[:id] == 'all' || params[:id].blank?
-      @collections = ['all']
-    else
-      @collections = (params[:id].class == String) ? [Collection.find(params[:id])] : params[:id].map { |id| Collection.find id }
-    end
-
-    unless params[:learning_objects_ids].blank?
-      @learning_objects = []
-
-      params[:learning_objects_ids].split(',').each do |id|
-        object = LearningObject.find id
-        @learning_objects << object unless object.blank?
-      end
-    end
-  end
-
-  # Never trust parameters from the scary internet, only allow the white list through.
-  def collection_params
-    params.require(:collection).permit(:name, :description, learning_objects: [])
-  end
-
-  def user_not_authorized
-    flash[:notice] = "Esta coleção é privada!"
-    redirect_to (root_path)
-  end
-
-  def authorize_action
-    if !@collections.nil?
-      @collections.each { |c| authorize c }
-    else
-      @collection ||= Collection.new
-      authorize @collection
-    end
-  end
-
-end
diff --git a/app/controllers/old/complaints_controller.rb b/app/controllers/old/complaints_controller.rb
deleted file mode 100644
index 07662797..00000000
--- a/app/controllers/old/complaints_controller.rb
+++ /dev/null
@@ -1,32 +0,0 @@
-class ComplaintsController < ApplicationController
-  include Pundit
-
-  before_action :authorize_action
-  before_action :authenticate_user!
-
-  def create
-    complaint = Complaint.new(complaint_params)
-    complaint.user = current_user
-
-    respond_to do |format|
-      if complaint.save
-        format.html { redirect_to :back, notice: t('activerecord.attributes.complaint.create.notice.sucess') }
-      else
-        format.html { redirect_to :back, alert: t('activerecord.attributes.complaint.create.alert.failure') }
-      end
-    end
-  end
-
-  private
-
-  # Never trust parameters from the scary internet, only allow the white list through.
-  def complaint_params
-    params.require(:complaint).permit(:complaintable_id, :complaintable_type, :complaint_reason_id, :description)
-  end
-
-  def authorize_action
-    @complaint ||= Complaint.new(complaint_params)
-    authorize @complaint
-  end
-
-end
diff --git a/app/controllers/old/feedbacks_controller.rb b/app/controllers/old/feedbacks_controller.rb
deleted file mode 100644
index bf391b70..00000000
--- a/app/controllers/old/feedbacks_controller.rb
+++ /dev/null
@@ -1,54 +0,0 @@
-class FeedbacksController < ApplicationController
-  before_filter :authenticate_user!
-
-  # GET /feedbacks/new
-  def new
-  #  @feedbacks = Feedback.new
-
-#    render layout: false
- end
-
-  # GET /feedbacks/new_bug
-  def new_bug
-    @bug = Bug.new
-
-    render layout: false
-  end
-
-  # POST /feedbacks
-  def create
-   # @feedbacks = Feedback.new(feedback_params)
-
-   # respond_to do |format|
-   #   if feedback_service.send_feedback @feedbacks
-   #     format.html { redirect_to :back, notice: 'Obrigado pela sua avaliação!' }
-  #    end
-  #  end
-  end
-
-  # POST /feedbacks/report_bug
-  def report_bug
-    @bug = Bug.new(bug_params)
-
-    respond_to do |format|
-      if feedback_service.report_bug @bug
-        format.html { redirect_to :back, notice: t('activerecord.attributes.feedback.report_bug.notice.success') }
-      end
-    end
-  end
-
-  private
-
-  def feedback_service
-    FeedbackService.new(GitlabBugreporterService.new(Gitlab))
-  end
-
-  def bug_params
-    params.require(:bug).permit(:title, :description)
-  end
-
-  def feedback_params
-    params.require(:feedbacks).permit(:object, :message, :description)
-  end
-
-end
diff --git a/app/controllers/old/institutions_controller.rb b/app/controllers/old/institutions_controller.rb
deleted file mode 100644
index 0f89f86b..00000000
--- a/app/controllers/old/institutions_controller.rb
+++ /dev/null
@@ -1,83 +0,0 @@
-class InstitutionsController < ApplicationController
-  include Pundit
-
-  before_action :set_institution, only: [:show, :edit, :update, :destroy, :like, :users]
-  before_action :authorize_action
-
-  # GET /institutions
-  # GET /institutions.json
-  def index
-    @institutions = Institution.all
-  end
-
-  # GET /institutions/1
-  # GET /institutions/1.json
-  def show
-  end
-
-  # GET /institutions/new
-  def new
-    @institution = Institution.new
-  end
-
-  # GET /institutions/1/edit
-  def edit
-  end
-
-  # POST /institutions
-  # POST /institutions.json
-  def create
-    @institution = Institution.new(institution_params)
-
-    respond_to do |format|
-      if Institution.save @institution
-        format.html { redirect_to @institution, notice: t('activerecord.attributes.institution.create.notice.successfully_created') }
-      else
-        format.html { render :new }
-      end
-    end
-  end
-
-  # PATCH/PUT /institutions/1
-  # PATCH/PUT /institutions/1.json
-  def update
-    respond_to do |format|
-      if Institution.update(institution_params)
-        format.html { redirect_to @learning_object, notice: t('activerecord.attributes.institution.update.notice.successfully_updated') }
-      else
-        format.html { render :edit }
-      end
-    end
-  end
-
-  # DELETE /institutions/1
-  # DELETE /institutions/1.json
-  def destroy
-    Institution.destroy @institution
-
-    respond_to do |format|
-      format.html { redirect_to institutions_url, notice: t('activerecord.attributes.institution.destroy.notice.successfully_destroy') }
-    end
-  end
-
-  def users
-    @users = @institution.users
-  end
-
-  private
-
-  def set_institution
-    @institution = Institution.find(params[:id])
-  end
-
-  # Never trust parameters from the scary internet, only allow the white list through.
-  def institution_params
-    params[:institution_object]
-  end
-
-  def authorize_action
-    @institution ||= Institution.new
-    authorize @institution
-  end
-
-end
diff --git a/app/controllers/old/learning_objects/build_controller.rb b/app/controllers/old/learning_objects/build_controller.rb
deleted file mode 100644
index 2463a666..00000000
--- a/app/controllers/old/learning_objects/build_controller.rb
+++ /dev/null
@@ -1,42 +0,0 @@
-class LearningObjects::BuildController < ::ApplicationController
-  layout 'learning_object_studio'
-
-  include Wicked::Wizard
-  before_action :set_learning_object, only: [:show, :update]
-
-  steps :upload_attachments, :select_thumbnail
-
-  def show
-    render_wizard
-  end
-
-  def update
-    @learning_object.update_attributes(learning_object_params)
-    publish @learning_object if step == steps.last
-    render_wizard @learning_object, notice: update_message
-  end
-
-  private
-
-  def set_learning_object
-    @learning_object = LearningObject.unscoped.find(params[:learning_object_id])
-  end
-
-  def publish(learning_object)
-    learning_object.publish
-    learning_object.save
-  end
-
-  def learning_object_params
-    params[:learning_object].permit(:thumbnail, :name, :object_type_id, :description, :school_level, :language, :link, topics: [])
-  end
-
-  def update_message
-    case step
-      when :upload_attachments
-        "Seus arquivos foram enviados com sucesso! Agora atualize a imagem do seu conteúdo para finalizar o processo de criação."
-      when :select_thumbnail
-        "Parabéns, a imagem foi atualizada e seu conteúdo foi criado com sucesso! Acesse seu perfil e veja todos os objetos criados."
-    end
-  end
-end
\ No newline at end of file
diff --git a/app/controllers/old/learning_objects_controller.rb b/app/controllers/old/learning_objects_controller.rb
deleted file mode 100644
index 99915a21..00000000
--- a/app/controllers/old/learning_objects_controller.rb
+++ /dev/null
@@ -1,174 +0,0 @@
-require 'uri'
-
-class LearningObjectsController < ApplicationController
-  include Reportable
-  layout :resolve_layout
-
-  before_action :authenticate_user!, except: [:index, :show]
-  before_action :set_learning_object, only: [:show, :edit, :update,
-                                             :destroy, :destroy_attachment, :remove_thumbnail, :like, :bookmarks,
-                                             :collections, :upload, :upload_link, :download,
-                                             :user_not_authorized]
-  after_action :increment_learning_object_views, only: [:show]
-  before_action :set_form_objects, only: [:new, :edit, :create]
-  before_action :authorize_action
-  before_action :set_preview_notice, only: :show
-
-  # GET /learning_objects/1
-  # GET /learning_objects/1.json
-  def show
-    @liked = @learning_object.liked?(current_user) if user_signed_in?
-    @reviews = Review.where(reviewable: @learning_object)
-  end
-
-  # GET /learning_objects/new
-  def new
-    @learning_object = LearningObject.new
-  end
-
-  # GET /learning_objects/1/edit
-  def edit
-  end
-
-  # POST /learning_objects
-  # POST /learning_objects.json
-  def create
-    @learning_object = ::LearningObject::DraftBuilder.build current_user, learning_object_params
-    publisher = LearningObjectPublisher.new(DspaceService.create_client)
-
-    respond_to do |format|
-      if publisher.create_draft @learning_object
-        # go to file submission page
-        format.html { success_redirect @learning_object }
-      else
-        format.html { render :new, notice:  t('activerecord.attributes.learning_object.create.notice.failure') }
-      end
-    end
-
-  end
-
-  # PATCH/PUT /learning_objects/1
-  # PATCH/PUT /learning_objects/1.json
-  def update
-    respond_to do |format|
-      if @learning_object.update(LearningObjectBuilder.build_form_params(learning_object_params))
-        format.html { redirect_to learning_object_build_path(learning_object_id: @learning_object.id, id: :upload_attachments), notice: 'Os metadados do seu conteúdo educacional foram atualizados com sucesso!' }
-      else
-        format.html { render :edit }
-      end
-    end
-  end
-
-  # DELETE /learning_objects/1
-  # DELETE /learning_objects/1.json
-  def destroy
-    LearningObject.destroy @learning_object
-
-    respond_to do |format|
-      format.html { redirect_to user_path(current_user), notice: t('activerecord.attributes.learning_object.destroy.notice.successfully_destroy') }
-    end
-  end
-
-  # POST /learning_objects/1/like
-  def like
-    if @learning_object.liked? current_user
-      @learning_object.dislike current_user
-    else
-      @learning_object.like current_user
-    end
-
-    if request.xhr?
-      render json: {count: @learning_object.likes.count, id: params[:id]}
-    end
-  end
-
-  def destroy_attachment
-    attachment = LearningObject::Attachment.find(params[:attachment_id])
-    @learning_object.update(attachment: nil) if @learning_object.attachment == attachment
-    attachment.destroy
-    render :nothing => true, :status => 204
-  end
-
-  def remove_thumbnail
-    @learning_object.thumbnail = nil
-    @learning_object.save
-    render :nothing => true, :status => 204
-  end
-
-  def download
-    @learning_object.download current_user
-
-    redirect_to @learning_object.retrieve_link
-  end
-
-  # POST /learning_objects/1/bookmarks
-  def bookmarks
-    bookmarks = current_user.bookmarks
-    bookmarks.add @learning_object
-    Collection.save_learning_objects bookmarks
-
-    if request.xhr?
-      render json: {id: params[:id]}
-    end
-  end
-
-  # GET /learning_objects/1/collections.json
-  def collections
-    @collections = @learning_object.collections
-  end
-
-  private
-
-  def set_preview_notice
-    if params[:preview_object]
-      flash[:notice] = %Q[Você está pré-visualizando o objeto. <a href='javascript:history.back()'>Clique aqui para voltar ao estúdio de criação</a>.]
-    end
-  end
-
-  # Use callbacks to share common setup or constraints between actions.
-  def set_learning_object
-    @learning_object = LearningObject.unscoped.find(params[:id])
-  end
-
-  # Never trust parameters from the scary internet, only allow the white list through.
-  def learning_object_params
-    params[:learning_object].permit(:author, :name, :object_type_id, :description, :school_level, :language, :link, topics: [])
-  end
-
-  def increment_learning_object_views
-    View.create(viewable: @learning_object, user: current_user) if user_signed_in? && @learning_object.publisher != current_user
-  end
-
-  def success_redirect(learning_object)
-    #if 'Website externo' == learning_object.object_type.name
-    redirect_to learning_object_build_path(learning_object, :upload_attachments), notice: t('activerecord.attributes.learning_object.success_redirect.notice.successfully_created')
-  end
-
-  def set_form_objects
-    @school_levels = ['Educação Infantil', 'Ensino Fundamental', 'Ensino Médio']
-    @topics = Topic.defaults
-    @types = ObjectType.all
-    @languages = Language.all
-  end
-
-  def user_not_authorized
-    flash[:notice] = "Este objeto está suspenso!"
-    flash[:alert] = "Razões: #{Complaint.where(complaintable_id: @learning_object.id).map(&:reason).join(',').to_s}"
-    redirect_to (root_path)
-  end
-
-  def resolve_layout
-    case action_name
-      when 'new', 'edit', 'create', 'update'
-        'learning_object_studio'
-      else
-        'application'
-    end
-  end
-
-  def authorize_action
-    @learning_object ||= LearningObject.new
-    authorize @learning_object
-  end
-
-end
diff --git a/app/controllers/old/links_controller.rb b/app/controllers/old/links_controller.rb
deleted file mode 100644
index 78529c14..00000000
--- a/app/controllers/old/links_controller.rb
+++ /dev/null
@@ -1,2 +0,0 @@
-class LinksController < ApplicationController
-end
diff --git a/app/controllers/old/reviews_controller.rb b/app/controllers/old/reviews_controller.rb
deleted file mode 100644
index 75e783ee..00000000
--- a/app/controllers/old/reviews_controller.rb
+++ /dev/null
@@ -1,98 +0,0 @@
-class ReviewsController < ApplicationController
-  include Pundit
-
-  before_action :authenticate_user!, except: [:show, :list]
-  before_action :set_review, only: [:show, :destroy]
-  before_action :authorize_action
-
-
-  def list
-    if !params[:learning_object_id].blank?
-      reviewable = LearningObject.find params[:learning_object_id]
-    elsif !params[:collection_id].blank?
-      reviewable = Collection.find params[:collection_id]
-    end
-
-    @reviews = Review.where(reviewable: reviewable) unless reviewable.blank?
-  end
-
-  # Global variables to show page
-  def show
-  end
-
-  def new
-    @review = Review.new
-    @rates = Rating.all
-
-    @reviewable_id = params[:reviewable_id]
-    @reviewable_type = params[:reviewable_type]
-  end
-
-  def create
-    review = Review.where(user: current_user, reviewable_id: params[:reviewable_id], reviewable_type: params[:reviewable_type]).new(review_params)
-
-    respond_to do |format|
-      if review.save && !params[:rates].blank? && params[:rates].is_a?(Hash) && params[:rates].size == Rating.count
-        ratings = []
-        params[:rates].each { |id, value| ratings << ReviewRating.new(review: review, rating_id: id.to_i, value: value.to_i) }
-        ReviewRating.import ratings
-
-        format.html { redirect_to params[:reviewable_type].constantize.find(params[:reviewable_id]), notice: t('activerecord.attributes.review.create.notice.successfully_created') }
-      else
-        review.destroy
-        format.html { redirect_to new_review_path, alert: t('activerecord.attributes.review.create.alert.there_was_an_error')}
-      end
-    end
-  end
-
-  def destroy
-    redirect = @review.reviewable
-
-    @review.destroy
-
-    respond_to do |format|
-      format.html { redirect_to redirect, notice: t('activerecord.attributes.review.destroy.notice.successfully_destroy') }
-    end
-  end
-
-  # User approve or not, the review
-  def rate
-    review = Review.find(params[:id])
-    user = current_user
-    approves = approves_param
-
-    rate = Rate.where(user: user, review: review).first_or_initialize
-
-    if rate.approves == approves
-      rate.destroy
-    else
-      rate.update(approves: approves)
-    end
-
-    render json: { approves: approves } if request.xhr?
-  end
-
-  private
-
-  def set_review
-    @review = Review.find params[:id]
-  end
-
-  # Never trust parameters from the scary internet, only allow the white list through.
-  def review_params
-    params.require(:review).permit(:name, :description, :pros, :cons)
-  end
-
-  def approves_param
-    case params[:approves]
-    when 'true' then true
-    when 'false' then false
-    end
-  end
-
-  def authorize_action
-    @review||= Review.new
-    authorize @review
-  end
-
-end
diff --git a/app/controllers/old/search_controller.rb b/app/controllers/old/search_controller.rb
deleted file mode 100644
index dc7d2368..00000000
--- a/app/controllers/old/search_controller.rb
+++ /dev/null
@@ -1,142 +0,0 @@
-class SearchController < ApplicationController
-
-  include LearningObjectsHelper
-  include Pundit
-
-  def index
-    @types = ObjectType.all.map(&:name)
-
-    @topics = Topic.defaults
-
-    @school_levels = ['Educação Infantil', 'Ensino Fundamental', 'Ensino Médio'].map { |o| Topic.find_by_name(o) }
-
-    @sources = Institution.all
-  end
-
-  def fetch
-
-    params[:query] = "*" if params[:query].blank?
-
-    case params[:search_class]
-    when "LearningObject"
-      @result = LearningObject.search params[:query], where: where_hash(params), order: lo_order_hash(params), page: params[:page] || 1, per_page: 10
-    when "Collection"
-      @result = Collection.search params[:query], where: {privacy: "public"}, order: col_order_hash(params), page: params[:page] || 1, per_page: 10
-    when "User"
-      @result = User.search params[:query], order: user_order_hash(params), page: params[:page] || 1, per_page: 10
-    else
-      raise "Wrong search class parameter"
-    end
-
-    render partial: 'search/fetch'
-  end
-
-  def autocomplete
-    params_hash = {}
-    get_thumbnail = nil
-    case params[:search_class]
-    when "LearningObject"
-      params_hash = { fields: ['name^10', 'description', 'author'] }
-      get_thumbnail = Proc.new { |obj| image_tag(learning_object_thumbnail(obj)) }
-    when "Collection"
-      params_hash = { where: {privacy: "public"},
-        fields: ['name^10', 'description', 'owner'] }
-      get_thumbnail = Proc.new { |obj| image_tag("/assets/icons/collection") }
-    when "User"
-      params_hash = { fields: ['name'] }
-      get_thumbnail = Proc.new { |obj| image_tag(obj.avatar.url(:thumb), 32) }
-    else
-      raise "Wrong search class parameter"
-    end
-    render json: autocomplete_search(Object.const_get(params[:search_class]), params_hash, get_thumbnail)
-  end
-
-  def get_class_size
-    className = params[:class]
-    render json: { number: Object.const_get(className).count }
-  end
-
-  private
-
-  def autocomplete_search(search_class, params_hash={}, get_thumbnail)
-    response = []
-    search_params = { limit: 10, misspellings: { below: 5 }, where: {state: validate_object} }
-    objs = search_class.search(params[:query], search_params.merge(params_hash))
-    objs.each do |obj|
-      hash = {}
-      hash["name"] = obj.name
-      hash["thumbnail"] = get_thumbnail.call(obj)
-      hash["url"] = url_for([obj, :only_path => false])
-      response <<  hash
-    end
-    response
-  end
-
-  def image_tag(image, width=56, height=32)
-    ActionController::Base.helpers.image_tag image, width: width, height: height, class: "autocomplete"
-  end
-
-  def where_hash(params)
-    hash = {}
-
-    topics = params[:topic] unless params[:topic].blank?
-    topics += ", " unless topics.nil?
-    topics = topics.to_s + params[:school_level] unless params[:school_level].blank?
-
-    # build hash
-    hash[:topics_name] = topics.split(', ') unless topics.nil?
-    hash[:object_type] = params[:type].split(', ') unless params[:type].blank?
-    hash[:publisher] = params[:source].split("-s- ") unless params[:source].blank?
-    hash[:state] = validate_object
-    # year = params[:year].blank? ? nil : params[:year].split('-').take(2)
-
-    hash.blank? ? nil : hash
-  end
-
-  def lo_order_hash(params)
-    case params[:order]
-    when 'author'
-      { author: {order: :asc, unmapped_type: :string} }
-    when 'publicationasc'
-      { published_at: {order: :asc, unmapped_type: :timestamp} }
-    when 'publicationdesc'
-      { published_at: {order: :desc, unmapped_type: :timestamp} }
-    when 'title'
-      { name: {order: :asc, unmapped_type: :string} }
-    else
-      { score: {order: :desc, unmapped_type: :integer} }
-    end
-  end
-
-  def col_order_hash(params)
-    case params[:order]
-    when 'author'
-      { owner: {order: :asc, unmapped_type: :string} }
-    when 'publicationasc'
-      { created_at: {order: :asc, unmapped_type: :timestamp} }
-    when 'publicationdesc'
-      { created_at: {order: :desc, unmapped_type: :timestamp} }
-    when 'title'
-      { name: {order: :asc, unmapped_type: :string} }
-    else
-      { score: {order: :desc, unmapped_type: :integer} }
-    end
-  end
-
-  def user_order_hash(params)
-    if params[:order] == 'title'
-      { name: {order: :asc, unmapped_type: :string} }
-    else
-      { score: {order: :desc, unmapped_type: :integer} }
-    end
-  end
-
-
-  private
-
-  def validate_object
-    return 'published' if current_user.nil? || !current_user.is_admin?
-    return ['published', 'suspended', 'draft']
-  end
-
-end
diff --git a/app/controllers/old/users_controller.rb b/app/controllers/old/users_controller.rb
deleted file mode 100644
index b4f75c7d..00000000
--- a/app/controllers/old/users_controller.rb
+++ /dev/null
@@ -1,80 +0,0 @@
-class UsersController < ApplicationController
-
-  include Pundit
-
-  before_action :authenticate_user!, only: [:follow, :unfollow]
-  before_action :check_current_user_page, only: :show
-  before_action :set_user, only: [:show]
-  before_action :set_institutions, only: :me
-  before_action :set_empty_collection, only: [:show, :me]
-  before_action :set_followable, only: [:follow, :unfollow]
-
-  def show
-    @objects = @user.learning_objects
-    @institutions = @user.institutions
-    @groups = [CollectionsGroup.new(title: 'Coleções Adicionadas', collections: [ CollectionPolicy::Scope.new(current_user, @user.id, @user.collections).resolve.includes(:owner)])]
-
-    if @user == current_user
-      @publishers = @user.institutions
-      @bookmarks = (@user.bookmarks.nil? || @user.bookmarks.first.nil?) ? [] : [@user.bookmarks.first]
-      @groups.unshift(CollectionsGroup.new(title: 'Coleções Automáticas', collections: @bookmarks))
-    end
-  end
-
-  def list
-    @users = User.all
-  end
-
-  def follow
-    Follow.create(user: current_user, followable: @followable) unless @followable.nil?
-
-    redirect_to user_path(@followable)
-  end
-
-  def unfollow
-    Follow.where(user: current_user, followable: @followable).destroy_all unless @followable.nil?
-
-    redirect_to user_path(@followable)
-  end
-
-  def verify_email
-    exists = User.find_by_email(params[:email])
-    render json: { valid: exists.nil? && !params[:email].match(Devise.email_regexp).nil? }
-  end
-
-  private
-
-  def set_empty_collection
-    @new_collection = Collection.new
-  end
-
-  def set_institutions
-    @institutions = current_user.institutions
-  end
-
-  def set_user
-    @user = User.find params[:id]
-  end
-
-  def set_followable
-    @followable = params[:followable_type].constantize.find(params[:followable_id]) if %w(Collection User).include? params[:followable_type]
-  end
-
-  def check_current_user_page
-    if user_signed_in?
-      if current_user.id == params[:id]
-        redirect_to action: :me
-      end
-    end
-  end
-
-  def publishers_for(user)
-    publishers = []
-    user_publisher = user
-    user_publisher.id = user.rid
-
-    publishers << user_publisher
-    publishers + user.institutions
-  end
-
-end
diff --git a/app/controllers/old/welcome_controller.rb b/app/controllers/old/welcome_controller.rb
deleted file mode 100644
index 9b768117..00000000
--- a/app/controllers/old/welcome_controller.rb
+++ /dev/null
@@ -1,18 +0,0 @@
-class WelcomeController < ApplicationController
-  include Pundit
-
-  def index
-    @carousel = Carousel.all || []
-    @highlights = policy_scope(LearningObject).limit(8).includes(:publisher, :language, :topics)
-  end
-
-  def faq
-  end
-
-  def contact
-  end
-
-  def terms_of_service
-  end
-
-end
-- 
GitLab