1
0
mirror of https://github.com/LaCasemate/fab-manager.git synced 2024-11-29 10:24:20 +01:00
fab-manager/config/routes.rb

215 lines
7.3 KiB
Ruby
Raw Normal View History

2019-02-25 15:04:38 +01:00
# frozen_string_literal: true
2015-05-05 03:10:25 +02:00
require 'sidekiq/web'
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
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
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
get :allowed_extensions
2015-05-05 03:10:25 +02:00
end
end
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]
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
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
get 'search/:query', action: 'search', on: :collection
get 'mapping', action: 'mapping', on: :collection
patch ':id/complete_tour', action: 'complete_tour', 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
get 'polling', action: 'polling', on: :collection
get 'last_unread', action: 'last_unread', on: :collection
2015-05-05 03:10:25 +02:00
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
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
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
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]
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
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
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
2015-05-05 03:10:25 +02:00
# for admin
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
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
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'
# payments handling
post 'payments/confirm_payment' => 'payments/confirm_payment'
# 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
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}"
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
get 'health' => 'health#status'
2016-05-05 15:02:02 +02:00
apipie
2015-05-05 03:10:25 +02:00
end