added django-import-export
This commit is contained in:
parent
9e976e06fd
commit
ced191e0fa
7 changed files with 56 additions and 20 deletions
5
backend/.gitignore
vendored
5
backend/.gitignore
vendored
|
|
@ -144,4 +144,7 @@ GitHub.sublime-settings
|
|||
**/migrations/**
|
||||
!**/migrations
|
||||
!**/migrations/__init__.py
|
||||
videoflix/users/migrations
|
||||
videoflix/users/migrations
|
||||
|
||||
# Statics
|
||||
videoflix/staticfiles
|
||||
|
|
@ -1,4 +1,12 @@
|
|||
from django.contrib import admin
|
||||
from .models import Video
|
||||
from import_export import resources
|
||||
from import_export.admin import ImportExportModelAdmin
|
||||
|
||||
admin.site.register(Video)
|
||||
class VideoResource(resources.ModelResource):
|
||||
class Meta:
|
||||
model = Video
|
||||
|
||||
@admin.register(Video)
|
||||
class VideoAdmin(ImportExportModelAdmin):
|
||||
pass
|
||||
18
backend/videoflix/content/class_assets.py
Normal file
18
backend/videoflix/content/class_assets.py
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
FILM_GENRES = [
|
||||
('action', 'Action'),
|
||||
('adventure', 'Adventure'),
|
||||
('comedy', 'Comedy'),
|
||||
('drama', 'Drama'),
|
||||
('horror', 'Horror'),
|
||||
('science_fiction', 'Science Fiction'),
|
||||
('fantasy', 'Fantasy'),
|
||||
('romance', 'Romance'),
|
||||
('thriller', 'Thriller'),
|
||||
('mystery', 'Mystery'),
|
||||
('crime', 'Crime'),
|
||||
('animation', 'Animation'),
|
||||
('documentary', 'Documentary'),
|
||||
('musical', 'Musical'),
|
||||
('war', 'War'),
|
||||
('western', 'Western'),
|
||||
]
|
||||
|
|
@ -1,11 +1,12 @@
|
|||
from django.db import models
|
||||
from datetime import date
|
||||
from .class_assets import FILM_GENRES
|
||||
|
||||
class Video(models.Model):
|
||||
created_at = models.DateField(default=date.today)
|
||||
title = models.CharField(max_length=80)
|
||||
description = models.CharField(max_length=500)
|
||||
film_genre = models.CharField(max_length=50, blank=True, null=True)
|
||||
film_genre = models.CharField(max_length=20, choices=FILM_GENRES, blank=True, null=True)
|
||||
video_file = models.FileField(upload_to='videos/', blank=True, null=True)
|
||||
thumbnail = models.ImageField(upload_to='thumbnails/', blank=True, null=True)
|
||||
|
||||
|
|
|
|||
|
|
@ -53,6 +53,7 @@ INSTALLED_APPS = [
|
|||
'corsheaders',
|
||||
'debug_toolbar',
|
||||
'django_rq',
|
||||
'import_export',
|
||||
'content.apps.ContentConfig',
|
||||
'users',
|
||||
]
|
||||
|
|
@ -121,6 +122,11 @@ MEDIA_URL = '/media/'
|
|||
|
||||
WSGI_APPLICATION = 'videoflix.wsgi.application'
|
||||
|
||||
# Statics
|
||||
|
||||
STATIC_ROOT = os.path.join(BASE_DIR, 'staticfiles')
|
||||
IMPORT_EXPORT_USE_TRANSACTIONS = True
|
||||
|
||||
# Database
|
||||
# https://docs.djangoproject.com/en/5.0/ref/settings/#databases
|
||||
|
||||
|
|
|
|||
|
|
@ -17,22 +17,22 @@ export class CategoriesComponent {
|
|||
environmentBaseUrl: string = environment.baseUrl.slice(0, -1);
|
||||
|
||||
filmGenres = [
|
||||
'Action',
|
||||
'Adventure',
|
||||
'Comedy',
|
||||
'Drama',
|
||||
'Horror',
|
||||
'Science Fiction',
|
||||
'Fantasy',
|
||||
'Romance',
|
||||
'Thriller',
|
||||
'Mystery',
|
||||
'Crime',
|
||||
'Animation',
|
||||
'Documentary',
|
||||
'Musical',
|
||||
'War',
|
||||
'Western',
|
||||
'action',
|
||||
'adventure',
|
||||
'comedy',
|
||||
'drama',
|
||||
'horror',
|
||||
'science_fiction',
|
||||
'fantasy',
|
||||
'romance',
|
||||
'thriller',
|
||||
'mystery',
|
||||
'crime',
|
||||
'animation',
|
||||
'documentary',
|
||||
'musical',
|
||||
'war',
|
||||
'western',
|
||||
];
|
||||
|
||||
openCurrentMovie(movieId: number) {
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||
'background-image':
|
||||
'url(' +
|
||||
environmentBaseUrl +
|
||||
currentMovie[0]?.thumbnail.replace('.jpg', '_1920p.jpg') +
|
||||
currentMovie[0]?.thumbnail.replace('.jpg', '_1080p.jpg') +
|
||||
')'
|
||||
}"
|
||||
>
|
||||
|
|
|
|||
Loading…
Reference in a new issue