summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorÉtienne Loks <etienne.loks@peacefrogs.net>2012-08-19 16:21:27 +0200
committerÉtienne Loks <etienne.loks@peacefrogs.net>2012-08-19 16:21:27 +0200
commitc8fcf14626873ad4bbe91788aadb60cfa488beda (patch)
tree679daba9ee80e429aec05a7f30f64e19d2237616
parent647f527cf506b362ff02ddf58da2490768b8bf7a (diff)
downloadChimère-c8fcf14626873ad4bbe91788aadb60cfa488beda.tar.bz2
Chimère-c8fcf14626873ad4bbe91788aadb60cfa488beda.zip
Models: Automaticaly add read attributes for marker properties
-rw-r--r--chimere/models.py10
-rw-r--r--debian/control3
-rw-r--r--docs/install.rst4
-rw-r--r--docs/upgrade.rst5
-rw-r--r--requirements.txt1
5 files changed, 19 insertions, 4 deletions
diff --git a/chimere/models.py b/chimere/models.py
index c053e1b..27875ec 100644
--- a/chimere/models.py
+++ b/chimere/models.py
@@ -25,6 +25,7 @@ import simplejson as json
from lxml import etree
from datetime import datetime, timedelta
from subprocess import Popen, PIPE
+import unidecode
from django.conf import settings
from django.contrib.gis.db import models
@@ -301,6 +302,15 @@ class Marker(GeographicItem):
def __unicode__(self):
return self.name
+ def __init__(self, *args, **kwargs):
+ super(Marker, self).__init__(*args, **kwargs)
+ # add read attributes for properties
+ for property in self.getProperties():
+ attr_name = unidecode.unidecode(property.propertymodel.name).lower()
+ attr_name = re.sub(r'\W+','_', attr_name.strip())
+ if not hasattr(self, attr_name):
+ setattr(self, attr_name, property.value)
+
def get_init_multi(self):
multis = [forms.model_to_dict(multi)
for multi in self.multimedia_files.all()]
diff --git a/debian/control b/debian/control
index 7317430..92cfa21 100644
--- a/debian/control
+++ b/debian/control
@@ -4,6 +4,7 @@ Depends: python-django (>=1.3), 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-unidecode
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 2f66879..d0f918a 100644
--- a/docs/install.rst
+++ b/docs/install.rst
@@ -32,6 +32,7 @@ Prerequisites
- `Beautiful Soup <http://www.crummy.com/software/BeautifulSoup/>`_
- python-simplejson
- python-gdal
+ - `unidecode <http://pypi.python.org/pypi/Unidecode>_
- `lxml <http://lxml.de/>`_
- `jquery <http://jquery.com/>`_ version 1.7.1 or better
- `jquery-ui <http://jqueryui.com/>`_
@@ -59,7 +60,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 python-unidecode \
+ gpsbabel
If these packages do not exist in your distribution's repository, please refer
to the applications' websites.
diff --git a/docs/upgrade.rst b/docs/upgrade.rst
index 9f36eb4..aca3985 100644
--- a/docs/upgrade.rst
+++ b/docs/upgrade.rst
@@ -44,14 +44,15 @@ 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-simplejson libjs-jquery-ui python-unidecode
Debian Wheezy
+++++++++++++
.. code-block:: bash
- apt-get install python-django-south python-simplejson libjs-jquery-ui
+ apt-get install python-django-south python-simplejson libjs-jquery-ui \
+ python-unidecode
If you are planing to do major import consider the install of `Celery
<http://celeryproject.org/>`_.
diff --git a/requirements.txt b/requirements.txt
index e1f2c46..843a351 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -5,3 +5,4 @@ pil
lxml
south==0.7.3
simplejson
+unidecode