added django-import-export

This commit is contained in:
Chneemann 2024-08-12 21:38:52 +02:00
parent 9e976e06fd
commit ced191e0fa
7 changed files with 56 additions and 20 deletions

3
backend/.gitignore vendored
View file

@ -145,3 +145,6 @@ GitHub.sublime-settings
!**/migrations
!**/migrations/__init__.py
videoflix/users/migrations
# Statics
videoflix/staticfiles

View file

@ -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

View 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'),
]

View file

@ -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)

View file

@ -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

View file

@ -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) {

View file

@ -4,7 +4,7 @@
'background-image':
'url(' +
environmentBaseUrl +
currentMovie[0]?.thumbnail.replace('.jpg', '_1920p.jpg') +
currentMovie[0]?.thumbnail.replace('.jpg', '_1080p.jpg') +
')'
}"
>