diff options
-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 | ||||
-rw-r--r-- | design/templates/admin/insert_images.html | 24 | ||||
-rwxr-xr-x[-rw-r--r--] | design/templates/admin/links/link/change_form.html | 0 | ||||
-rw-r--r-- | design/templates/details/resume.html | 2 |
8 files changed, 119 insertions, 23 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)) diff --git a/design/templates/admin/insert_images.html b/design/templates/admin/insert_images.html index f9a2fa6..4841f50 100644 --- a/design/templates/admin/insert_images.html +++ b/design/templates/admin/insert_images.html @@ -102,20 +102,20 @@ $(function(){ <button id="add_id_image" onClick="window.parent.open('/admin/photos/luximage/add/?_to_field=id&_popup=1')">Upload Image <img src="/static/admin/img/icon-addlink.svg" alt="Add"> </button> - <div class="up-wrapper">{% for image in images %} + <div class="up-wrapper">{% for object in object_list %} <div class="item-wrapper"> - <figure class="item" > - <img src="{% get_image_by_size image 'tn' %}" /> - <figcaption>{{image.id}} - {{image.title}} {% if image.caption %}– {{image.caption}}{%endif%}</figcaption> + <figure class="item" > + <img src="{% if object.get_type == "LuxImage" %}{% get_image_by_size object 'tn' %}{%else%}{{object.video_poster.url}}{%endif%}" /> + <figcaption>{{object.id}} - {{object.title}} {% if object.caption %}– {{object.caption}}{%endif%}</figcaption> </figure> - <ul class="actions">{%if image.is_video %} - <li><a data-is-video="true" data-src="{{image.get_video_base_url}}" data-id="{{image.id}}" data-class="vid" class="insert" href="">Insert video</a>{%else%} - <li><a data-src="{% get_image_by_size image 'admin_insert' %}" data-id="{{image.id}}" data-class="picwide" class="insert" href="">full width</a></li> - <li><a data-src="{% get_image_by_size image 'admin_insert' %}" data-id="{{image.id}}" data-class="picfull" class="insert" href="">column width</a></li> - <li><a data-src="{% get_image_by_size image 'admin_insert' %}" data-id="{{image.id}}" data-class="picwide" data-caption="true" class="insert" href="">full width cap</a></li> - <li><a data-src="{% get_image_by_size image 'admin_insert' %}" data-id="{{image.id}}" data-class="picfull" data-caption="true" class="insert" href="">column width cap</a></li> - <li><a data-src="{% get_image_by_size image 'admin_insert' %}" data-id="{{image.id}}" data-class="cluster pic" class="insert" href="">cluster</a></li> - <li><a href="/admin/photos/luximage/{{image.pk}}/change/">Edit Image</a></li>{%endif%} + <ul class="actions">{%if object.get_type == "LuxVideo" %} + <li><a data-is-video="true" data-src="{{object.image.url}}" data-id="{{object.id}}" data-class="vid" class="insert" href="">Insert video</a>{%else%} + <li><a data-src="{% get_image_by_size object 'admin_insert' %}" data-id="{{object.id}}" data-class="picwide" class="insert" href="">full width</a></li> + <li><a data-src="{% get_image_by_size object 'admin_insert' %}" data-id="{{object.id}}" data-class="picfull" class="insert" href="">column width</a></li> + <li><a data-src="{% get_image_by_size object 'admin_insert' %}" data-id="{{object.id}}" data-class="picwide" data-caption="true" class="insert" href="">full width cap</a></li> + <li><a data-src="{% get_image_by_size object 'admin_insert' %}" data-id="{{object.id}}" data-class="picfull" data-caption="true" class="insert" href="">column width cap</a></li> + <li><a data-src="{% get_image_by_size object 'admin_insert' %}" data-id="{{object.id}}" data-class="cluster pic" class="insert" href="">cluster</a></li> + <li><a href="/admin/photos/luximage/{{object.pk}}/change/">Edit Image</a></li>{%endif%} </ul> </div> {% endfor %} diff --git a/design/templates/admin/links/link/change_form.html b/design/templates/admin/links/link/change_form.html index aa1769f..aa1769f 100644..100755 --- a/design/templates/admin/links/link/change_form.html +++ b/design/templates/admin/links/link/change_form.html diff --git a/design/templates/details/resume.html b/design/templates/details/resume.html index c36f986..5c47b2c 100644 --- a/design/templates/details/resume.html +++ b/design/templates/details/resume.html @@ -12,7 +12,7 @@ <main role="main"> <article role="main"> <h1>{{object.title|safe|smartypants|widont}}</h1> - <p>This article was published in {{object.publisher}}, you can view <a href="{{object.url}}">the original</a> there, complete with graphics, comments and other fun stuff.</p> + <p><i>This article was published in {{object.publisher}}, you can view <a href="{{object.url}}">the original</a> there, complete with graphics, comments and other fun stuff.</i></p> <div class="post--article" style="margin-top: 3em"> {{object.body_html|safe|smartypants|widont}} </div> |