......@@ -102,7 +102,7 @@
*/
app.factory('CourseProfessor', ['$resource', function($resource) {
return $resource('/api/course_professor/:id', {'id':'@id'}, {
return $resource(BASE_API_URL + '/course_professor/:id', {'id':'@id'}, {
'update': {
'method': 'PUT'
}
......@@ -116,7 +116,7 @@
*/
app.factory('CourseAuthor', ['$resource', function($resource) {
return $resource('/api/course_author/:id', {'id':'@id'}, {
return $resource(BASE_API_URL + '/course_author/:id', {'id':'@id'}, {
'update': {
'method': 'PUT'
}
......@@ -129,7 +129,7 @@
* list of fields that reflects Course model in Django
*/
app.factory('Course', ['$resource', 'getRestOptions', function($resource, getRestOptions) {
var Course = $resource('/api/course/:id', {'id':'@id'});
var Course = $resource(BASE_API_URL + '/course/:id', {'id':'@id'});
Course.prototype.isDraft = function() { return this.status === 'draft'; };
Course.prototype.isListed = function() { return this.status === 'listed'; };
......@@ -150,10 +150,6 @@
};
getRestOptions('/api/course').success(function(data) {
Course.fields = angular.copy(data.actions.POST);
});
return Course;
}]);
......@@ -175,7 +171,7 @@
'method': 'PUT'
}
};
var Professor = $resource('/api/user/:id', {'id':'@id'}, resourceConfig);
var Professor = $resource(BASE_API_URL + '/user/:id', {'id':'@id'}, resourceConfig);
Professor.prototype.getName = function() {
var name = this.name;
if(!name && (this.first_name || this.last_name)) {
......@@ -194,7 +190,7 @@
var resourceConfig = {
'update': {'method': 'PUT'}
};
var Lesson = $resource('/api/lessons/:id', {'id':'@id'}, resourceConfig);
var Lesson = $resource(BASE_API_URL + '/lessons/:id', {'id':'@id'}, resourceConfig);
Lesson.prototype.countVideos = function() {
return (this.units || []).reduce(function(c, u){
return u.video ? c + 1 : c;
......@@ -217,7 +213,7 @@
*/
app.factory('SimpleLesson', ['$resource', function($resource){
var resourceConfig = {};
var SimpleLesson = $resource('/api/simple_lessons/:id', {'id':'@id'}, resourceConfig);
var SimpleLesson = $resource(BASE_API_URL + '/simple_lessons/:id', {'id':'@id'}, resourceConfig);
SimpleLesson.prototype.countVideos = function() {
return (this.units || []).reduce(function(c, u){
return u.video ? c + 1 : c;
......@@ -235,19 +231,19 @@
}]);
app.factory('CourseStudent', function($resource){
return $resource('/api/course_student/:id',
return $resource(BASE_API_URL + '/course_student/:id',
{'id' : '@id'},
{'update': {'method': 'PUT'} });
});
app.factory('CertificationProcess', function($resource){
return $resource('/api/certification_process/:certificateId',
return $resource(BASE_API_URL + '/certification_process/:certificateId',
{'certificateId' : '@id'},
{'update': {'method': 'PUT'} });
});
app.factory('CourseCertification', function($resource){
return $resource('/api/course_certification/:link_hash',
return $resource(BASE_API_URL + '/course_certification/:link_hash',
{'link_hash' : '@id' },
{'update': {'method': 'PUT'} });
});
......@@ -256,13 +252,13 @@
* Basic model class to Evaluation
*/
app.factory('Evaluation', function($resource){
return $resource('/api/evaluation/:id', {'id' : '@id'}, {
return $resource(BASE_API_URL + '/evaluation/:id', {'id' : '@id'}, {
'update': {'method': 'PUT'}
});
});
app.factory('CertificateTemplate', function($resource){
return $resource('/api/certificate_template/:course', {}, {
return $resource(BASE_API_URL + '/certificate_template/:course', {}, {
'update' : {'method' : 'PUT'},
});
});
......@@ -292,7 +288,7 @@
*/
app.factory('StudentSearch', ['$http', function($http){
return function(val, course_id) {
return $http.get('/api/student_search', {
return $http.get(BASE_API_URL + '/student_search', {
params: {
name: val,
course: course_id,
......@@ -325,7 +321,7 @@
*/
app.factory('UserSearch', ['$http', function($http){
return function(val, course_id) {
return $http.get('/api/user_search', {
return $http.get(BASE_API_URL + '/user_search', {
params: {
name: val,
sensor: false
......@@ -353,7 +349,7 @@
app.factory('Class', function($resource){
return $resource('/api/course_classes/:id', {'id' : '@id'}, {
return $resource(BASE_API_URL + '/course_classes/:id', {'id' : '@id'}, {
'update': {'method': 'PUT'}
});
});
......
......@@ -9,16 +9,14 @@
'directive.waiting-screen',
'directive.alertPopup',
'directive.contenteditable',
'directive.codemirror',
'core.services',
'directive.fixedBar',
'directive.markdowneditor',
// 'directive.sortable',
// 'filters.text',
'youtube',
'header',
'ui.bootstrap',
'discussion.services',
// 'discussion.services',
'ngFileUpload',
'ui.tinymce',
]);
......
......@@ -14,9 +14,8 @@
'youtubePlayerApi',
'MarkdownDirective',
'waitingScreen',
'Forum',
function($scope, $location, Course, CourseProfessor, Lesson, LessonUpdate, Unit, VideoData, youtubePlayerApi,
MarkdownDirective, waitingScreen, Forum) {
MarkdownDirective, waitingScreen) {
$scope.errors = {};
var httpErrors = {
'400': 'Os campos não foram preenchidos corretamente.',
......@@ -290,28 +289,28 @@
expected = [];
}
if(type === 'discussion'){
// if(type === 'discussion'){
// JSON pattern for the discussion type of activities
$scope.currentActivity = {
'type': type,
'data': {
'forum': null,
'content': '',
'start_date': null,
'end_date': null
},
'expected': ''
};
// Create a new forum to recieve the students answers
var new_forum = new Forum();
new_forum.title = 'Fórum de atividades: ' + $scope.lesson.name;
new_forum.forum_type = 'activity';
new_forum.$save(function(forum) {
$scope.currentActivity.data.forum = forum.id;
});
} else {
// $scope.currentActivity = {
// 'type': type,
// 'data': {
// 'forum': null,
// 'content': '',
// 'start_date': null,
// 'end_date': null
// },
// 'expected': ''
// };
// // Create a new forum to recieve the students answers
// var new_forum = new Forum();
// new_forum.title = 'Fórum de atividades: ' + $scope.lesson.name;
// new_forum.forum_type = 'activity';
// new_forum.$save(function(forum) {
// $scope.currentActivity.data.forum = forum.id;
// });
// } else {
// JSON pattern for other types of activities
$scope.currentActivity = {
'type': type,
......@@ -323,7 +322,7 @@
},
'expected': expected
};
}
// }
$scope.currentUnit.activities.push($scope.currentActivity);
$scope.newActivityType = null;
......@@ -388,7 +387,7 @@
}
Upload.upload({
url: '/api/activity_image' + id,
url: BASE_API_URL + '/activity_image' + id,
method: upload_method,
data: {image: $scope.image_up},
}).then(function(response){
......@@ -403,7 +402,7 @@
$scope.deleteThumb = function() {
if ($scope.course.id) {
Upload.upload({
url: '/api/activity_image/' + $scope.currentActivity.id,
url: BASE_API_URL + '/activity_image/' + $scope.currentActivity.id,
method: 'PUT',
data: {image: ''},
}).then(function(response){
......
......@@ -4,7 +4,7 @@
var app = angular.module('admin.lesson.services', []);
app.factory('Unit', ['$resource', function($resource){
return $resource('/api/unit/:id/');
return $resource(BASE_API_URL + '/unit/:id/');
}]);
/**
......@@ -13,7 +13,7 @@
*/
app.factory('SimpleLesson', ['$resource', function($resource){
var resourceConfig = {};
var SimpleLesson = $resource('/api/simple_lessons/:id', {'id':'@id'}, resourceConfig);
var SimpleLesson = $resource('/legacy/api/simple_lessons/:id', {'id':'@id'}, resourceConfig);
return SimpleLesson;
}]);
......
......@@ -4,33 +4,33 @@
var module = angular.module('messages.services', ['ngRoute', 'ngResource']);
module.factory('Message', function($resource){
return $resource('/api/professor_message/:messageId', {}, {
return $resource(BASE_API_URL + '/professor_message/:messageId', {}, {
update: {method: 'PUT'}
});
});
module.factory('MessageGlobal', function($resource){
return $resource('/api/professor_message_global/:messageId', {}, {
return $resource(BASE_API_URL + '/professor_message_global/:messageId', {}, {
update: {method: 'PUT'}
});
});
module.factory('MessageRead', function($resource){
return $resource('/api/professor_message_read/:message', {}, {
return $resource(BASE_API_URL + '/professor_message_read/:message', {}, {
});
});
module.factory('User', function($resource){
return $resource('/api/user/:userId', {}, {
return $resource(BASE_API_URL + '/user/:userId', {}, {
});
});
module.factory('Group', function($resource){
return $resource('/api/group/:groupId', {}, {
return $resource(BASE_API_URL + '/group/:groupId', {}, {
});
});
module.factory('Student', function($resource){
return $resource('/api/course_student/', {}, {});
return $resource(BASE_API_URL + '/course_student/', {}, {});
});
})(angular);
......@@ -15,6 +15,5 @@
'youtube',
'markdown',
'ui.bootstrap',
'header',
]);
})(window.angular);
......@@ -75,9 +75,6 @@
var messages = [];
for(var att in response.data) {
var message = response.data[att];
if(Course.fields && Course.fields[att]) {
message = Course.fields[att].label + ': ' + message;
}
messages.push(message);
}
$scope.alert.error('Encontramos alguns erros!', messages, true);
......@@ -92,7 +89,7 @@
var fu = new FormUpload();
fu.addField('thumbnail', $scope.thumbfile);
// return a new promise that file will be uploaded
return fu.sendTo('/api/coursethumbs/' + $scope.course.id)
return fu.sendTo(BASE_API_URL + '/coursethumbs/' + $scope.course.id)
.then(function(){
$scope.alert.success('A imagem atualizada.');
});
......@@ -108,7 +105,7 @@
var fu = new FormUpload();
fu.addField('home_thumbnail', $scope.home_thumbfile);
// return a new promise that file will be uploaded
return fu.sendTo('/api/coursethumbs/' + $scope.course.id)
return fu.sendTo(BASE_API_URL + '/coursethumbs/' + $scope.course.id)
.then(function(){
$scope.alert.success('A imagem atualizada.');
});
......@@ -116,7 +113,7 @@
};
$scope.export_course = function() {
$window.open('/admin/course/' + $scope.course_id + '/export/', '_blank', '');
$window.open('/legacy/admin/course/' + $scope.course_id + '/export/', '_blank', '');
};
$scope.saveCourse = function() {
......@@ -158,7 +155,7 @@
$scope.course.$delete()
.then(function(){
document.location.href = '/admin/courses';
document.location.href = '/legacy/admin/courses';
});
};
......@@ -220,7 +217,7 @@
if (course_professor_picture_file){
// return a new promise that file will be uploaded
fu.sendTo('/api/course_professor_picture/' + course_professor.id)
fu.sendTo(BASE_API_URL + '/course_professor_picture/' + course_professor.id)
.then(function(response){
course_professor.get_picture_url = '/media/' + response.data.picture;
course_professor.picture = '/media/' + response.data.picture;
......@@ -237,7 +234,7 @@
course_professor.$update({id: course_professor.id}, function (){
if (course_professor_picture_file){
// return a new promise that file will be uploaded
fu.sendTo('/api/course_professor_picture/' + course_professor.id)
fu.sendTo(BASE_API_URL + '/course_professor_picture/' + course_professor.id)
.then(function(response){
course_professor.get_picture_url = '/media/' + response.data.picture;
course_professor.picture = '/media/' + response.data.picture;
......@@ -342,7 +339,7 @@
};
$scope.getUsers = function(val) {
return $http.get('/api/user_search', {
return $http.get(BASE_API_URL + '/user_search', {
params: {
name: val,
sensor: false
......