2019-02-25 15:04:38 +01:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2020-06-09 18:51:57 +02:00
|
|
|
require 'sidekiq_unique_jobs/web'
|
2022-03-09 14:33:50 +01:00
|
|
|
require 'sidekiq-scheduler/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
|
|
|
|
|
2022-04-13 15:50:33 +02:00
|
|
|
devise_scope :user do
|
|
|
|
get '/sessions/sign_out', to: 'devise/sessions#destroy'
|
2022-04-26 18:05:18 +02:00
|
|
|
post '/password/verify', to: 'passwords#verify'
|
2022-04-13 15:50:33 +02: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
|
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
|
2020-06-08 15:08:07 +02:00
|
|
|
get '/is_present/:name', action: 'test_present', 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
|
2022-05-10 10:50:41 +02:00
|
|
|
get 'current', action: 'current', 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
|
2022-03-18 19:44:30 +01:00
|
|
|
patch ':id/validate', action: 'validate', on: :collection
|
2015-05-05 03:10:25 +02:00
|
|
|
end
|
2021-05-19 18:12:52 +02:00
|
|
|
resources :reservations, only: %i[show index update]
|
2019-02-25 15:04:38 +01:00
|
|
|
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
|
|
|
|
2021-12-21 17:13:40 +01:00
|
|
|
resources :prices, only: %i[create index update destroy] do
|
2016-03-23 18:39:41 +01:00
|
|
|
post 'compute', on: :collection
|
|
|
|
end
|
2021-06-21 17:39:48 +02:00
|
|
|
resources :prepaid_packs
|
2021-06-18 17:40:06 +02:00
|
|
|
resources :coupons do
|
|
|
|
post 'validate', action: 'validate', on: :collection
|
|
|
|
post 'send', action: 'send_to', on: :collection
|
|
|
|
end
|
2021-06-29 11:14:36 +02:00
|
|
|
resources :user_packs, only: %i[index]
|
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]
|
2021-10-18 10:15:48 +02:00
|
|
|
resources :subscriptions, only: %i[show] do
|
2021-10-08 19:14:47 +02:00
|
|
|
get 'payment_details', action: 'payment_details', on: :member
|
|
|
|
end
|
2021-06-08 16:32:19 +02:00
|
|
|
resources :plan_categories
|
2021-06-10 14:06:53 +02:00
|
|
|
resources :plans do
|
|
|
|
get 'durations', on: :collection
|
|
|
|
end
|
2022-07-12 17:46:01 +02:00
|
|
|
resources :slots_reservations, only: [:update] do
|
2016-03-23 18:39:41 +01:00
|
|
|
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
|
|
|
|
|
2022-01-17 12:38:53 +01:00
|
|
|
resources :payment_schedules, only: %i[index show update] do
|
2021-01-25 17:42:30 +01:00
|
|
|
post 'list', action: 'list', on: :collection
|
2021-02-09 15:44:56 +01:00
|
|
|
put 'cancel', on: :member
|
2020-12-30 18:39:46 +01:00
|
|
|
get 'download', on: :member
|
2022-01-03 11:24:08 +01:00
|
|
|
get 'items/:id', action: 'show_item', on: :collection
|
2021-02-04 17:51:16 +01:00
|
|
|
post 'items/:id/cash_check', action: 'cash_check', on: :collection
|
2022-01-05 15:58:33 +01:00
|
|
|
post 'items/:id/confirm_transfer', action: 'confirm_transfer', on: :collection
|
2021-02-08 15:28:47 +01:00
|
|
|
post 'items/:id/refresh_item', action: 'refresh_item', on: :collection
|
2021-02-09 12:09:26 +01:00
|
|
|
post 'items/:id/pay_item', action: 'pay_item', on: :collection
|
2020-12-30 18:39:46 +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
|
|
|
|
2022-03-18 19:44:30 +01:00
|
|
|
resources :proof_of_identity_types
|
|
|
|
resources :proof_of_identity_files, only: %i[index show create update] do
|
|
|
|
get 'download', on: :member
|
|
|
|
end
|
|
|
|
resources :proof_of_identity_refusals, only: %i[index show create]
|
|
|
|
|
|
|
|
resources :profile_custom_fields
|
|
|
|
|
2022-07-12 17:30:33 +02:00
|
|
|
resources :product_categories do
|
|
|
|
patch 'position', on: :member
|
|
|
|
end
|
2022-07-11 19:17:36 +02:00
|
|
|
|
2022-09-08 17:51:48 +02:00
|
|
|
resources :products do
|
2022-10-11 18:53:12 +02:00
|
|
|
put 'clone', on: :member
|
2022-09-08 17:51:48 +02:00
|
|
|
get 'stock_movements', on: :member
|
|
|
|
end
|
2022-08-19 19:59:13 +02:00
|
|
|
resources :cart, only: %i[create] do
|
|
|
|
put 'add_item', on: :collection
|
|
|
|
put 'remove_item', on: :collection
|
|
|
|
put 'set_quantity', on: :collection
|
2022-09-08 15:10:56 +02:00
|
|
|
put 'set_offer', on: :collection
|
2022-09-27 19:44:39 +02:00
|
|
|
put 'refresh_item', on: :collection
|
|
|
|
post 'validate', on: :collection
|
2022-08-25 08:52:17 +02:00
|
|
|
end
|
|
|
|
resources :checkout, only: %i[] do
|
|
|
|
post 'payment', on: :collection
|
|
|
|
post 'confirm_payment', on: :collection
|
2022-08-19 19:59:13 +02:00
|
|
|
end
|
2022-10-05 12:06:35 +02:00
|
|
|
resources :orders, except: %i[create] do
|
|
|
|
get 'withdrawal_instructions', on: :member
|
|
|
|
end
|
2022-07-13 15:06:46 +02: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
|
2022-06-29 14:15:36 +02:00
|
|
|
resources :credits do
|
|
|
|
get 'user/:id/:resource', action: :user_resource, on: :collection
|
|
|
|
end
|
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
|
2022-04-12 15:20:10 +02:00
|
|
|
get 'strategy_name', action: 'strategy_name', 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
|
|
|
|
2021-04-12 10:45:41 +02:00
|
|
|
# card payments handling
|
|
|
|
## Stripe gateway
|
|
|
|
post 'stripe/confirm_payment' => 'stripe/confirm_payment'
|
|
|
|
get 'stripe/online_payment_status' => 'stripe/online_payment_status'
|
|
|
|
get 'stripe/setup_intent/:user_id' => 'stripe#setup_intent'
|
2021-10-07 17:07:46 +02:00
|
|
|
post 'stripe/setup_subscription' => 'stripe/setup_subscription'
|
2021-10-06 17:09:35 +02:00
|
|
|
post 'stripe/confirm_subscription' => 'stripe#confirm_subscription'
|
2021-04-12 10:45:41 +02:00
|
|
|
post 'stripe/update_card' => 'stripe#update_card'
|
|
|
|
|
|
|
|
## PayZen gateway
|
|
|
|
post 'payzen/sdk_test' => 'payzen#sdk_test'
|
|
|
|
post 'payzen/create_payment' => 'payzen#create_payment'
|
2021-04-13 17:16:05 +02:00
|
|
|
post 'payzen/confirm_payment' => 'payzen#confirm_payment'
|
2021-06-01 12:20:02 +02:00
|
|
|
post 'payzen/confirm_payment_schedule' => 'payzen#confirm_payment_schedule'
|
2021-04-14 17:56:04 +02:00
|
|
|
post 'payzen/check_hash' => 'payzen#check_hash'
|
2021-04-22 19:24:08 +02:00
|
|
|
post 'payzen/create_token' => 'payzen#create_token'
|
2021-06-04 18:26:20 +02:00
|
|
|
post 'payzen/update_token' => 'payzen#update_token'
|
2022-06-07 16:55:24 +02:00
|
|
|
post 'payzen/check_cart' => 'payzen#check_cart'
|
2020-01-15 12:48:55 +01:00
|
|
|
|
2021-05-19 18:12:52 +02:00
|
|
|
# local payments handling
|
|
|
|
post 'local_payment/confirm_payment' => 'local_payment#confirm_payment'
|
|
|
|
|
2020-01-15 12:48:55 +01:00
|
|
|
# FabAnalytics
|
|
|
|
get 'analytics/data' => 'analytics#data'
|
2020-06-03 16:25:13 +02:00
|
|
|
|
|
|
|
# test MIME type
|
|
|
|
post 'files/mime_type' => 'files#mime'
|
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
|
2022-08-30 12:58:44 +02:00
|
|
|
resources :plans, only: %i[index show]
|
2022-08-30 13:11:08 +02:00
|
|
|
resources :plan_categories
|
2022-08-30 14:16:49 +02:00
|
|
|
resources :prices
|
2016-05-04 18:17:50 +02:00
|
|
|
resources :users
|
|
|
|
resources :trainings
|
|
|
|
resources :user_trainings
|
|
|
|
resources :reservations
|
2021-02-01 17:43:15 +01:00
|
|
|
resources :machines, only: %i[index create update show destroy]
|
2022-08-30 12:18:09 +02:00
|
|
|
resources :spaces, only: %i[index show]
|
2016-05-04 18:17:50 +02:00
|
|
|
resources :bookable_machines
|
|
|
|
resources :invoices do
|
|
|
|
get :download, on: :member
|
|
|
|
end
|
|
|
|
resources :events
|
|
|
|
resources :availabilities
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2022-10-11 17:23:45 +02:00
|
|
|
%w[account event machine project subscription training user space order].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
|
|
|
|
2022-08-30 12:18:09 +02:00
|
|
|
get '/project_collaborator/:valid_token', to: 'api/projects#collaborator_valid'
|
2015-05-05 03:10:25 +02:00
|
|
|
|
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
|