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
c6c0adc3
Commit
c6c0adc3
authored
2 years ago
by
Ilya Simonov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add new fiels in Video model
parent
7999e802
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
89 additions
and
8 deletions
+89
-8
admin.cpython-39.pyc
apps/core/__pycache__/admin.cpython-39.pyc
+0
-0
models.cpython-39.pyc
apps/core/__pycache__/models.cpython-39.pyc
+0
-0
admin.py
apps/core/admin.py
+6
-1
0002_video_closed_captions_video_creator_and_more.py
...ions/0002_video_closed_captions_video_creator_and_more.py
+35
-1
0002_video_closed_captions_video_creator_and_more.cpython-39.pyc
...deo_closed_captions_video_creator_and_more.cpython-39.pyc
+0
-0
0002_video_description_video_thumbnail_and_more.cpython-39.pyc
...video_description_video_thumbnail_and_more.cpython-39.pyc
+0
-0
models.py
apps/core/models.py
+45
-4
tasks.py
apps/core/tasks.py
+3
-2
No files found.
apps/core/__pycache__/admin.cpython-39.pyc
View file @
c6c0adc3
No preview for this file type
This diff is collapsed.
Click to expand it.
apps/core/__pycache__/models.cpython-39.pyc
View file @
c6c0adc3
No preview for this file type
This diff is collapsed.
Click to expand it.
apps/core/admin.py
View file @
c6c0adc3
...
...
@@ -4,8 +4,13 @@ from . import models
class
VideoAdmin
(
admin
.
ModelAdmin
):
list_display
=
[
'id'
,
'title'
,
]
list_display
=
[
'id'
,
'title'
,
'slug'
,
'status'
,
'duration'
]
readonly_fields
=
[
'created'
,
'updated'
]
list_filter
=
(
'status'
,)
def
save_model
(
self
,
request
,
obj
,
form
,
change
):
obj
.
creator
=
request
.
user
super
()
.
save_model
(
request
,
obj
,
form
,
change
)
class
PlayListAdmin
(
admin
.
ModelAdmin
):
...
...
This diff is collapsed.
Click to expand it.
apps/core/migrations/0002_video_
description_video_thumbnail
_and_more.py
→
apps/core/migrations/0002_video_
closed_captions_video_creator
_and_more.py
View file @
c6c0adc3
# Generated by Django 4.1.7 on 2023-0
2-28 15:22
# Generated by Django 4.1.7 on 2023-0
3-06 13:56
import
apps.core.utils
from
django.conf
import
settings
from
django.db
import
migrations
,
models
import
django.db.models.deletion
import
storages.backends.s3boto3
class
Migration
(
migrations
.
Migration
):
dependencies
=
[
migrations
.
swappable_dependency
(
settings
.
AUTH_USER_MODEL
),
(
'core'
,
'0001_initial'
),
]
operations
=
[
migrations
.
AddField
(
model_name
=
'video'
,
name
=
'closed_captions'
,
field
=
models
.
CharField
(
blank
=
True
,
max_length
=
255
,
null
=
True
,
verbose_name
=
'closed_captions'
),
),
migrations
.
AddField
(
model_name
=
'video'
,
name
=
'creator'
,
field
=
models
.
ForeignKey
(
blank
=
True
,
default
=
1
,
on_delete
=
django
.
db
.
models
.
deletion
.
CASCADE
,
related_name
=
'creator_video'
,
to
=
settings
.
AUTH_USER_MODEL
,
verbose_name
=
'creator'
),
preserve_default
=
False
,
),
migrations
.
AddField
(
model_name
=
'video'
,
name
=
'description'
,
field
=
models
.
TextField
(
blank
=
True
,
null
=
True
,
verbose_name
=
'description'
),
),
migrations
.
AddField
(
model_name
=
'video'
,
name
=
'duration'
,
field
=
models
.
IntegerField
(
blank
=
True
,
null
=
True
,
verbose_name
=
'duration'
),
),
migrations
.
AddField
(
model_name
=
'video'
,
name
=
'slug'
,
field
=
models
.
SlugField
(
blank
=
True
,
max_length
=
255
,
unique
=
True
,
verbose_name
=
'slug'
),
),
migrations
.
AddField
(
model_name
=
'video'
,
name
=
'status'
,
field
=
models
.
CharField
(
choices
=
[(
'ready'
,
'Ready'
),
(
'progress'
,
'Progress'
),
(
'fail'
,
'Fail'
)],
default
=
'progress'
,
max_length
=
255
,
verbose_name
=
'status'
),
),
migrations
.
AddField
(
model_name
=
'video'
,
name
=
'thumbnail'
,
...
...
@@ -32,6 +61,11 @@ class Migration(migrations.Migration):
name
=
's3_file'
,
field
=
models
.
FileField
(
blank
=
True
,
max_length
=
500
,
null
=
True
,
storage
=
storages
.
backends
.
s3boto3
.
S3Boto3Storage
(
bucket_name
=
'clutchpoints-videos'
),
upload_to
=
''
,
verbose_name
=
'AWS S3 file'
),
),
migrations
.
AlterField
(
model_name
=
'video'
,
name
=
'title'
,
field
=
models
.
CharField
(
max_length
=
255
,
verbose_name
=
'title'
),
),
migrations
.
CreateModel
(
name
=
'Playlist'
,
fields
=
[
...
...
This diff is collapsed.
Click to expand it.
apps/core/migrations/__pycache__/0002_video_closed_captions_video_creator_and_more.cpython-39.pyc
0 → 100644
View file @
c6c0adc3
File added
This diff is collapsed.
Click to expand it.
apps/core/migrations/__pycache__/0002_video_description_video_thumbnail_and_more.cpython-39.pyc
deleted
100644 → 0
View file @
7999e802
File deleted
This diff is collapsed.
Click to expand it.
apps/core/models.py
View file @
c6c0adc3
from
django.db
import
models
from
django.utils.translation
import
gettext_lazy
as
_
from
django.contrib.auth.models
import
User
from
pytils.translit
import
slugify
from
storages.backends.s3boto3
import
S3Boto3Storage
from
.utils
import
asset_upload
READY
=
'ready'
PROGRESS
=
'progress'
FAIL
=
'fail'
STATUS_CHOICES
=
(
(
READY
,
'Ready'
),
(
PROGRESS
,
'Progress'
),
(
FAIL
,
'Fail'
),
)
class
BaseModel
(
models
.
Model
):
updated
=
models
.
DateTimeField
(
_
(
'updated'
),
auto_now
=
True
,
db_index
=
True
)
created
=
models
.
DateTimeField
(
_
(
'created'
),
auto_now_add
=
True
,
db_index
=
True
)
...
...
@@ -15,29 +28,50 @@ class BaseModel(models.Model):
class
Video
(
BaseModel
):
title
=
models
.
CharField
(
_
(
'full name'
),
max_length
=
255
)
title
=
models
.
CharField
(
_
(
'title'
),
max_length
=
255
)
slug
=
models
.
SlugField
(
_
(
'slug'
),
max_length
=
255
,
unique
=
True
,
blank
=
True
)
description
=
models
.
TextField
(
_
(
'description'
),
blank
=
True
,
null
=
True
)
local_file
=
models
.
FileField
(
'local file'
,
_
(
'local file'
)
,
upload_to
=
'videos'
,
blank
=
True
,
null
=
True
,
)
s3_file
=
models
.
FileField
(
'AWS S3 file'
,
_
(
'AWS S3 file'
)
,
storage
=
S3Boto3Storage
(
bucket_name
=
'clutchpoints-videos'
),
blank
=
True
,
null
=
True
,
max_length
=
500
,
)
thumbnail
=
models
.
ImageField
(
'thumbnail'
,
_
(
'thumbnail'
)
,
upload_to
=
asset_upload
,
storage
=
S3Boto3Storage
(
bucket_name
=
'clutchpoints-videos'
),
blank
=
True
,
null
=
True
,
max_length
=
500
,
)
creator
=
models
.
ForeignKey
(
User
,
verbose_name
=
_
(
'creator'
),
related_name
=
'creator_video'
,
on_delete
=
models
.
CASCADE
,
blank
=
True
)
status
=
models
.
CharField
(
_
(
'status'
),
choices
=
STATUS_CHOICES
,
default
=
PROGRESS
,
max_length
=
255
,
)
duration
=
models
.
IntegerField
(
_
(
'duration'
),
blank
=
True
,
null
=
True
)
closed_captions
=
models
.
CharField
(
_
(
'closed_captions'
),
max_length
=
255
,
blank
=
True
,
null
=
True
,
)
class
Meta
:
ordering
=
(
'title'
,)
...
...
@@ -45,6 +79,13 @@ class Video(BaseModel):
def
__str__
(
self
):
return
self
.
title
def
save
(
self
,
*
args
,
**
kwargs
):
print
(
'save'
)
if
not
self
.
id
:
self
.
slug
=
slugify
(
self
.
title
)
super
()
.
save
(
*
args
,
**
kwargs
)
class
Playlist
(
BaseModel
):
title
=
models
.
CharField
(
_
(
'title'
),
max_length
=
255
)
...
...
This diff is collapsed.
Click to expand it.
apps/core/tasks.py
View file @
c6c0adc3
import
os
from
.models
import
Video
from
.models
import
Video
,
READY
from
.s3_uploader
import
upload_file
from
cp_video.celery
import
app
...
...
@@ -16,8 +16,9 @@ def send_video_to_s3():
content
=
local_video
.
local_file
.
read
()
local_video
.
s3_file
=
upload_file
(
content
,
key
,
'video/mp4'
)
local_video
.
status
=
READY
local_video
.
save
(
update_fields
=
[
's3_file'
])
local_video
.
save
(
update_fields
=
[
's3_file'
,
'status'
])
os
.
remove
(
local_video
.
local_file
.
path
)
local_videos
.
update
(
local_file
=
None
)
This diff is collapsed.
Click to expand it.
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