Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[#1713, #1714] Added basic video model, player & cms-plugin #773

Merged
merged 7 commits into from
Sep 28, 2023

Conversation

Bartvaderkin
Copy link
Contributor

@Bartvaderkin Bartvaderkin commented Sep 19, 2023

What is in here?

  • basic Video model + admin (from Anne F.)
  • CMS plugin + model (to put a Video on CMS pages)
  • Change to Product model + template to add Video on Product detail view

For clarity you can view the separate commits.

Possibly @jiromaykin want's to do some CSS or template work so the player adjusts size to available space? If so either amend the PR now, or create a ticket for this sprint.

@codecov-commenter
Copy link

codecov-commenter commented Sep 19, 2023

Codecov Report

Merging #773 (981ce22) into develop (c294eef) will increase coverage by 0.01%.
Report is 11 commits behind head on develop.
The diff coverage is 96.27%.

❗ Current head 981ce22 differs from pull request most recent head a9ffd61. Consider uploading reports for the commit a9ffd61 to get more accurate results

@@             Coverage Diff             @@
##           develop     #773      +/-   ##
===========================================
+ Coverage    93.58%   93.59%   +0.01%     
===========================================
  Files          697      716      +19     
  Lines        24595    24793     +198     
===========================================
+ Hits         23016    23204     +188     
- Misses        1579     1589      +10     
Files Changed Coverage Δ
src/open_inwoner/conf/base.py 95.60% <ø> (ø)
src/open_inwoner/cms/plugins/models/videoplayer.py 70.00% <70.00%> (ø)
src/open_inwoner/media/models/video.py 90.90% <90.90%> (ø)
src/open_inwoner/media/admin/video.py 94.44% <94.44%> (ø)
...c/open_inwoner/cms/plugins/cms_plugins/__init__.py 100.00% <100.00%> (ø)
...pen_inwoner/cms/plugins/cms_plugins/videoplayer.py 100.00% <100.00%> (ø)
...pen_inwoner/cms/plugins/migrations/0001_initial.py 100.00% <100.00%> (ø)
src/open_inwoner/cms/plugins/models/__init__.py 100.00% <100.00%> (ø)
...open_inwoner/cms/plugins/tests/test_videoplayer.py 100.00% <100.00%> (ø)
src/open_inwoner/media/admin/__init__.py 100.00% <100.00%> (ø)
... and 11 more

... and 7 files with indirect coverage changes

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@Bartvaderkin Bartvaderkin marked this pull request as ready for review September 21, 2023 07:37
@jiromaykin
Copy link
Contributor

@Bartvaderkin Yes, cool, the video frame seems to have a set width to 640px + could use a top-margin; and I'll need to make it responsive somehow :)
I've created a new issue (#1756) for this and will probably branch off from this one.

from djchoices import ChoiceItem, DjangoChoices


class VideoPlayerChoices(DjangoChoices):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

djchoices is deprecated as Django supports enum types natively. See Django docs and the note in the djchoices docs

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

True but the whole application is using djchoices so let's stick with it for now.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@pi-sigma I made Taiga 1769 issue to swap the old choices for modern native ones.

@property
def external_url(self):
if self.player_type == VideoPlayerChoices.youtube:
url = "https://www.youtube.com/watch?v={link_id}&enablejsapi=1"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

link_id > self.link_id

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This code was from an older project so used old .format(), but I replaced it with f-strings as I should've done before.

src/open_inwoner/media/models/video.py Outdated Show resolved Hide resolved
@@ -101,6 +101,15 @@ class Product(models.Model):
"Product content with build-in WYSIWYG editor. By adding '[CTABUTTON]' you can embed a cta-button for linking to the defined form or link"
),
)
video = models.ForeignKey(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this what we want? A ForeignKey from A to B defines a many-to-one relationship. I this case, many products can be associated with a single video (as in: one video covers different products), but each product can have only one video. My first thought is that, if anything, it should be the other way around (you could have several videos for a single product, highlighting different aspects perhaps), or perhaps even have a many-to-many relationship.

Copy link
Contributor Author

@Bartvaderkin Bartvaderkin Sep 25, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We specifically went for this because it was the simplest solution, until ultimately we convert the pages to be CMS pages (where the editor can add and position videos freely).

src/open_inwoner/scss/components/Video/Video.scss Outdated Show resolved Hide resolved
@alextreme alextreme merged commit b938865 into develop Sep 28, 2023
14 checks passed
@alextreme alextreme deleted the feature/1714-video-homepage branch September 28, 2023 09:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants