summaryrefslogtreecommitdiff
path: root/app/media
diff options
context:
space:
mode:
Diffstat (limited to 'app/media')
-rw-r--r--app/media/admin.py8
-rw-r--r--app/media/models.py17
2 files changed, 21 insertions, 4 deletions
diff --git a/app/media/admin.py b/app/media/admin.py
index 50eb879..a9b60f0 100644
--- a/app/media/admin.py
+++ b/app/media/admin.py
@@ -1,6 +1,6 @@
from django.contrib import admin
from django import forms
-from django.contrib.gis.admin import OSMGeoAdmin
+from django.contrib.gis.admin import GISModelAdmin
from .models import LuxImage, LuxGallery, LuxImageSize, LuxVideo
from django.shortcuts import render
from django.contrib.admin import helpers
@@ -8,17 +8,17 @@ from django.http import HttpResponseRedirect
@admin.register(LuxImageSize)
-class LuxImageSizeAdmin(OSMGeoAdmin):
+class LuxImageSizeAdmin(GISModelAdmin):
list_display = ('name','slug', 'width', 'height', 'quality')
@admin.register(LuxVideo)
-class LuxVideoAdmin(OSMGeoAdmin):
+class LuxVideoAdmin(GISModelAdmin):
pass
@admin.register(LuxImage)
-class LuxImageAdmin(OSMGeoAdmin):
+class LuxImageAdmin(GISModelAdmin):
list_display = ('pk', 'admin_thumbnail', 'pub_date', 'caption')
list_filter = ('pub_date',)
search_fields = ['title', 'caption', 'alt']
diff --git a/app/media/models.py b/app/media/models.py
index dcf7ccc..b5b4e06 100644
--- a/app/media/models.py
+++ b/app/media/models.py
@@ -5,6 +5,7 @@ from pathlib import Path
from PIL import Image
from django.core.exceptions import ValidationError
+from django.core.files import File
from django.contrib.gis.db import models
from django.contrib.sitemaps import Sitemap
from django.db.models.signals import post_save
@@ -25,6 +26,22 @@ from .readexif import readexif
from .utils import resize_image
+def add_mp4(filepath, luxvideo):
+ full_filepath = "/home/lxf/sites/django/luxagraf.net/"+filepath
+ v = open(full_filepath, "rb")
+ django_file = File(v)
+ video = LuxVideo.objects.get(title=luxvideo)
+ video.video_mp4.save(filepath, django_file, save=True)
+
+
+def add_webm(filepath, luxvideo):
+ full_filepath = "/home/lxf/sites/django/luxagraf.net/"+filepath
+ v = open(full_filepath, "rb")
+ django_file = File(v)
+ video = LuxVideo.objects.get(title=luxvideo)
+ video.video_webm.save(filepath, django_file, save=True)
+
+
def get_upload_path(self, filename):
return "images/original/%s/%s" % (datetime.datetime.today().strftime("%Y"), filename)