Merge branch 'hotfix/adding_course_26-02-19' into 'master'

Добавление курса выдает 500 (26.02, https://goo.gl/KTKkAL, https://goo.gl/D2S2Gv)

See merge request lilschool/site!271
remotes/origin/feature/links-page
Danil 7 years ago
commit c6ee6638a0
  1. 26
      web/src/components/CourseRedactor.vue
  2. 15
      web/src/js/modules/api.js

@ -528,8 +528,7 @@
api.saveCourse(this.course, this.accessToken)
.then((response) => {
this.courseSaving = false;
this.course = api.convertCourseJson(response.data);
this.course.live = this.live;
this.processCourseJson(response.data);
})
.catch((err) => {
this.courseSaving = false;
@ -804,10 +803,7 @@
.catch((err) => {
this.courseSyncHook = false;
this.courseSaving = false;
//console.error(err);
this.changeSavingStatus(true, true);
// alert('Произошло что-то страшное: '+err.toString());
//console.log(err.response.data);
if(err.response) {
for(let i in err.response.data) {
if(typeof err.response.data[i] === "array") {
@ -959,19 +955,7 @@
}
});
// if (this.courseId) {
// this.loadCourse().then(()=>{this.updateViewSection(window.location, 'load')}).catch(()=>{
// this.updateViewSection(window.location, 'load err')
// })
// } else {
// this.loadCourseDraft().then(()=>{this.updateViewSection(window.location, 'load draft')}).catch(()=>{
// this.updateViewSection(window.location, 'load draft err')
// });
// }
//console.log('wait promises');
Promise.all(promises.map(p => p.catch(e => e))).then(()=>{
//console.log('promises end');
this.mounting = false;
let load;
if (this.courseId) {
@ -987,9 +971,6 @@
this.updateViewSection(window.location, 'load err '+this.courseId)
})
});
//console.log('mounted end');
// this.updateViewSection(window.location);
},
computed: {
displayPrice: {
@ -1019,17 +1000,12 @@
watch: {
'course': {
handler: function (newValue, oldValue) {
// //console.log('watch', JSON.stringify(newValue), JSON.stringify(oldValue));
// Если курс загрузился и есть ID - делаем кнопки превью и публикации активными
//console.log('newValue.id', newValue.id);
if (newValue.id) {
// //console.log('newValue.id disabled remove', newValue.id);
$('#course-redactor__preview-button').removeAttr('disabled');
$('#course-redactor__publish-button').removeAttr('disabled');
}
// //console.log('courseSyncHook', this.courseSyncHook);
if (this.courseSyncHook || this.courseLoading) {
//console.log('abort save draft', this.courseSyncHook, this.courseLoading);
return;
}
this.saveCourseDraft(newValue, oldValue);

@ -90,7 +90,7 @@ export const api = {
});
},
saveCourse: (courseObject, accessToken) => {
const isAdding = (!courseObject.hasOwnProperty('id') || !courseObject.hasOwnProperty('id'));
const isAdding = !courseObject.id;
let deferredStart = null;
if (courseObject.is_deferred) {
@ -114,7 +114,7 @@ export const api = {
access_duration: courseObject.is_paid && courseObject.access_duration || 0,
is_featured: courseObject.is_featured,
slug: (courseObject.slug || '').toLowerCase(),
date: (courseObject.date) ? courseObject.date.value:null,
date: (courseObject.date) ? courseObject.date.value : null,
stream: courseObject.stream,
cover: courseObject.coverImageId ? courseObject.coverImageId : null,
gallery: {
@ -212,14 +212,14 @@ export const api = {
},
convertContentJson: (contentJson, forSaving) => {
if(forSaving){
return contentJson.map((block, index) => {
let content = contentJson.map((block, index) => {
if (block.type === 'text') {
return {
'type': 'text',
'data': {
'id': block.data.id ? block.data.id : null,
'uuid': block.uuid,
'position': ++index,
'position': index + 1,
'title': block.data.title,
'txt': block.data.text,
}
@ -230,7 +230,7 @@ export const api = {
'data': {
'id': block.data.id ? block.data.id : null,
'uuid': block.uuid,
'position': ++index,
'position': index + 1,
'title': block.data.title,
'img': block.data.image_id,
}
@ -241,7 +241,7 @@ export const api = {
'data': {
'id': block.data.id ? block.data.id : null,
'uuid': block.uuid,
'position': ++index,
'position': index + 1,
'title': block.data.title,
'img': block.data.image_id,
'txt': block.data.text,
@ -253,7 +253,7 @@ export const api = {
'data': {
'id': block.data.id ? block.data.id : null,
'uuid': block.uuid,
'position': ++index,
'position': index + 1,
'title': block.data.title,
'images': api.convertGalleryImagesJson(block.data.images),
}
@ -271,6 +271,7 @@ export const api = {
}
}
});
return content;
}
return contentJson.sort((a, b) => {
if (a.position < b.position) {

Loading…
Cancel
Save