fix content creation in right folder + disable autoplay in preview mode

This commit is contained in:
jr-k 2024-07-11 01:30:42 +02:00
parent 6043547972
commit 022b094bda
3 changed files with 13 additions and 5 deletions

View File

@ -86,12 +86,16 @@ class ContentController(ObController):
return redirect(url_for('slideshow_content_list'))
def slideshow_content_add(self):
working_folder_path = self._model_store.variable().get_one_by_name('last_folder_content').as_string()
working_folder = self._model_store.folder().get_one_by_path(path=working_folder_path, entity=FolderEntity.CONTENT)
self._model_store.content().add_form_raw(
name=request.form['name'],
type=str_to_enum(request.form['type'], ContentType),
request_files=request.files,
upload_dir=self._app.config['UPLOAD_FOLDER'],
location=request.form['object'] if 'object' in request.form else None
location=request.form['object'] if 'object' in request.form else None,
folder_id=working_folder.id if working_folder else None
)
return redirect(url_for('slideshow_content_list'))

View File

@ -157,10 +157,11 @@ class ContentManager(ModelManager):
self._db.add(self.TABLE_NAME, self.pre_add(form))
self.post_add(content.id)
def add_form_raw(self, name: str, type: ContentType, request_files: Optional[Dict], upload_dir: str, location: Optional[str] = None) -> Content:
def add_form_raw(self, name: str, type: ContentType, request_files: Optional[Dict], upload_dir: str, location: Optional[str] = None, folder_id: Optional[int] = None) -> Content:
content = Content(
name=name,
type=type
type=type,
folder_id=folder_id,
)
if content.has_file():

View File

@ -343,7 +343,8 @@
}
if (element.innerHTML === 'youtube') {
element.innerHTML = `<iframe src="https://www.youtube.com/embed/${item.location}?version=3&autoplay=1&showinfo=0&controls=0&modestbranding=1&fs=1&rel=0" frameborder="0" allow="autoplay" allowfullscreen></iframe>`;
const autoplay = items['preview_mode'] ? '0' : '1';
element.innerHTML = `<iframe src="https://www.youtube.com/embed/${item.location}?version=3&autoplay=${autoplay}&showinfo=0&controls=0&modestbranding=1&fs=1&rel=0" frameborder="0" allow="autoplay" allowfullscreen></iframe>`;
}
}
setTimeout(autoplayLoader, delayNoisyContentJIT);
@ -370,7 +371,9 @@
}
if (element.innerHTML.match('<video>')) {
video.play();
if (!items['preview_mode']) {
video.play();
}
}
}
setTimeout(autoplayLoader, delayNoisyContentJIT);