Aurélien Warnon 7b5427f6d6 [REF] website_slides: refactor external content management in slide.slide
PURPOSE

Globally refactor the way we handle external content (YouTube videos,
Google Drive documents, ...) in the course slides.

This includes both technical changes (new computed fields, rename, ...) as well
as visual changes on the form views that allow introducing new content, both in
the backend (slide.slide form view) and in the frontend (course main website
page).

SPECS

TECHNICAL REFACTOR

1. Rework the "url" field

This field was used without any distinction for videos, regular documents and
images, leading to a big confusion both technically and visually.

The urls are now split in separate fields (video_url, document_google_url and
image_google_url), based on the type of slide.
Those fields are implemented as 'related' to the stored 'url' field to avoid
extra storage.

This change globally increases the readability and usability in the code, and
also allows for clear labels on the various views.

1b. Rework the "binary_content" field

The same way as for the 'url' field, the 'binary_content' field has been split
into 2 related fields ('document_binary_content' and 'image_binary_content').

This allows for more readability and also helps in the form view to limit the
file selection to the supported file types.

2. Remove the "document_id" stored field

This field did not have to be stored since it can "easily" be inferred from the
video/document URL with some regex work.

3. Remove the "mime_type" field

This field's value was only determined by an external call to the Google Drive
API. It was inconsistent because not set for manually uploaded document and was
used for some strange checks that seemed to work but did not make much sense.
(e.g: used to make the difference between a Google Drive video and a YouTube
video??).

It has been replaced by a "document_type" field, which is always 'pdf' for
local files (only type we support) and inferred from the mimeType returned by
Google Drive metadata for external documents.

This allows, for instance, to show pretty icons next to every slide based on
their type, "sheet" files (Excel, Google Sheet, ...) share the same icons, the
same principle is applied to "doc" files (Word, OpenOffice, Google Doc, ...)
and finally "slides" files (PowerPoint, Google Slides, ...).

4. Introduce several computed fields

Such as:
- video_source_type
- youtube_id
- google_drive_id

These fields are mostly inferred from the slide type and the related URL.
They are used to make clear checks in the code and ease readability, for
example when constructing the slide "embed code" to insert it in the frontend
full screen viewer.

5. Remove the "presentation" slide_type

The slide type "presentation" was some kind of very confusing type between
image and pdf. It was mostly relying on the fact that the content had a bigger
width than height ('landscape' display).

This lead to a lot of confusion both in the code base and in the various forms
allowing to introduce new content ("what should I choose? document or
presentation?").

In order to simplify everything, we completely removed the slide type
"presentation" and converted all the data that had this type and the various
code checks to the type "document" instead.

Meaning that we end up with the following slide types:
- Infographic - for images, local files + external links
- Web Page - local input only
- Document local files + external links
- Video - external only, YouTube or Google Drive links
- Quiz

FUNCTIONAL

Following the technical changes here above, we can improve the form view of the
slide.slide model as well as the website form that allows adding new content.

1. Slide form view

To make it clear where the source of the document comes from, we introduced a
"source_type" field that is either "local_file", used when uploading a file
from your computer, or "external", used when linking content from Google Drive.

The source_type selection appears when adding content of type "document" or
"infographic" and conditions the display of the file upload button or the
document_url field.

2. Adding content from the website

When adding content from the website, the user is now invited to select from
ALL the available slide type, meaning we added "Infographic" to the selection.

Before this change, if you wanted to link an image, you had to select the type
"presentation" (that has a PDF file as icon...) and then input an image file.
The JS then processed the file type to determine the slide type.

As this was slightly confusing for the end user, we decided to use the same
approach as the form view, meaning you FIRST select the type of slide you want
and THEN input the content as a local file or external link.

Since we now handle all types of documents when using an external Google Drive
link, the various screen and text helpers have been reworked accordingly.

3. Handle more types of slides with the new "slide_type" field

This commit also introduces a new "slide_type" field.
(Don't get confused, the previous "slide_type" field has been renamed to
"slide_category" in an earlier rename commit).

This slide_type is a refined slide_category:
- Videos are split into 'youtube_video' and 'google_drive_video'
- Documents are refined based on the file mime_type if it's external content
  For example, if you link a Excel file, the slide_type will be 'sheet'.
  If you link a Google Doc, the slide_type will be 'doc'
  etc...
  (Local documents are only PDFs since it's the only type we support for now)

This small change allows to include minor nice details into views, such as a
refined icon for each slide_type on the website.

LINKS

Task-2510174
UPG PR odoo/upgrade#2498

Part-of: odoo/odoo#71477
2021-11-30 15:21:48 +00:00
2021-10-21 19:09:48 +00:00
2021-11-29 15:41:03 +00:00
2021-10-21 19:09:48 +00:00
…
…
…
…
2021-11-04 10:21:58 +00:00
2021-10-21 19:09:48 +00:00
2021-10-07 17:59:53 +00:00
2021-10-21 19:09:48 +00:00
2021-10-21 19:09:48 +00:00

Build Status Tech Doc Help Nightly Builds

Odoo

Odoo is a suite of web based open source business apps.

The main Odoo Apps include an Open Source CRM, Website Builder, eCommerce, Warehouse Management, Project Management, Billing & Accounting, Point of Sale, Human Resources, Marketing, Manufacturing, ...

Odoo Apps can be used as stand-alone applications, but they also integrate seamlessly so you get a full-featured Open Source ERP when you install several Apps.

Getting started with Odoo

For a standard installation please follow the Setup instructions from the documentation.

To learn the software, we recommend the Odoo eLearning, or Scale-up, the business game. Developers can start with the developer tutorials

S
Description
No description provided
Readme LGPL-3.0
3.4 GiB
Languages
Python 49.6%
JavaScript 47.8%
SCSS 2%
CSS 0.3%
HTML 0.2%