Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
C
cp_video_dokku
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Alexandr Dzehil
cp_video_dokku
Commits
da5769a4
You need to sign in or sign up before continuing.
Commit
da5769a4
authored
Mar 16, 2023
by
Ilya Simonov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
delete signal for generate thumbnail
parent
43809573
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
15 deletions
+15
-15
signals.cpython-39.pyc
apps/core/__pycache__/signals.cpython-39.pyc
+0
-0
signals.py
apps/core/signals.py
+15
-15
No files found.
apps/core/__pycache__/signals.cpython-39.pyc
View file @
da5769a4
No preview for this file type
apps/core/signals.py
View file @
da5769a4
...
...
@@ -7,18 +7,18 @@ from django.db.models.signals import post_save
from
.
import
models
,
utils
,
s3_uploader
@
receiver
(
post_save
,
sender
=
models
.
Video
)
def
generate_default_thumbnail_for_video
(
sender
,
instance
,
**
kwargs
):
if
not
instance
.
thumbnail
and
instance
.
local_file
:
if
os
.
path
.
isfile
(
instance
.
local_file
.
path
):
thumbnail_name
=
utils
.
generate_thumbnail
(
instance
.
local_file
)
key
=
f
'videos/{thumbnail_name}'
thumbnail_path
=
f
'{settings.MEDIA_ROOT}{key}'
content
=
utils
.
get_thumbnail_content
(
thumbnail_path
)
content_type
=
'image/jpeg'
instance
.
thumbnail
=
s3_uploader
.
upload_file
(
content
,
key
,
content_type
)
instance
.
save
(
update_fields
=
[
'thumbnail'
])
os
.
remove
(
thumbnail_path
)
#
@receiver(post_save, sender=models.Video)
#
def generate_default_thumbnail_for_video(sender, instance, **kwargs):
#
if not instance.thumbnail and instance.local_file:
#
if os.path.isfile(instance.local_file.path):
#
thumbnail_name = utils.generate_thumbnail(instance.local_file)
#
key = f'videos/{thumbnail_name}'
#
thumbnail_path = f'{settings.MEDIA_ROOT}{key}'
#
#
content = utils.get_thumbnail_content(thumbnail_path)
#
content_type = 'image/jpeg'
#
instance.thumbnail = s3_uploader.upload_file(content, key, content_type)
#
#
instance.save(update_fields=['thumbnail'])
#
#
os.remove(thumbnail_path)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment