From d76899be5440c26b97180a8b55536d25fcc81993 Mon Sep 17 00:00:00 2001 From: Steven Miers Date: Sat, 8 Aug 2015 15:00:44 -0500 Subject: [PATCH] VRFS-3359 : Teacher profile REST functions. --- web/app/assets/javascripts/jam_rest.js | 57 +++++++++++++++++++++++++- 1 file changed, 56 insertions(+), 1 deletion(-) diff --git a/web/app/assets/javascripts/jam_rest.js b/web/app/assets/javascripts/jam_rest.js index 0f1445290..22ca5db52 100644 --- a/web/app/assets/javascripts/jam_rest.js +++ b/web/app/assets/javascripts/jam_rest.js @@ -476,6 +476,58 @@ }); } + + function getTeacher(options) { + // var url = '/api/teacher/detail' + + // if(options && _.size(options) > 0) { + // console.log("WTF"); + // url += "?" + $.param(options) + // } + + // console.log("THE URL", url) + return $.ajax({ + type: "GET", + dataType: "json", + url: '/api/teachers/detail?'+ $.param(options), + contentType: 'application/json', + processData: false + }); + } + + function deleteTeacher(teacherId) { + var url = "/api/teachers/" + teacherId; + return $.ajax({ + type: "DELETE", + dataType: "json", + url: url, + contentType: 'application/json', + processData:false + }); + } + + function updateTeacher(teacher) { + console.log("Updating teacher", teacher) + var id = teacher && teacher["id"] + var url + if (id != null && typeof(id) != 'undefined') { + url = '/api/teachers/' + teacher.id + } else { + url = '/api/teachers' + } + + var deferred = $.ajax({ + type: "POST", + dataType: "json", + url: url, + contentType: 'application/json', + processData: false, + data: JSON.stringify(teacher) + }) + + return deferred + } + function getSession(id) { var url = "/api/sessions/" + id; return $.ajax({ @@ -989,7 +1041,7 @@ type: 'GET', dataType: "json", url: "/api/feeds?" + $.param(options), - processData:false + processData:false }) } @@ -1945,6 +1997,9 @@ this.getBandPhotoFilepickerPolicy = getBandPhotoFilepickerPolicy; this.getBand = getBand; this.validateBand = validateBand; + this.getTeacher = getTeacher; + this.updateTeacher = updateTeacher; + this.deleteTeacher = deleteTeacher; this.updateFavorite = updateFavorite; this.createBandInvitation = createBandInvitation; this.updateBandInvitation = updateBandInvitation;