summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorluxagraf <sng@luxagraf.net>2016-06-17 10:21:26 -0400
committerluxagraf <sng@luxagraf.net>2016-06-17 10:21:26 -0400
commitb658d4b38f1aab3ed1bdc629300392c1b3e9e8fa (patch)
tree28eefd84cd586f23f1b1e7d96c4b58c229b7e183 /app
parentcec274a4b7de8e07a3d7dc29127ba18f0dd42305 (diff)
fixed notes to be like an instagram for the web also tweaked styles for
picwide captions and added support for show camera make, model and lens
Diffstat (limited to 'app')
-rw-r--r--app/jrnl/models.py12
-rw-r--r--app/notes/admin.py3
-rw-r--r--app/notes/migrations/0004_auto_20160616_1444.py27
-rw-r--r--app/notes/migrations/0005_auto_20160616_1445.py20
-rw-r--r--app/notes/models.py6
-rw-r--r--app/photos/models.py2
-rw-r--r--app/utils/views.py10
7 files changed, 75 insertions, 5 deletions
diff --git a/app/jrnl/models.py b/app/jrnl/models.py
index d19e39d..874da74 100644
--- a/app/jrnl/models.py
+++ b/app/jrnl/models.py
@@ -43,13 +43,23 @@ def parse_image(s):
i = LuxImage.objects.get(image__icontains=src)
cl = img['class']
caption = False
+ exif = False
if len(cl) > 1:
css_class = cl[0]
if cl[1] == 'caption':
caption = True
+ if cl[1] == 'exif':
+ exif = True
+ if len(cl) > 2:
+ css_class = cl[0]
+ if cl[1] == 'caption':
+ caption = True
+ if cl[2] == 'exif':
+ exif = True
+ print('caption'+str(caption))
else:
css_class = cl[0]
- c = Context({'image': i, 'caption': caption})
+ c = Context({'image': i, 'caption': caption, 'exif': exif})
return render_to_string("lib/img_%s.html" % css_class, c)
diff --git a/app/notes/admin.py b/app/notes/admin.py
index 3e15be2..e84b7a0 100644
--- a/app/notes/admin.py
+++ b/app/notes/admin.py
@@ -2,11 +2,10 @@ from django.contrib import admin
from django.contrib.gis.admin import OSMGeoAdmin
from notes.models import Note, LuxNote
-from utils.widgets import AdminImageWidget, LGEntryForm, LGEntryFormSmall, OLAdminBase
+from utils.widgets import LGEntryForm, OLAdminBase
class LuxNoteAdmin(OLAdminBase):
- form = LGEntryFormSmall
prepopulated_fields = {"slug": ('title',)}
list_display = ('slug', 'pub_date', 'location')
fieldsets = (
diff --git a/app/notes/migrations/0004_auto_20160616_1444.py b/app/notes/migrations/0004_auto_20160616_1444.py
new file mode 100644
index 0000000..76b1f3a
--- /dev/null
+++ b/app/notes/migrations/0004_auto_20160616_1444.py
@@ -0,0 +1,27 @@
+# -*- coding: utf-8 -*-
+# Generated by Django 1.9 on 2016-06-16 14:44
+from __future__ import unicode_literals
+
+from django.db import migrations, models
+import django.utils.timezone
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ('photos', '0010_auto_20160517_0906'),
+ ('notes', '0003_auto_20160208_1120'),
+ ]
+
+ operations = [
+ migrations.AddField(
+ model_name='luxnote',
+ name='images',
+ field=models.ManyToManyField(to='photos.LuxImage'),
+ ),
+ migrations.AlterField(
+ model_name='luxnote',
+ name='pub_date',
+ field=models.DateTimeField(default=django.utils.timezone.now),
+ ),
+ ]
diff --git a/app/notes/migrations/0005_auto_20160616_1445.py b/app/notes/migrations/0005_auto_20160616_1445.py
new file mode 100644
index 0000000..129bbc2
--- /dev/null
+++ b/app/notes/migrations/0005_auto_20160616_1445.py
@@ -0,0 +1,20 @@
+# -*- coding: utf-8 -*-
+# Generated by Django 1.9 on 2016-06-16 14:45
+from __future__ import unicode_literals
+
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ('notes', '0004_auto_20160616_1444'),
+ ]
+
+ operations = [
+ migrations.AlterField(
+ model_name='luxnote',
+ name='images',
+ field=models.ManyToManyField(blank=True, null=True, to='photos.LuxImage'),
+ ),
+ ]
diff --git a/app/notes/models.py b/app/notes/models.py
index 775c78c..1acf966 100644
--- a/app/notes/models.py
+++ b/app/notes/models.py
@@ -17,6 +17,8 @@ import markdown
from utils.widgets import markdown_to_html
from daily.models import CheckIn
+from photos.models import LuxImage
+from jrnl.models import render_images
def twitter_truncate(txt):
@@ -32,6 +34,7 @@ class LuxNote(models.Model):
body_markdown = models.TextField('Note')
point = models.PointField(blank=True, null=True)
location = models.ForeignKey(Location, blank=True, null=True)
+ images = models.ManyToManyField(LuxImage, blank=True, null=True)
def __str__(self):
return self.title
@@ -63,7 +66,8 @@ class LuxNote(models.Model):
def save(self, *args, **kwargs):
- self.body_html = markdown_to_html(self.body_markdown)
+ md = render_images(self.body_markdown)
+ self.body_html = markdown_to_html(md)
if not self.point:
self.point = CheckIn.objects.latest().point
try:
diff --git a/app/photos/models.py b/app/photos/models.py
index 9ec68e0..e90a079 100644
--- a/app/photos/models.py
+++ b/app/photos/models.py
@@ -86,6 +86,8 @@ class LuxImage(models.Model):
def get_image_by_size(self, size="original"):
base = self.get_image_name()
+ if size == "admin_insert":
+ return "images/%s/%s.%s" % (self.pub_date.strftime("%Y"), base, self.get_image_ext())
if size == "original":
return "%soriginal/%s/%s.%s" % (settings.IMAGES_URL, self.pub_date.strftime("%Y"), base, self.get_image_ext())
else:
diff --git a/app/utils/views.py b/app/utils/views.py
index f28a8cd..b1decf6 100644
--- a/app/utils/views.py
+++ b/app/utils/views.py
@@ -1,5 +1,7 @@
from django.views.generic import ListView
-
+from photos.models import LuxImage
+from django.shortcuts import render_to_response
+from django.template import RequestContext
class PaginatedListView(ListView):
"""
@@ -17,3 +19,9 @@ class PaginatedListView(ListView):
print(request.page_url)
request.page = int(self.kwargs['page'])
return super(PaginatedListView, self).dispatch(request, *args, **kwargs)
+
+
+def insert_image(request):
+ images = LuxImage.objects.all()[:50]
+ return render_to_response('admin/insert_images.html', {'images': images, 'textarea_id': request.GET['textarea']}, context_instance=RequestContext(request))
+