2019-02-25 15:04:38 +01:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2015-05-05 03:10:25 +02:00
|
|
|
require 'sidekiq/web'
|
2020-01-13 17:05:53 +01:00
|
|
|
require 'sidekiq/cron/web'
|
2015-05-05 03:10:25 +02:00
|
|
|
|
|
|
|
Rails.application.routes.draw do
|
2016-03-23 18:39:41 +01:00
|
|
|
if AuthProvider.active.providable_type == DatabaseProvider.name
|
2020-03-30 15:32:14 +02:00
|
|
|
# with local authentication we do not use omniAuth so we must differentiate the config
|
2019-06-04 13:33:00 +02:00
|
|
|
devise_for :users, controllers: {
|
|
|
|
registrations: 'registrations', sessions: 'sessions', confirmations: 'confirmations', passwords: 'passwords'
|
|
|
|
}
|
2016-03-23 18:39:41 +01:00
|
|
|
else
|
2019-06-04 13:33:00 +02:00
|
|
|
devise_for :users, controllers: {
|
|
|
|
registrations: 'registrations', sessions: 'sessions', confirmations: 'confirmations', passwords: 'passwords',
|
|
|
|
omniauth_callbacks: 'users/omniauth_callbacks'
|
|
|
|
}
|
2019-10-02 14:37:47 +02:00
|
|
|
get '/sso-redirect', to: 'application#sso_redirect', as: :sso_redirect
|
2016-03-23 18:39:41 +01:00
|
|
|
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".
|
|
|
|
|
2019-02-25 15:04:38 +01:00
|
|
|
constraints user_agent: %r{facebookexternalhit/[0-9]|Twitterbot|Pinterest|Google.*snippet} do
|
|
|
|
root to: 'social_bot#share', as: :bot_root
|
2016-07-28 17:44:58 +02:00
|
|
|
end
|
|
|
|
|
2015-05-05 03:10:25 +02:00
|
|
|
## You can have the root of your site routed with "root"
|
|
|
|
root 'application#index'
|
|
|
|
|
|
|
|
namespace :api, as: nil, defaults: { format: :json } do
|
2019-02-25 15:04:38 +01:00
|
|
|
resources :projects, only: %i[index show create update destroy] do
|
2015-05-05 03:10:25 +02:00
|
|
|
collection do
|
|
|
|
get :last_published
|
2016-03-23 18:39:41 +01:00
|
|
|
get :search
|
2016-09-27 14:08:04 +02:00
|
|
|
get :allowed_extensions
|
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
|
2019-02-25 15:04:38 +01:00
|
|
|
resources :admins, only: %i[index create destroy]
|
2019-09-16 14:39:47 +02:00
|
|
|
resources :settings, only: %i[show update index], param: :name do
|
|
|
|
patch '/bulk_update', action: 'bulk_update', on: :collection
|
2020-01-22 11:53:40 +01:00
|
|
|
put '/reset/:name', action: 'reset', on: :collection
|
2019-09-16 14:39:47 +02:00
|
|
|
end
|
2020-04-21 16:47:35 +02:00
|
|
|
resources :users, only: %i[index create destroy]
|
2019-02-25 15:04:38 +01:00
|
|
|
resources :members, only: %i[index show create update destroy] do
|
2016-03-23 18:39:41 +01:00
|
|
|
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
|
2020-02-18 17:36:45 +01:00
|
|
|
patch ':id/complete_tour', action: 'complete_tour', on: :collection
|
2020-05-04 18:32:25 +02:00
|
|
|
patch ':id/update_role', action: 'update_role', on: :collection
|
2015-05-05 03:10:25 +02:00
|
|
|
end
|
2019-02-25 15:04:38 +01:00
|
|
|
resources :reservations, only: %i[show create index update]
|
|
|
|
resources :notifications, only: %i[index show update] do
|
|
|
|
match :update_all, path: '/', via: %i[put patch], on: :collection
|
2017-01-05 15:06:54 +01:00
|
|
|
get 'polling', action: 'polling', on: :collection
|
|
|
|
get 'last_unread', action: 'last_unread', on: :collection
|
2015-05-05 03:10:25 +02:00
|
|
|
end
|
2016-07-07 15:57:06 +02:00
|
|
|
resources :wallet, only: [] do
|
2016-07-18 18:16:54 +02:00
|
|
|
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
|
2019-02-25 15:04:38 +01:00
|
|
|
get '/last_subscribed/:last' => 'members#last_subscribed'
|
2015-05-05 03:10:25 +02:00
|
|
|
|
2016-08-08 14:42:17 +02:00
|
|
|
get 'pricing' => 'pricing#index'
|
|
|
|
put 'pricing' => 'pricing#update'
|
2016-03-23 18:39:41 +01:00
|
|
|
|
2019-02-25 15:04:38 +01:00
|
|
|
resources :prices, only: %i[index update] do
|
2016-03-23 18:39:41 +01:00
|
|
|
post 'compute', on: :collection
|
|
|
|
end
|
2016-08-08 17:09:05 +02:00
|
|
|
resources :coupons
|
|
|
|
post 'coupons/validate' => 'coupons#validate'
|
2016-08-16 18:12:13 +02:00
|
|
|
post 'coupons/send' => 'coupons#send_to'
|
2016-03-23 18:39:41 +01:00
|
|
|
|
2019-02-25 15:04:38 +01:00
|
|
|
resources :trainings_pricings, only: %i[index update]
|
2016-03-23 18:39:41 +01:00
|
|
|
|
|
|
|
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
|
2017-02-23 17:45:55 +01:00
|
|
|
get 'spaces/:space_id', action: 'spaces', 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
|
2017-03-02 12:34:28 +01:00
|
|
|
get '/export_index', action: 'export_availabilities', on: :collection
|
2017-09-06 15:01:41 +02:00
|
|
|
put ':id/lock', action: 'lock', on: :collection
|
2016-03-23 18:39:41 +01:00
|
|
|
end
|
|
|
|
|
2019-02-25 15:04:38 +01:00
|
|
|
resources :groups, only: %i[index create update destroy]
|
|
|
|
resources :subscriptions, only: %i[show create update]
|
|
|
|
resources :plans, only: %i[index create update destroy show]
|
2016-03-23 18:39:41 +01:00
|
|
|
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
|
|
|
|
|
2019-02-25 15:04:38 +01:00
|
|
|
resources :invoices, only: %i[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
|
2019-07-31 12:00:52 +02:00
|
|
|
get 'first', action: 'first', on: :collection
|
2016-03-23 18:39:41 +01:00
|
|
|
end
|
|
|
|
|
2019-11-27 17:05:19 +01:00
|
|
|
resources :i_calendar, only: %i[index create destroy] do
|
2019-12-02 15:53:24 +01:00
|
|
|
get 'events', on: :member
|
2019-12-02 12:19:30 +01:00
|
|
|
post 'sync', on: :member
|
2019-11-27 17:05:19 +01:00
|
|
|
end
|
2019-11-26 13:44:43 +01:00
|
|
|
|
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]
|
2018-12-03 10:22:10 +01:00
|
|
|
resources :custom_assets, only: %i[show create update]
|
2016-03-23 18:39:41 +01:00
|
|
|
resources :tags
|
|
|
|
resources :stylesheets, only: [:show]
|
|
|
|
resources :auth_providers do
|
|
|
|
get 'mapping_fields', on: :collection
|
|
|
|
get 'active', action: 'active', on: :collection
|
2016-12-15 14:16:24 +01:00
|
|
|
post 'send_code', action: 'send_code', on: :collection
|
2016-03-23 18:39:41 +01:00
|
|
|
end
|
2019-05-09 18:27:19 +02:00
|
|
|
resources :abuses, only: %i[index create destroy]
|
2018-12-03 10:22:10 +01:00
|
|
|
resources :open_api_clients, only: %i[index create update destroy] do
|
2016-05-09 18:15:04 +02:00
|
|
|
patch :reset_token, on: :member
|
|
|
|
end
|
2016-08-24 12:30:48 +02:00
|
|
|
resources :price_categories
|
2017-02-13 17:00:27 +01:00
|
|
|
resources :spaces
|
2019-01-07 15:33:09 +01:00
|
|
|
resources :accounting_periods do
|
2019-01-07 17:21:32 +01:00
|
|
|
get 'last_closing_end', on: :collection
|
2019-02-25 17:22:54 +01:00
|
|
|
get 'archive', action: 'download_archive', on: :member
|
2019-01-07 15:33:09 +01:00
|
|
|
end
|
2019-07-30 11:43:51 +02:00
|
|
|
# export accounting data to csv or equivalent
|
|
|
|
post 'accounting/export' => 'accounting_exports#export'
|
2016-03-23 18:39:41 +01:00
|
|
|
|
|
|
|
# i18n
|
2018-12-03 10:22:10 +01:00
|
|
|
# regex allows using dots in URL for 'state'
|
2019-02-25 15:04:38 +01:00
|
|
|
get 'translations/:locale/:state' => 'translations#show', :constraints => { state: %r{[^/]+} }
|
2016-07-27 11:28:54 +02:00
|
|
|
|
|
|
|
# XLSX exports
|
|
|
|
get 'exports/:id/download' => 'exports#download'
|
2016-07-27 15:42:29 +02:00
|
|
|
post 'exports/status' => 'exports#status'
|
2016-09-22 16:46:14 +02:00
|
|
|
|
2019-09-25 16:37:42 +02:00
|
|
|
# Members CSV import
|
|
|
|
resources :imports, only: [:show] do
|
|
|
|
post 'members', action: 'members', on: :collection
|
|
|
|
end
|
|
|
|
|
2016-09-22 16:46:14 +02:00
|
|
|
# Fab-manager's version
|
2020-04-14 11:39:26 +02:00
|
|
|
post 'version' => 'version#show'
|
2019-09-05 16:17:02 +02:00
|
|
|
|
|
|
|
# payments handling
|
|
|
|
post 'payments/confirm_payment' => 'payments/confirm_payment'
|
2020-01-15 12:48:55 +01:00
|
|
|
|
|
|
|
# FabAnalytics
|
|
|
|
get 'analytics/data' => 'analytics#data'
|
2016-03-23 18:39:41 +01:00
|
|
|
end
|
|
|
|
|
2016-09-29 10:53:20 +02:00
|
|
|
# rss
|
|
|
|
|
|
|
|
namespace :rss, as: nil, defaults: { format: :xml } do
|
2016-09-29 11:54:08 +02:00
|
|
|
resources :projects, only: [:index], as: 'rss_projects'
|
|
|
|
resources :events, only: [:index], as: 'rss_events'
|
2016-09-29 10:53:20 +02:00
|
|
|
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
|
|
|
|
|
2018-12-03 10:22:10 +01:00
|
|
|
%w[account event machine project subscription training user space].each do |path|
|
2016-03-23 18:39:41 +01:00
|
|
|
post "/stats/#{path}/_search", to: "api/statistics##{path}"
|
2016-07-04 17:15:37 +02:00
|
|
|
post "/stats/#{path}/export", to: "api/statistics#export_#{path}"
|
2015-05-05 03:10:25 +02:00
|
|
|
end
|
2018-12-03 10:22:10 +01:00
|
|
|
post '/stats/global/export', to: 'api/statistics#export_global'
|
|
|
|
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
|
|
|
|
|
2019-02-25 15:04:38 +01:00
|
|
|
authenticate :user, ->(u) { u.admin? } do
|
2015-05-05 03:10:25 +02:00
|
|
|
mount Sidekiq::Web => '/admin/sidekiq'
|
|
|
|
end
|
|
|
|
|
2020-01-13 17:05:53 +01:00
|
|
|
get 'health' => 'health#status'
|
|
|
|
|
2016-05-05 15:02:02 +02:00
|
|
|
apipie
|
2015-05-05 03:10:25 +02:00
|
|
|
end
|