aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorChocobozzz <florian.bigard@gmail.com>2017-05-05 14:29:58 +0200
committerChocobozzz <florian.bigard@gmail.com>2017-05-05 14:29:58 +0200
commitc24ac1c18e26b6a24a4d294744908fb0c53ddf3c (patch)
treee66ede727fdc92d446f0db829e0592b5f0a2cdd0
parent9eee32fc34ece1cc5e624ae15d81bfede68be33f (diff)
downloadPeerTube-c24ac1c18e26b6a24a4d294744908fb0c53ddf3c.tar.gz
PeerTube-c24ac1c18e26b6a24a4d294744908fb0c53ddf3c.tar.zst
PeerTube-c24ac1c18e26b6a24a4d294744908fb0c53ddf3c.zip
Fix unset video language on video update
-rw-r--r--client/src/app/videos/shared/video.service.ts5
-rw-r--r--client/src/app/videos/video-edit/video-update.component.ts10
-rw-r--r--server/controllers/api/videos.js12
-rw-r--r--server/helpers/custom-validators/videos.js2
4 files changed, 21 insertions, 8 deletions
diff --git a/client/src/app/videos/shared/video.service.ts b/client/src/app/videos/shared/video.service.ts
index ba83c72fd..ef683dea6 100644
--- a/client/src/app/videos/shared/video.service.ts
+++ b/client/src/app/videos/shared/video.service.ts
@@ -81,14 +81,17 @@ export class VideoService {
81 } 81 }
82 82
83 updateVideo(video: Video) { 83 updateVideo(video: Video) {
84 const language = video.language ? video.language : null;
85
84 const body = { 86 const body = {
85 name: video.name, 87 name: video.name,
86 category: video.category, 88 category: video.category,
87 licence: video.licence, 89 licence: video.licence,
88 language: video.language, 90 language,
89 description: video.description, 91 description: video.description,
90 tags: video.tags 92 tags: video.tags
91 }; 93 };
94
92 const headers = new Headers({ 'Content-Type': 'application/json' }); 95 const headers = new Headers({ 'Content-Type': 'application/json' });
93 const options = new RequestOptions({ headers: headers }); 96 const options = new RequestOptions({ headers: headers });
94 97
diff --git a/client/src/app/videos/video-edit/video-update.component.ts b/client/src/app/videos/video-edit/video-update.component.ts
index adb3d295c..933132cc0 100644
--- a/client/src/app/videos/video-edit/video-update.component.ts
+++ b/client/src/app/videos/video-edit/video-update.component.ts
@@ -98,7 +98,17 @@ export class VideoUpdateComponent extends FormReactive implements OnInit {
98 ); 98 );
99 } 99 }
100 100
101 checkForm() {
102 this.forceCheck();
103
104 return this.form.valid;
105 }
106
101 update() { 107 update() {
108 if (this.checkForm() === false) {
109 return;
110 }
111
102 this.video.patch(this.form.value); 112 this.video.patch(this.form.value);
103 113
104 this.videoService.updateVideo(this.video) 114 this.videoService.updateVideo(this.video)
diff --git a/server/controllers/api/videos.js b/server/controllers/api/videos.js
index 4a4c5e162..aeefaa555 100644
--- a/server/controllers/api/videos.js
+++ b/server/controllers/api/videos.js
@@ -444,12 +444,12 @@ function updateVideo (req, res, finalCallback) {
444 transaction: t 444 transaction: t
445 } 445 }
446 446
447 if (videoInfosToUpdate.name) videoInstance.set('name', videoInfosToUpdate.name) 447 if (videoInfosToUpdate.name !== undefined) videoInstance.set('name', videoInfosToUpdate.name)
448 if (videoInfosToUpdate.category) videoInstance.set('category', videoInfosToUpdate.category) 448 if (videoInfosToUpdate.category !== undefined) videoInstance.set('category', videoInfosToUpdate.category)
449 if (videoInfosToUpdate.licence) videoInstance.set('licence', videoInfosToUpdate.licence) 449 if (videoInfosToUpdate.licence !== undefined) videoInstance.set('licence', videoInfosToUpdate.licence)
450 if (videoInfosToUpdate.language) videoInstance.set('language', videoInfosToUpdate.language) 450 if (videoInfosToUpdate.language !== undefined) videoInstance.set('language', videoInfosToUpdate.language)
451 if (videoInfosToUpdate.nsfw) videoInstance.set('nsfw', videoInfosToUpdate.nsfw) 451 if (videoInfosToUpdate.nsfw !== undefined) videoInstance.set('nsfw', videoInfosToUpdate.nsfw)
452 if (videoInfosToUpdate.description) videoInstance.set('description', videoInfosToUpdate.description) 452 if (videoInfosToUpdate.description !== undefined) videoInstance.set('description', videoInfosToUpdate.description)
453 453
454 videoInstance.save(options).asCallback(function (err) { 454 videoInstance.save(options).asCallback(function (err) {
455 return callback(err, t, tagInstances) 455 return callback(err, t, tagInstances)
diff --git a/server/helpers/custom-validators/videos.js b/server/helpers/custom-validators/videos.js
index 8dabb828d..196731e04 100644
--- a/server/helpers/custom-validators/videos.js
+++ b/server/helpers/custom-validators/videos.js
@@ -53,7 +53,7 @@ function isVideoLicenceValid (value) {
53} 53}
54 54
55function isVideoLanguageValid (value) { 55function isVideoLanguageValid (value) {
56 return constants.VIDEO_LANGUAGES[value] !== undefined 56 return value === null || constants.VIDEO_LANGUAGES[value] !== undefined
57} 57}
58 58
59function isVideoNSFWValid (value) { 59function isVideoNSFWValid (value) {