diff --git a/web/app/assets/javascripts/jam_rest.js b/web/app/assets/javascripts/jam_rest.js index 87f964575..2256520f9 100644 --- a/web/app/assets/javascripts/jam_rest.js +++ b/web/app/assets/javascripts/jam_rest.js @@ -702,6 +702,20 @@ }); } + function getSubjects(options) { + return $.ajax('/api/subjects', { + data: { }, + dataType: 'json' + }); + } + + function getLanguages(options) { + return $.ajax('/api/languages', { + data: { }, + dataType: 'json' + }); + } + function updateUdpReachable(options) { var id = getId(options); @@ -1927,6 +1941,8 @@ this.getResolvedLocation = getResolvedLocation; this.getInstruments = getInstruments; this.getGenres = getGenres; + this.getSubjects = getSubjects; + this.getLanguages = getLanguages; this.updateUdpReachable = updateUdpReachable; this.updateNetworkTesting = updateNetworkTesting; this.updateAvatar = updateAvatar; diff --git a/web/app/controllers/api_languages_controller.rb b/web/app/controllers/api_languages_controller.rb new file mode 100644 index 000000000..9e5c3fa8c --- /dev/null +++ b/web/app/controllers/api_languages_controller.rb @@ -0,0 +1,15 @@ +class ApiLanguagesController < ApiController + + respond_to :json + + def index + @languages = Language.order(:description) + end + + def show + @language = Language.find(params[:id]) + gon.language_id = @language.id + gon.description = @language.description + end + +end diff --git a/web/app/controllers/api_subjects_controller.rb b/web/app/controllers/api_subjects_controller.rb new file mode 100644 index 000000000..8a343ce10 --- /dev/null +++ b/web/app/controllers/api_subjects_controller.rb @@ -0,0 +1,15 @@ +class ApiSubjectsController < ApiController + + respond_to :json + + def index + @subjects = Subject.order(:description) + end + + def show + @subject = Subject.find(params[:id]) + gon.subject_id = @subject.id + gon.description = @subject.description + end + +end diff --git a/web/config/routes.rb b/web/config/routes.rb index 77c641200..e575ee465 100644 --- a/web/config/routes.rb +++ b/web/config/routes.rb @@ -272,6 +272,12 @@ SampleApp::Application.routes.draw do # genres match '/genres' => 'api_genres#index', :via => :get + # language + match '/languages' => 'api_languages#index', :via => :get + + # subjects + match '/subjects' => 'api_subjects#index', :via => :get + # users match '/users/isp_scoring' => 'api_users#isp_scoring', :via => :post , :as => 'isp_scoring'