VRFS-3359 : API and REST for languages and subjects

This commit is contained in:
Steven Miers 2015-08-17 14:08:03 -05:00
parent 6edb4b6012
commit dd98f3bf2e
4 changed files with 52 additions and 0 deletions

View File

@ -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;

View File

@ -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

View File

@ -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

View File

@ -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'