From c8fcf14626873ad4bbe91788aadb60cfa488beda Mon Sep 17 00:00:00 2001 From: Étienne Loks Date: Sun, 19 Aug 2012 16:21:27 +0200 Subject: Models: Automaticaly add read attributes for marker properties --- chimere/models.py | 10 ++++++++++ debian/control | 3 ++- docs/install.rst | 4 +++- docs/upgrade.rst | 5 +++-- requirements.txt | 1 + 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 `_ - python-simplejson - python-gdal + - `unidecode _ - `lxml `_ - `jquery `_ version 1.7.1 or better - `jquery-ui `_ @@ -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 `_. 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 -- cgit v1.2.3