diff options
Diffstat (limited to 'chimere/models.py')
| -rw-r--r-- | chimere/models.py | 27 |
1 files changed, 23 insertions, 4 deletions
diff --git a/chimere/models.py b/chimere/models.py index 2454c86..ca608e8 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 @@ -38,7 +39,7 @@ from django import forms from django.utils.translation import ugettext_lazy as _ from chimere.widgets import PointField, RouteField, SelectMultipleField, \ - TextareaWidget + TextareaWidget, DatePickerWidget from chimere.managers import BaseGeoManager from chimere.utils import KMLManager, OSMManager, ShapefileManager @@ -233,9 +234,11 @@ class GeographicItem(models.Model): categories = SelectMultipleField(SubCategory) submiter_session_key = models.CharField(_(u"Submitter session key"), blank=True, null=True, max_length=40) + submiter_name = models.CharField(_(u"Submitter name or nickname"), + blank=True, null=True, max_length=40) submiter_email = models.EmailField(_(u"Submitter email"), blank=True, null=True) - submiter_comment = models.CharField(_(u"Submitter comment"), max_length=200, + submiter_comment = models.TextField(_(u"Submitter comment"), max_length=200, blank=True, null=True) STATUS = (('S', _(u'Submited')), ('A', _(u'Available')), @@ -301,6 +304,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()] @@ -889,12 +901,19 @@ class PropertyModel(models.Model): name = models.CharField(_(u"Name"), max_length=150) order = models.IntegerField(_(u"Order")) available = models.BooleanField(_(u"Available")) + mandatory = models.BooleanField(_(u"Mandatory")) + subcategories = SelectMultipleField(SubCategory, related_name='properties', + blank=True, verbose_name=_(u"Restricted to theses sub-categories"), + help_text=_(u"If no sub-category is set all the property applies to all " + u"sub-categories")) TYPE = (('T', _('Text')), ('L', _('Long text')), - ('P', _('Password'))) + ('P', _('Password')), + ('D', _("Date"))) TYPE_WIDGET = {'T':forms.TextInput, 'L':TextareaWidget, - 'P':forms.PasswordInput} + 'P':forms.PasswordInput, + 'D':DatePickerWidget} type = models.CharField(_(u"Type"), max_length=1, choices=TYPE) def __unicode__(self): return self.name |
