diff --git a/addons/website_slides/controllers/main.py b/addons/website_slides/controllers/main.py
index 7cac5ce0bb7..a52ba886922 100644
--- a/addons/website_slides/controllers/main.py
+++ b/addons/website_slides/controllers/main.py
@@ -544,7 +544,7 @@ class WebsiteSlides(WebsiteProfile):
# display data
'pager': pager,
# display upload modal
- 'enable_slide_upload': 'enable_slide_upload' in kw,
+ 'enable_slide_upload': kw.get('enable_slide_upload', False),
** errors,
** self._slide_channel_prepare_review_values(channel),
})
@@ -580,7 +580,8 @@ class WebsiteSlides(WebsiteProfile):
render_values['modules_to_install'] = [{
'id': module.id,
'name': module.shortdesc,
- 'motivational': _('Evaluate and certify your students.'),
+ 'motivational': _('Want to test and certify your students?'),
+ 'default_slide_category': 'certification',
}]
render_values = self._prepare_additional_channel_values(render_values, **kw)
@@ -1246,10 +1247,12 @@ class WebsiteSlides(WebsiteProfile):
channel._resequence_slides(slide, force_category=category)
redirect_url = "/slides/slide/%s" % (slide.id)
- if channel.channel_type == "training" and slide.slide_category not in ["article", "quiz"]:
- redirect_url = "/slides/%s" % (slug(channel))
if slide.slide_category == 'article':
redirect_url += "?enable_editor=1"
+ elif slide.slide_category == 'quiz':
+ redirect_url += "?quiz_quick_create"
+ elif channel.channel_type == "training":
+ redirect_url = "/slides/%s" % (slug(channel))
return {
'url': redirect_url,
'channel_type': channel.channel_type,
diff --git a/addons/website_slides/static/src/js/slides_upload.js b/addons/website_slides/static/src/js/slides_upload.js
index f7f901c82cc..3321da9b4f5 100644
--- a/addons/website_slides/static/src/js/slides_upload.js
+++ b/addons/website_slides/static/src/js/slides_upload.js
@@ -34,13 +34,20 @@ var SlideUploadDialog = Dialog.extend({
this._setup();
this.channelID = parseInt(options.channelId, 10);
- this.defaultCategoryID = parseInt(options.categoryId,10);
+ this.defaultCategoryID = parseInt(options.categoryId, 10);
this.canUpload = options.canUpload === 'True';
this.canPublish = options.canPublish === 'True';
this.modulesToInstall = options.modulesToInstall ? JSON.parse(options.modulesToInstall.replace(/'/g, '"')) : null;
this.modulesToInstallStatus = null;
- this.set('state', '_select');
+ if (options.openModal && options.openModal in this.slide_category_data) {
+ // Sets the appropriate category's upload template if one has to be opened on load.
+ this.set('state', options.openModal);
+ this.set('defaultTemplate', this.slide_category_data[options.openModal]['template']);
+ } else {
+ this.set('state', '_select');
+ this.set('defaultTemplate', 'website.slide.upload.modal.select');
+ }
this.on('change:state', this, this._onChangeType);
this.set('can_submit_form', false);
this.on('change:can_submit_form', this, this._onChangeCanSubmitForm);
@@ -51,6 +58,10 @@ var SlideUploadDialog = Dialog.extend({
start: function () {
var self = this;
return this._super.apply(this, arguments).then(function () {
+ if (self.get('state') !== '_select') {
+ self.$modal.find('.modal-dialog').addClass('modal-lg');
+ }
+ self._bindSelect2Dropdown();
self._resetModalButton();
});
},
@@ -668,7 +679,12 @@ var SlideUploadDialog = Dialog.extend({
method: 'button_immediate_install',
args: [[this.modulesToInstallStatus.id]],
}).then(function () {
- window.location.href = window.location.origin + window.location.pathname + '?enable_slide_upload';
+ let redirectUrl = window.location.origin + window.location.pathname + '?enable_slide_upload';
+ if (self.modulesToInstallStatus.default_slide_category) {
+ redirectUrl += '=';
+ redirectUrl += self.modulesToInstallStatus.default_slide_category;
+ }
+ window.location.href = redirectUrl;
}, function () {
$el.text(_.str.sprintf(_t('Failed to install "%s".'), self.modulesToInstallStatus.name));
self.modulesToInstallStatus.installing = false;
@@ -733,13 +749,16 @@ publicWidget.registry.websiteSlidesUpload = publicWidget.Widget.extend({
},
/**
+ * Automatically opens the upload dialog if requested from query string.
+ * If openModal is defined ( === '' ), opens the category selection dialog.
+ * If openModal is a category name, opens the category's upload dialog.
+ *
* @override
*/
start: function () {
- // Automatically open the upload dialog if requested from query string
- if (this.$el.attr('data-open-modal')) {
- this.$el.removeAttr('data-open-modal');
+ if ('openModal' in this.$el.data()) {
this._openDialog(this.$el);
+ this.$el.data('openModal', false);
}
return this._super.apply(this, arguments);
},
@@ -749,8 +768,7 @@ publicWidget.registry.websiteSlidesUpload = publicWidget.Widget.extend({
//--------------------------------------------------------------------------
_openDialog: function ($element) {
- var data = $element.data();
- return new SlideUploadDialog(this, data).open();
+ return new SlideUploadDialog(this, $element.data()).open();
},
//--------------------------------------------------------------------------
diff --git a/addons/website_slides/static/src/xml/website_slides_upload.xml b/addons/website_slides/static/src/xml/website_slides_upload.xml
index f5874a0fa5b..def77ee04da 100644
--- a/addons/website_slides/static/src/xml/website_slides_upload.xml
+++ b/addons/website_slides/static/src/xml/website_slides_upload.xml
@@ -4,7 +4,7 @@