diff options
Diffstat (limited to 'app')
-rw-r--r-- | app/jrnl/models.py | 2 | ||||
-rw-r--r-- | app/photos/migrations/0017_auto_20161130_1218.py | 38 | ||||
-rw-r--r-- | app/photos/migrations/0018_auto_20161130_1218.py | 29 | ||||
-rw-r--r-- | app/photos/models.py | 33 | ||||
-rw-r--r-- | app/utils/views.py | 14 |
5 files changed, 106 insertions, 10 deletions
diff --git a/app/jrnl/models.py b/app/jrnl/models.py index 4a2f8e8..0124182 100644 --- a/app/jrnl/models.py +++ b/app/jrnl/models.py @@ -165,7 +165,7 @@ class Entry(models.Model): else: md = image_url_replace(self.body_markdown) self.body_html = markdown.markdown(md, extensions=['extra'], safe_mode=False) - self.has_video = False #parse_video(self.body_html) + self.has_video = parse_video(self.body_html) try: self.location = Location.objects.filter(geometry__contains=self.point).get() except Location.DoesNotExist: diff --git a/app/photos/migrations/0017_auto_20161130_1218.py b/app/photos/migrations/0017_auto_20161130_1218.py new file mode 100644 index 0000000..8d5a496 --- /dev/null +++ b/app/photos/migrations/0017_auto_20161130_1218.py @@ -0,0 +1,38 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.9 on 2016-11-30 12:18 +from __future__ import unicode_literals + +import datetime +from django.db import migrations, models +import photos.models + + +class Migration(migrations.Migration): + + dependencies = [ + ('photos', '0016_auto_20161022_1411'), + ] + + operations = [ + migrations.CreateModel( + name='LuxVideo', + fields=[ + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('video_mp4', models.FileField(blank=True, null=True, upload_to=photos.models.get_vid_upload_path)), + ('video_webm', models.FileField(blank=True, null=True, upload_to=photos.models.get_vid_upload_path)), + ('video_poster', models.FileField(blank=True, null=True, upload_to=photos.models.get_vid_upload_path)), + ('title', models.CharField(blank=True, max_length=300, null=True)), + ('pub_date', models.DateTimeField(default=datetime.datetime.now)), + ], + options={ + 'verbose_name_plural': 'Videos', + 'ordering': ('-pub_date', 'id'), + 'get_latest_by': 'pub_date', + }, + ), + migrations.AlterField( + model_name='luximage', + name='pub_date', + field=models.DateTimeField(default=datetime.datetime.now), + ), + ] diff --git a/app/photos/migrations/0018_auto_20161130_1218.py b/app/photos/migrations/0018_auto_20161130_1218.py new file mode 100644 index 0000000..784175a --- /dev/null +++ b/app/photos/migrations/0018_auto_20161130_1218.py @@ -0,0 +1,29 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.9 on 2016-11-30 12:18 +from __future__ import unicode_literals + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('photos', '0017_auto_20161130_1218'), + ] + + operations = [ + migrations.RemoveField( + model_name='luximage', + name='is_video', + ), + migrations.AddField( + model_name='luxvideo', + name='vimeo_url', + field=models.CharField(blank=True, max_length=300, null=True), + ), + migrations.AddField( + model_name='luxvideo', + name='youtube_url', + field=models.CharField(blank=True, max_length=80, null=True), + ), + ] diff --git a/app/photos/models.py b/app/photos/models.py index 4249e6f..0d123c3 100644 --- a/app/photos/models.py +++ b/app/photos/models.py @@ -25,6 +25,8 @@ from django.db.models.signals import m2m_changed def get_upload_path(self, filename): return "images/original/%s/%s" % (datetime.datetime.today().strftime("%Y"), filename) +def get_vid_upload_path(self, filename): + return "images/videos/%s/%s" % (datetime.datetime.today().strftime("%Y"), filename) class LuxImageSize(models.Model): name = models.CharField(null=True, blank=True, max_length=30) @@ -49,7 +51,7 @@ class LuxImage(models.Model): photo_credit_source = models.CharField(null=True, blank=True, max_length=300) photo_credit_url = models.CharField(null=True, blank=True, max_length=300) caption = models.TextField(blank=True, null=True) - pub_date = models.DateTimeField() + pub_date = models.DateTimeField(default=datetime.datetime.now) exif_raw = models.TextField(blank=True, null=True) exif_aperture = models.CharField(max_length=50, blank=True, null=True) exif_make = models.CharField(max_length=50, blank=True, null=True) @@ -64,7 +66,6 @@ class LuxImage(models.Model): point = models.PointField(null=True, blank=True) location = models.ForeignKey(Location, null=True, blank=True) is_public = models.BooleanField(default=True) - is_video = models.BooleanField(default=False) sizes = models.ManyToManyField(LuxImageSize, blank=True) flickr_id = models.CharField(null=True, blank=True, max_length=80) twitter_link = models.CharField(null=True, blank=True, max_length=300) @@ -81,17 +82,15 @@ class LuxImage(models.Model): else: return "%s" % self.pk + def get_type(self): + return str(self.__class__.__name__) + def get_admin_image(self): for size in self.sizes.all(): if size.width and size.width <= 820 or size.height and size.height<=800: print("Size name" +size.name) return self.get_image_by_size(size.name) - def get_video_base_url(self): - if self.is_video: - return self.image.url[:-4] - - def get_largest_image(self): t = [] for size in self.sizes.all(): @@ -255,6 +254,26 @@ class LuxGallery(models.Model): thumbs.allow_tags = True +class LuxVideo(models.Model): + video_mp4 = models.FileField(blank=True, null=True, upload_to=get_vid_upload_path) + video_webm = models.FileField(blank=True, null=True, upload_to=get_vid_upload_path) + video_poster = models.FileField(blank=True, null=True, upload_to=get_vid_upload_path) + title = models.CharField(null=True, blank=True, max_length=300) + pub_date = models.DateTimeField(default=datetime.datetime.now) + youtube_url = models.CharField(null=True, blank=True, max_length=80) + vimeo_url = models.CharField(null=True, blank=True, max_length=300) + + def __str__(self): + return self.title + + def get_type(self): + return str(self.__class__.__name__) + + class Meta: + ordering = ('-pub_date', 'id') + verbose_name_plural = 'Videos' + get_latest_by = 'pub_date' + class Photo(models.Model): description = models.TextField(blank=True, null=True) title = models.CharField(blank=True, max_length=300) diff --git a/app/utils/views.py b/app/utils/views.py index b1decf6..c5f3f59 100644 --- a/app/utils/views.py +++ b/app/utils/views.py @@ -1,5 +1,6 @@ +from itertools import chain from django.views.generic import ListView -from photos.models import LuxImage +from photos.models import LuxImage, LuxVideo from django.shortcuts import render_to_response from django.template import RequestContext @@ -22,6 +23,15 @@ class PaginatedListView(ListView): def insert_image(request): + """ + The view that handles the admin insert image/video feature + """ images = LuxImage.objects.all()[:50] - return render_to_response('admin/insert_images.html', {'images': images, 'textarea_id': request.GET['textarea']}, context_instance=RequestContext(request)) + videos = LuxVideo.objects.all()[:10] + object_list = sorted( + chain(images, videos), + key=lambda instance: instance.pub_date, + reverse=True + ) + return render_to_response('admin/insert_images.html', {'object_list': object_list, 'textarea_id': request.GET['textarea']}, context_instance=RequestContext(request)) |