Skip to content
Snippets Groups Projects
routes.rb 6.25 KiB
Newer Older
bfs15's avatar
bfs15 committed

# Copyright (C) 2015 Centro de Computacao Cientifica e Software Livre
# Departamento de Informatica - Universidade Federal do Parana
#
# This file is part of portalmec.
#
# portalmec is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# portalmec is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with portalmec.  If not, see <http://www.gnu.org/licenses/>.

Rails.application.routes.draw do
Mateus Rambo Strey's avatar
Mateus Rambo Strey committed
  # require 'sidekiq/web'
  # mount Sidekiq::Web, at: '/sidekiq'
  concern :deletable do
    collection do
      get :deleted
    end
  end

      post 'follow', as: :follow, action: :follow
      delete 'follow', as: :unfollow, action: :unfollow
      put 'follow', as: :follow_toggle, action: :follow_toggle
  concern :taggable do
    member do
      post 'tagging', as: :tagging, action: :tagging
      delete 'tagging', as: :untagging, action: :untagging
  concern :subjectable do
    member do
      post 'subjects', as: :subjecting, action: :subjecting
      delete 'subjects', as: :unsubjecting, action: :unsubjecting
  concern :stageable do
    member do
      post 'educational_stages', as: :add_stages, action: :add_stages
      delete 'educational_stages', as: :remove_stages, action: :remove_stages
    end
  end

  concern :sociable do
      put 'like', as: :like, action: :like
      get 'download', as: :download, action: :download
    resources :reviews, only: [:index, :create, :update, :destroy], concerns: :deletable do
  concern :submission do
    collection do
      get 'submissions/:id', action: :show_submission
  concern :highlights do
    collection do
      get :this_week
      get :this_month
    end
  end

  # GET /users/1/learning_objects/
  concern :publisher do
Mateus Rambo Strey's avatar
Mateus Rambo Strey committed
      get 'drafts', as: :get_drafts, action: :show_all_drafts
      get 'learning_objects', as: :get_learning_objects, action: :show_all_learning_objects
      get 'learning_objects/liked', as: :get_liked_learning_objects, action: :show_liked_learning_objects
      get 'submissions', as: :get_submitted_learning_objects, action: :show_submitted_learning_objects
      get 'collections', as: :get_collections, action: :show_all_collections
      get 'collections/liked', as: :get_liked_collections, action: :show_liked_collections
  # GET /learning_objects/1/versions/123
  # GET /learning_objects/1/versions
  # POST /learning_objects/1/versions/234/checkout
  concern :versionable do
    resources :versions, only: [:show, :index] do
      member do
        post :checkout
      end
    end
  end

Mateus Rambo Strey's avatar
Mateus Rambo Strey committed
  scope :v1 do
    mount_devise_token_auth_for 'User', at: 'auth', controllers: {
      omniauth_callbacks: 'v1/omniauth_callbacks'
    }
Mateus Rambo Strey's avatar
Mateus Rambo Strey committed
  end
Mateus Rambo Strey's avatar
Mateus Rambo Strey committed
  namespace :v1 do
    resources :activities, only: [:index, :show] do
        collection do
            get 'me'
        end
    end
    resources :feed, only: [:index]
    resources :users, concerns: [:followable, :deletable, :publisher, :versionable] do
      resources :bookmarks, module: 'users', only: [:index, :create, :destroy]
        get 'followers', to: 'users#followers'
        get 'activities', to: 'activities#user_activities'
        get 'reviews/own', to: 'users#own_reviews'
        get 'reviews/received', to: 'users#received_reviews'
        post 'add_teacher', to: 'users#add_teacher'
        delete 'remove_teacher', to: 'users#remove_teacher'
      collection do
        get 'teacher_requests'
        post 'teacher_request', to: 'users#create_teacher_request'
        put 'teacher_request', to: 'users#update_teacher_request'
    resources :reviews, only: :show

    resources :search, only: :index do
      collection do
        get :autocomplete
    resources :collections, concerns: [:followable, :sociable, :downloadable, :reviewable, :taggable, :versionable, :deletable, :highlights, :subjectable, :stageable] do
        post :items, to: 'collections#add_object'
        delete :items, to: 'collections#delete_object'
    resources :learning_objects, concerns: [:sociable, :downloadable, :reviewable, :taggable, :versionable, :deletable, :highlights, :subjectable, :stageable, :submission] do
Mateus Rambo Strey's avatar
Mateus Rambo Strey committed
      member do
        resource :chunk, module: 'learning_objects', only: [:create, :show]
        resource :upload, module: 'learning_objects', only: :create
        resource :publish, module: 'learning_objects', only: :create
Mateus Rambo Strey's avatar
Mateus Rambo Strey committed
      end
      collection do
        get 'validate'
      end
      resources :attachment, module: 'learning_objects', only: [:destroy, :update, :index], on: :member
Mateus Rambo Strey's avatar
Mateus Rambo Strey committed
    end
    resources :institutions, concerns: :deletable do
Giovanne Marcelo's avatar
Giovanne Marcelo committed
      member do
        get :users, to: 'institutions#users'
      end
    resources :complaints, only: [:index, :show, :create], concerns: :deletable
    resources :languages, except: [:new, :edit]
    resources :licenses, except: [:new, :edit]
    resources :mime_types, except: [:new, :edit]
    resources :object_types, except: [:new, :edit]
    resources :roles, except: [:new, :edit]
    resources :scores, only: [:index, :show, :update]

    post '/package', to: 'packages#link'
    get '/subjects', to: 'subjects#index'
    get '/educational_stages', to: 'educational_stages#index'
    get 'learning_objects/magnetlink/:magnetlink', to: 'learning_objects#magnetlink', as: 'magnetlink_learning_objects'