diff options
Diffstat (limited to 'chimere/main/models.py')
-rw-r--r-- | chimere/main/models.py | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/chimere/main/models.py b/chimere/main/models.py index 198b837..40204d1 100644 --- a/chimere/main/models.py +++ b/chimere/main/models.py @@ -257,6 +257,32 @@ Format YYYY-MM-DD")) properties.append(property) return properties + def saveProperties(self, values): + """ + Save properties + """ + for propertymodel in PropertyModel.objects.filter(available=True): + properties = Property.objects.filter(marker=self, + propertymodel=propertymodel).all() + # in case of multiple edition as the same time delete arbitrary + # the others + if len(properties) > 1: + for property in properties[1:]: + property.delete() + val = u"" + if unicode(propertymodel.id) in values: + val = values[unicode(propertymodel.id)] + # new property + if not properties: + new_property = Property.objects.create(marker=self, + propertymodel=propertymodel, + value=val) + new_property.save() + else: + property = properties[0] + property.value = val + property.save() + def getGeoJSON(self, categories_id=[]): '''Return a GeoJSON string ''' |