1
0
mirror of https://github.com/LaCasemate/fab-manager.git synced 2024-12-16 01:24:03 +01:00
fab-manager/config/routes.rb

324 lines
11 KiB
Ruby
Raw Normal View History

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'
require 'sidekiq-scheduler/web'
2015-05-05 03:10:25 +02:00
Rails.application.routes.draw do
2023-03-29 18:01:16 +02:00
if Rails.configuration.auth_provider.providable_type == 'DatabaseProvider'
2020-03-30 15:32:14 +02:00
# with local authentication we do not use omniAuth so we must differentiate the config
devise_for :users, controllers: {
registrations: 'registrations', sessions: 'sessions', confirmations: 'confirmations', passwords: 'passwords'
}
2016-03-23 18:39:41 +01:00
else
devise_for :users, controllers: {
registrations: 'registrations', sessions: 'sessions', confirmations: 'confirmations', passwords: 'passwords',
omniauth_callbacks: 'users/omniauth_callbacks'
}
get '/sso-redirect', to: 'application#sso_redirect', as: :sso_redirect
2016-03-23 18:39:41 +01:00
end
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'
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
2023-06-29 16:37:16 +02:00
get :markdown, on: :member
2015-05-05 03:10:25 +02:00
end
resources :openlab_projects, only: :index
2015-05-05 03:10:25 +02:00
resources :machines
2022-12-16 18:43:38 +01:00
resources :machine_categories
2015-05-05 03:10:25 +02:00
resources :components
resources :themes
resources :licences
2023-01-16 17:37:44 +01:00
resources :statuses
2023-06-29 08:47:42 +02:00
resources :project_categories
2019-02-25 15:04:38 +01:00
resources :admins, only: %i[index create destroy]
resources :settings, only: %i[show update index], param: :name do
patch '/bulk_update', action: 'bulk_update', on: :collection
put '/reset/:name', action: 'reset', on: :collection
get '/is_present/:name', action: 'test_present', on: :collection
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
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
get 'search/:query', action: 'search', on: :collection
get 'mapping', action: 'mapping', on: :collection
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
patch ':id/validate', action: 'validate', on: :collection
2015-05-05 03:10:25 +02:00
end
resources :reservations, only: %i[show index update] do
post :confirm_payment, on: :collection
end
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
get 'polling', action: 'polling', on: :collection
get 'last_unread', action: 'last_unread', on: :collection
2015-05-05 03:10:25 +02:00
end
resources :notification_types, only: %i[index]
resources :notification_preferences, only: %i[index update], param: :notification_type do
patch '/bulk_update', action: 'bulk_update', on: :collection
end
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
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
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
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
get 'public', on: :collection
2017-03-02 12:34:28 +01:00
get '/export_index', action: 'export_availabilities', on: :collection
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
2023-01-03 17:17:39 +01:00
patch 'cancel', on: :member
2021-10-08 19:14:47 +02:00
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
put 'validate', on: :member
put 'invalidate', on: :member
2016-03-23 18:39:41 +01:00
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
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
resources :payment_schedules, only: %i[index show update] do
post 'list', action: 'list', on: :collection
put 'cancel', on: :member
get 'download', on: :member
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
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
end
2019-11-27 17:05:19 +01:00
resources :i_calendar, only: %i[index create destroy] do
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
resources :supporting_document_types
resources :supporting_document_files, only: %i[index show create update] do
get 'download', on: :member
end
resources :supporting_document_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-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
put 'set_offer', on: :collection
put 'refresh_item', on: :collection
post 'validate', on: :collection
2022-12-30 15:29:52 +01:00
post 'create_item', on: :collection
put 'set_customer', 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
resources :orders, except: %i[create] do
get 'withdrawal_instructions', on: :member
end
2022-07-13 15:06:46 +02:00
2023-05-25 20:17:37 +02:00
resources :children do
patch ':id/validate', action: 'validate', on: :collection
end
2023-04-03 18:23:49 +02:00
2015-05-05 03:10:25 +02:00
# for admin
resources :trainings do
get :availabilities, on: :member
end
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
post 'send_code', action: 'send_code', on: :collection
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
resources :spaces
resources :accounting_periods do
get 'last_closing_end', on: :collection
get 'archive', action: 'download_archive', on: :member
end
# 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{[^/]+} }
# XLSX exports
get 'exports/:id/download' => 'exports#download'
post 'exports/status' => 'exports#status'
2019-09-25 16:37:42 +02:00
# Members CSV import
resources :imports, only: [:show] do
post 'members', action: 'members', on: :collection
end
# Fab-manager's version
2020-04-14 11:39:26 +02:00
post 'version' => 'version#show'
# 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'
post 'stripe/setup_subscription' => 'stripe/setup_subscription'
post 'stripe/confirm_subscription' => 'stripe#confirm_subscription'
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'
post 'payzen/check_hash' => 'payzen#check_hash'
post 'payzen/create_token' => 'payzen#create_token'
2021-06-04 18:26:20 +02:00
post 'payzen/update_token' => 'payzen#update_token'
post 'payzen/check_cart' => 'payzen#check_cart'
# local payments handling
post 'local_payment/confirm_payment' => 'local_payment#confirm_payment'
# FabAnalytics
get 'analytics/data' => 'analytics#data'
# 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
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 :plans, only: %i[index show]
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
resources :machines, only: %i[index create update show destroy]
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
resources :accounting
resources :subscriptions
2016-05-04 18:17:50 +02:00
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}"
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
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
get 'health' => 'health#status'
2016-05-05 15:02:02 +02:00
apipie
2015-05-05 03:10:25 +02:00
end