-
-
Notifications
You must be signed in to change notification settings - Fork 25
Expand file tree
/
Copy pathroutes.rb
More file actions
126 lines (100 loc) · 4.34 KB
/
Copy pathroutes.rb
File metadata and controls
126 lines (100 loc) · 4.34 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
Rails.application.routes.draw do
Mumukit::Login.configure_login_routes! self
Mumukit::Platform.map_organization_routes!(self) do
root to: 'book#show'
concern :debatable do |options|
resources :discussions, options.merge(only: [:index, :new, :show, :create, :update, :destroy]) do
post :subscription, on: :member
post :upvote, on: :member
end
end
get '/discussions/terms' => 'book_discussions#terms'
concerns :debatable, controller: 'book_discussions', only: :index
resources :discussions, only: [] do
resources :messages, only: [:create, :destroy], controller: 'discussions_messages' do
post :approve, on: :member
post :question, on: :member
end
end
resources :exam_registrations, only: [:show]
resources :exam_authorization_requests, only: [:show, :create, :update]
resources :book, only: [:show]
resources :chapters, only: [:show] do
concerns :debatable, debatable_class: 'Chapter'
resource :appendix, only: :show
end
# All users
resources :exercises, only: :show do
# Current user
resources :confirmations, controller: 'exercise_confirmations', only: :create
resources :solutions, controller: 'exercise_solutions', only: :create
resources :queries, controller: 'exercise_query', only: :create
resources :tries, controller: 'exercise_tries', only: :create
end
resources :exercises, only: :show do
concerns :debatable, debatable_class: 'Exercise'
end
# All users
resources :guides, only: :show do
resource :progress, controller: 'guide_progress', only: :destroy
end
resources :lessons, only: :show do
concerns :debatable, debatable_class: 'Lesson'
end
resources :complements, only: :show
resources :exams, only: :show
# Current user
resource :user, only: [:show, :edit, :update] do
get :terms
post :terms, to: 'users#accept_profile_terms'
# Notification subscriptions
get :unsubscribe
get :messages
get :discussions
get :certificates
get :delete_request
post :delete_request, to: 'users#send_delete_confirmation_email'
get :delete_confirmation_invalid
get :delete_confirmation
post :delete_confirmation, to: 'users#disable'
end
resources :faqs, only: [:index]
resources :messages, only: [:index, :create]
get '/messages/errors' => 'messages#errors'
get 'certificates/verify/:code', to: 'certificates#verify', as: :verify_certificate
get 'certificates/download/:code', to: 'certificates#download', as: :download_certificate
# Routes by slug
get '/guides/:organization/:repository' => 'guides#show_transparently', as: :transparent_guide
get '/topics/:organization/:repository' => 'topics#show_transparently', as: :transparent_topic
get '/exercises/:organization/:repository/:bibliotheca_id' => 'exercises#show_transparently', as: :transparent_exercise
# Join to course
get '/join/:code' => 'invitations#show', as: :invitation
post '/join/:code' => 'invitations#join'
# Route for reading messages
post '/messages/read_messages/:exercise_id' => 'messages#read_messages', as: :read_messages
# Organizations assets
get '/theme_stylesheet' => 'assets#theme_stylesheet'
get '/extension_javascript' => 'assets#extension_javascript'
namespace :api do
organization_regexp = Regexp.new Mumukit::Platform::Organization.valid_name_regex
uid_regexp = /[^\/]+/
resources :users, only: [:create, :update], constraints: {id: uid_regexp}
resources :organizations,
only: [:index, :show, :create, :update],
constraints: {id: organization_regexp}
resources :courses, only: [:create]
constraints(uid: uid_regexp, organization: organization_regexp) do
'/courses/:organization/:course'.tap do |it|
post "#{it}/students" => 'students#create'
post "#{it}/students/:uid/attach" => 'students#attach'
post "#{it}/students/:uid/detach" => 'students#detach'
post "#{it}/teachers" => 'teachers#create'
post "#{it}/teachers/:uid/attach" => 'teachers#attach'
post "#{it}/teachers/:uid/detach" => 'teachers#detach'
end
end
end
end
#Rescue not found routes
get '*not_found', to: 'application#not_found'
end