2015-05-05 03:10:25 +02:00
|
|
|
require 'sidekiq/web'
|
|
|
|
|
|
|
|
Rails.application.routes.draw do
|
|
|
|
post 'webhooks' => 'webhooks#create'
|
|
|
|
|
2016-03-23 18:39:41 +01:00
|
|
|
if AuthProvider.active.providable_type == DatabaseProvider.name
|
|
|
|
# with local authentification we do not use omniAuth so we must differentiate the config
|
|
|
|
devise_for :users, controllers: {registrations: 'registrations', sessions: 'sessions',
|
|
|
|
confirmations: 'confirmations', passwords: 'passwords'}
|
|
|
|
else
|
|
|
|
devise_for :users, controllers: {registrations: 'registrations', sessions: 'sessions',
|
|
|
|
confirmations: 'confirmations', passwords: 'passwords',
|
|
|
|
:omniauth_callbacks => 'users/omniauth_callbacks'}
|
|
|
|
end
|
|
|
|
|
2015-05-05 03:10:25 +02:00
|
|
|
|
|
|
|
## The priority is based upon order of creation: first created -> highest priority.
|
|
|
|
## See how all your routes lay out with "rake routes".
|
|
|
|
|
|
|
|
## You can have the root of your site routed with "root"
|
|
|
|
root 'application#index'
|
|
|
|
|
|
|
|
namespace :api, as: nil, defaults: { format: :json } do
|
|
|
|
resources :projects, only: [:index, :last_published, :show, :create, :update, :destroy] do
|
|
|
|
collection do
|
|
|
|
get :last_published
|
2016-03-23 18:39:41 +01:00
|
|
|
get :search
|
2015-05-05 03:10:25 +02:00
|
|
|
end
|
|
|
|
end
|
2016-04-22 18:17:55 +02:00
|
|
|
resources :openlab_projects, only: :index
|
2015-05-05 03:10:25 +02:00
|
|
|
resources :machines
|
|
|
|
resources :components
|
|
|
|
resources :themes
|
|
|
|
resources :licences
|
2016-03-23 18:39:41 +01:00
|
|
|
resources :admins, only: [:index, :create, :destroy]
|
|
|
|
resources :settings, only: [:show, :update, :index], param: :name
|
|
|
|
resources :users, only: [:index, :create]
|
|
|
|
resources :members, only: [:index, :show, :create, :update, :destroy] do
|
|
|
|
get '/export_subscriptions', action: 'export_subscriptions', on: :collection
|
|
|
|
get '/export_reservations', action: 'export_reservations', on: :collection
|
2015-05-05 03:10:25 +02:00
|
|
|
get '/export_members', action: 'export_members', on: :collection
|
2016-03-23 18:39:41 +01:00
|
|
|
put ':id/merge', action: 'merge', on: :collection
|
2016-05-30 15:39:19 +02:00
|
|
|
post 'list', action: 'list', on: :collection
|
2016-06-16 14:26:10 +02:00
|
|
|
get 'search/:query', action: 'search', on: :collection
|
2016-06-21 14:39:44 +02:00
|
|
|
get 'mapping', action: 'mapping', on: :collection
|
2015-05-05 03:10:25 +02:00
|
|
|
end
|
2016-03-23 18:39:41 +01:00
|
|
|
resources :reservations, only: [:show, :create, :index, :update]
|
2015-05-05 03:10:25 +02:00
|
|
|
resources :notifications, only: [:index, :show, :update] do
|
|
|
|
match :update_all, path: '/', via: [:put, :patch], on: :collection
|
|
|
|
end
|
2016-07-18 18:16:54 +02:00
|
|
|
resources :wallet do
|
|
|
|
get :my, on: :collection
|
|
|
|
get '/by_user/:user_id', action: 'by_user', on: :collection
|
2016-07-05 13:20:25 +02:00
|
|
|
get :transactions, on: :member
|
2016-07-05 19:07:50 +02:00
|
|
|
put :credit, on: :member
|
2016-07-18 18:16:54 +02:00
|
|
|
end
|
2015-05-05 03:10:25 +02:00
|
|
|
|
|
|
|
# for homepage
|
|
|
|
get '/last_subscribed/:last' => "members#last_subscribed"
|
|
|
|
get '/feeds/twitter_timelines' => "feeds#twitter_timelines"
|
|
|
|
|
2016-03-23 18:39:41 +01:00
|
|
|
get 'pricing' => "pricing#index"
|
|
|
|
put 'pricing' => "pricing#update"
|
|
|
|
|
|
|
|
resources :prices, only: [:index, :update] do
|
|
|
|
post 'compute', on: :collection
|
|
|
|
end
|
|
|
|
|
|
|
|
resources :trainings_pricings, only: [:index, :update]
|
|
|
|
|
|
|
|
resources :availabilities do
|
|
|
|
get 'machines/:machine_id', action: 'machine', on: :collection
|
2016-07-13 18:15:14 +02:00
|
|
|
get 'trainings/:training_id', action: 'trainings', on: :collection
|
2016-03-23 18:39:41 +01:00
|
|
|
get 'reservations', on: :member
|
2016-07-13 19:12:16 +02:00
|
|
|
get 'public', on: :collection
|
2016-03-23 18:39:41 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
resources :groups, only: [:index, :create, :update, :destroy]
|
|
|
|
resources :subscriptions, only: [:show, :create, :update]
|
|
|
|
resources :plans, only: [:index, :create, :update, :destroy, :show]
|
|
|
|
resources :slots, only: [:update] do
|
|
|
|
put 'cancel', on: :member
|
|
|
|
end
|
2015-05-05 03:10:25 +02:00
|
|
|
|
|
|
|
resources :events do
|
|
|
|
get 'upcoming/:limit', action: 'upcoming', on: :collection
|
|
|
|
end
|
|
|
|
|
2016-03-23 18:39:41 +01:00
|
|
|
resources :invoices, only: [:index, :show, :create] do
|
2016-05-04 18:17:50 +02:00
|
|
|
get 'download', action: 'download', on: :member
|
2016-05-31 10:02:27 +02:00
|
|
|
post 'list', action: 'list', on: :collection
|
2016-03-23 18:39:41 +01:00
|
|
|
end
|
|
|
|
|
2015-05-05 03:10:25 +02:00
|
|
|
# for admin
|
2016-07-19 12:16:41 +02:00
|
|
|
resources :trainings do
|
|
|
|
get :availabilities, on: :member
|
|
|
|
end
|
2016-03-23 18:39:41 +01:00
|
|
|
resources :credits
|
2016-06-28 17:06:33 +02:00
|
|
|
resources :categories
|
2016-06-29 10:38:04 +02:00
|
|
|
resources :event_themes
|
2016-06-29 11:21:21 +02:00
|
|
|
resources :age_ranges
|
2016-03-23 18:39:41 +01:00
|
|
|
resources :statistics, only: [:index]
|
|
|
|
resources :custom_assets, only: [:show, :create, :update]
|
|
|
|
resources :tags
|
|
|
|
resources :stylesheets, only: [:show]
|
|
|
|
resources :auth_providers do
|
|
|
|
get 'mapping_fields', on: :collection
|
|
|
|
get 'active', action: 'active', on: :collection
|
|
|
|
end
|
|
|
|
resources :abuses, only: [:create]
|
2016-05-09 18:15:04 +02:00
|
|
|
resources :open_api_clients, only: [:index, :create, :update, :destroy] do
|
|
|
|
patch :reset_token, on: :member
|
|
|
|
end
|
2016-03-23 18:39:41 +01:00
|
|
|
|
|
|
|
# i18n
|
|
|
|
get 'translations/:locale/:state' => 'translations#show', :constraints => { :state => /[^\/]+/ } # allow dots in URL for 'state'
|
|
|
|
end
|
|
|
|
|
2016-05-04 18:17:50 +02:00
|
|
|
# open_api
|
|
|
|
|
|
|
|
namespace :open_api do
|
|
|
|
namespace :v1 do
|
|
|
|
scope only: :index do
|
|
|
|
resources :users
|
|
|
|
resources :trainings
|
|
|
|
resources :user_trainings
|
|
|
|
resources :reservations
|
|
|
|
resources :machines
|
|
|
|
resources :bookable_machines
|
|
|
|
resources :invoices do
|
|
|
|
get :download, on: :member
|
|
|
|
end
|
|
|
|
resources :events
|
|
|
|
resources :availabilities
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2016-03-23 18:39:41 +01:00
|
|
|
%w(account event machine project subscription training user).each do |path|
|
|
|
|
post "/stats/#{path}/_search", to: "api/statistics##{path}"
|
2015-05-05 03:10:25 +02:00
|
|
|
end
|
2016-06-21 13:16:42 +02:00
|
|
|
post '_search/scroll', to: "api/statistics#scroll"
|
2015-05-05 03:10:25 +02:00
|
|
|
|
|
|
|
match '/project_collaborator/:valid_token', to: 'api/projects#collaborator_valid', via: :get
|
|
|
|
|
2016-03-23 18:39:41 +01:00
|
|
|
authenticate :user, lambda { |u| u.is_admin? } do
|
2015-05-05 03:10:25 +02:00
|
|
|
mount Sidekiq::Web => '/admin/sidekiq'
|
|
|
|
end
|
|
|
|
|
2016-05-05 15:02:02 +02:00
|
|
|
apipie
|
2015-05-05 03:10:25 +02:00
|
|
|
end
|