summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--chimere/feeds.py4
-rw-r--r--chimere/models.py37
-rw-r--r--chimere/static/chimere/css/forms.css5
-rw-r--r--chimere/static/chimere/js/textareas.js1
-rw-r--r--chimere/static/chimere/js/utils.js8
-rw-r--r--chimere/widgets.py10
-rw-r--r--debian/control5
-rw-r--r--docs/install.rst6
-rw-r--r--docs/upgrade.rst4
9 files changed, 70 insertions, 10 deletions
diff --git a/chimere/feeds.py b/chimere/feeds.py
index d5ae5ef..057fe5e 100644
--- a/chimere/feeds.py
+++ b/chimere/feeds.py
@@ -1,8 +1,8 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
+# Copyright (C) 2012 Étienne Loks <etienne.loks_AT_peacefrogsDOTnet>
# Copyright (C) 2010 Pierre Clarenc <pierre.crc_AT_gmailDOTcom>,
-# Samuel Renard <renard.samuel_AT_gmailDOTcom>,
-# Étienne Loks <etienne.loks_AT_peacefrogsDOTnet>
+# Samuel Renard <renard.samuel_AT_gmailDOTcom>
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as
diff --git a/chimere/models.py b/chimere/models.py
index 4d66278..e98c97b 100644
--- a/chimere/models.py
+++ b/chimere/models.py
@@ -20,7 +20,7 @@
"""
Models description
"""
-import os, datetime, re, string
+import os, datetime, pyexiv2, re, string
import simplejson as json
from lxml import etree
from PIL import Image
@@ -609,11 +609,44 @@ def scale_image(max_x, pair):
new_y = (float(max_x) / x) * y
return (int(max_x), int(new_y))
+
+IMAGE_EXIF_ORIENTATION_MAP = {
+ 1: 0,
+ 8: 2,
+ 3: 3,
+ 6: 4,
+}
+
+PYEXIV2_OLD_API = not hasattr(pyexiv2, 'ImageMetadata')
+
def picturefile_post_save(sender, **kwargs):
if not kwargs['instance']:
return
picturefile = kwargs['instance']
+ if kwargs['created']:
+ filename = picturefile.picture.path
+ metadata = None
+ if PYEXIV2_OLD_API:
+ metadata = pyexiv2.Image(filename)
+ metadata.readMetadata()
+ else:
+ metadata = pyexiv2.ImageMetadata(filename)
+ metadata.read()
+ orientation = metadata['Exif.Image.Orientation'].value \
+ if 'Exif.Image.Orientation' in metadata else None
+ print "orientation", orientation
+ if orientation and orientation in IMAGE_EXIF_ORIENTATION_MAP \
+ and orientation > 1:
+ metadata['Exif.Image.Orientation'] = 1
+ if PYEXIV2_OLD_API:
+ metadata.writeMetadata()
+ else:
+ metadata.write()
+ im = Image.open(filename)
+ im = im.transpose(IMAGE_EXIF_ORIENTATION_MAP[orientation])
+ im.save(filename)
+
if not picturefile.thumbnailfile:
file = picturefile.picture
# defining the filename and the thumbnail filename
@@ -650,7 +683,7 @@ def picturefile_post_save(sender, **kwargs):
picturefile.thumbnailfile = short_name
picturefile.save()
- if not kwargs['instance'] or not kwargs['created']:
+ if not kwargs['created']:
return
pfs = PictureFile.objects.filter(marker=picturefile.marker).exclude(
pk=picturefile.pk).order_by('order')
diff --git a/chimere/static/chimere/css/forms.css b/chimere/static/chimere/css/forms.css
index 5740a62..46acdb9 100644
--- a/chimere/static/chimere/css/forms.css
+++ b/chimere/static/chimere/css/forms.css
@@ -124,3 +124,8 @@ div.bottomform{
display:None
}
+.object-tools{
+ width:90px;
+ overflow:hidden;
+ height:16px;
+}
diff --git a/chimere/static/chimere/js/textareas.js b/chimere/static/chimere/js/textareas.js
index fec83b8..048718d 100644
--- a/chimere/static/chimere/js/textareas.js
+++ b/chimere/static/chimere/js/textareas.js
@@ -20,6 +20,7 @@ See the file COPYING for details.
tinyMCE.init({
mode : "textareas",
theme : "advanced",
+ editor_selector : "mceEditor",
relative_urls : false,
theme_advanced_buttons1 : "bold,italic,underline,strikethrough,separator,bullist,numlist,separator,hr,separator,link",
theme_advanced_buttons2 : "",
diff --git a/chimere/static/chimere/js/utils.js b/chimere/static/chimere/js/utils.js
index e8981c6..460e843 100644
--- a/chimere/static/chimere/js/utils.js
+++ b/chimere/static/chimere/js/utils.js
@@ -241,3 +241,11 @@ function isValidEmailAddress(emailAddress) {
var pattern = new RegExp(/^((([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*)|((\x22)((((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(([\x01-\x08\x0b\x0c\x0e-\x1f\x7f]|\x21|[\x23-\x5b]|[\x5d-\x7e]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(\\([\x01-\x09\x0b\x0c\x0d-\x7f]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))))*(((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(\x22)))@((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?$/i);
return pattern.test(emailAddress);
};
+
+/* remove multiple, leading or trailing spaces */
+function trim(s) {
+ s = s.replace(/(^\s*)|(\s*$)/gi,"");
+ s = s.replace(/[ ]{2,}/gi," ");
+ s = s.replace(/\n /,"\n");
+ return s;
+}
diff --git a/chimere/widgets.py b/chimere/widgets.py
index a096cde..a30b596 100644
--- a/chimere/widgets.py
+++ b/chimere/widgets.py
@@ -145,6 +145,16 @@ class TextareaWidget(forms.Textarea):
class Media:
js = ["%stiny_mce.js" % settings.TINYMCE_URL,
"%schimere/js/textareas.js" % settings.STATIC_URL,]
+ def render(self, *args, **kwargs):
+ if 'attrs' not in kwargs:
+ kwargs['attrs'] = {}
+ if 'class' not in kwargs['attrs']:
+ kwargs['attrs']['class'] = ''
+ else:
+ kwargs['attrs']['class'] += ' '
+ kwargs['attrs']['class'] += 'mceEditor'
+ rendered = super(TextareaWidget, self).render(*args, **kwargs)
+ return mark_safe(rendered)
def render(self, *args, **kwargs):
rendered = super(TextareaWidget, self).render(*args, **kwargs)
diff --git a/debian/control b/debian/control
index 7317430..1c93646 100644
--- a/debian/control
+++ b/debian/control
@@ -1,9 +1,10 @@
Package: python-django-chimere
Version: 2.0
-Depends: python-django (>=1.3), python-gdal, python-psycopg2,
+Depends: python-django (>=1.4), python-gdal, python-psycopg2,
python-beautifulsoup, python-imaging, libjs-jquery,
libjs-jquery-ui, libjs-jquery-ui-theme-base,
postgresql-9.1, postgresql-9.1-postgis, gettext,
- python-simplejson, gpsbabel, python-django-south
+ python-simplejson, gpsbabel, python-django-south,
+ python-pyexiv2
Recommends: tinymce, python-django-celery, python-kombu
Suggests: libjs-jquery-ui-theme-south-street
diff --git a/docs/install.rst b/docs/install.rst
index 163c980..e1cb458 100644
--- a/docs/install.rst
+++ b/docs/install.rst
@@ -29,6 +29,7 @@ Prerequisites
- `gettext <http://www.gnu.org/software/gettext/>`_
- `psycopg2 <http://freshmeat.net/projects/psycopg/>`_
- `Python Imaging Library <http://www.pythonware.com/products/pil/>`_
+ - `pyexiv2 <http://tilloy.net/dev/pyexiv2/>`_
- `Beautiful Soup <http://www.crummy.com/software/BeautifulSoup/>`_
- python-simplejson
- python-gdal
@@ -60,7 +61,8 @@ Linux distribution repositories. For instance on Debian Wheezy::
python-beautifulsoup tinymce apache2 libgeos-3.3.3 proj-bin gdal-bin \
python-gdal python-lxml python-psycopg2 python-imaging gettext \
postgresql-9.1 postgresql-9.1-postgis libjs-jquery libjs-jquery-ui \
- python-django-celery python-simplejson python-gdal gpsbabel
+ python-django-celery python-simplejson python-gdal gpsbabel \
+ python-pyexiv2
On Debian Squeeze (you need to activate backports)::
@@ -70,7 +72,7 @@ On Debian Squeeze (you need to activate backports)::
apache2 libgeos-3.2.0 proj-bin gdal-bin python-gdal python-lxml \
python-psycopg2 python-imaging gettext postgresql-8.4 \
postgresql-8.4-postgis libjs-jquery libjs-jquery-ui python-simplejson \
- python-gdal gpsbabel
+ python-gdal gpsbabel python-pyexiv2
If these packages do not exist in your distribution's repository, please refer
diff --git a/docs/upgrade.rst b/docs/upgrade.rst
index aca3985..65e3734 100644
--- a/docs/upgrade.rst
+++ b/docs/upgrade.rst
@@ -44,7 +44,7 @@ Activate the backports: http://backports-master.debian.org/Instructions/
Then install the new dependencies::
apt-get install -t squeeze-backports python-django python-django-south \
- python-simplejson libjs-jquery-ui python-unidecode
+ python-simplejson libjs-jquery-ui python-pyexiv2
Debian Wheezy
+++++++++++++
@@ -52,7 +52,7 @@ Debian Wheezy
.. code-block:: bash
apt-get install python-django-south python-simplejson libjs-jquery-ui \
- python-unidecode
+ python-pyexiv2
If you are planing to do major import consider the install of `Celery
<http://celeryproject.org/>`_.