summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorÉtienne Loks <etienne.loks@proxience.com>2015-09-23 23:38:21 +0200
committerÉtienne Loks <etienne.loks@proxience.com>2015-09-23 23:38:21 +0200
commit3d3d618fc627fc4568c826e11a296a5e75e2ebb9 (patch)
tree0e4c24d715b9d4a678eff9015f498b256a466c2b
parentcf03b1eea89f4a7a0c0b03629a81a0d8d588a35f (diff)
parent5d2cac2cb5a03c8f55a2396e4c4ce13911a9149c (diff)
downloadChimère-3d3d618fc627fc4568c826e11a296a5e75e2ebb9.tar.bz2
Chimère-3d3d618fc627fc4568c826e11a296a5e75e2ebb9.zip
Merge branch 'v2.1' into v2.2
Conflicts: chimere/admin.py chimere/models.py
-rw-r--r--chimere/admin.py22
-rw-r--r--chimere/migrations/0009_auto__add_field_importer_default_status.py289
-rw-r--r--chimere/models.py44
-rw-r--r--chimere/static/chimere/js/importer_interface.js24
-rw-r--r--chimere/static/chimere/js/jquery.chimere.js25
-rw-r--r--chimere/templates/chimere/blocks/map_menu.html2
-rw-r--r--chimere/templatetags/chimere_tags.py3
-rw-r--r--chimere/utils.py10
8 files changed, 382 insertions, 37 deletions
diff --git a/chimere/admin.py b/chimere/admin.py
index 521c5a2..60d1141 100644
--- a/chimere/admin.py
+++ b/chimere/admin.py
@@ -25,6 +25,7 @@ import datetime
from django import forms
from django.conf import settings
from django.contrib import admin, messages
+from django.contrib.admin import SimpleListFilter
from django.core.exceptions import ObjectDoesNotExist
from django.db.models import Q
from django.http import HttpResponse, HttpResponseRedirect
@@ -199,14 +200,31 @@ class AreaRouteListFilter(AreaMarkerListFilter):
return queryset
return queryset.filter(area.getIncludeRoute())
+class HasCategoriesListFilter(SimpleListFilter):
+ title = _('Has categories')
+ parameter_name = 'has_category'
+
+ def lookups(self, request, model_admin):
+ return (
+ ('true', _('Yes')),
+ ('false', _('No')),
+ )
+
+ def queryset(self, request, queryset):
+ if self.value() == 'false':
+ return queryset.filter(categories__isnull=True)
+ elif self.value() == 'true':
+ return queryset.exclude(categories__isnull=True)
+ return queryset
+
class MarkerAdmin(admin.ModelAdmin):
"""
Specialized the Point field.
"""
search_fields = ("name",)
list_display = ('name', 'status', 'start_date', 'end_date')
- list_filter = ('status', AreaMarkerListFilter, 'categories', 'start_date',
- 'end_date')
+ list_filter = ('status', AreaMarkerListFilter, 'categories',
+ HasCategoriesListFilter, 'start_date', 'end_date')
actions = [validate, disable, managed_modified, export_to_kml,
export_to_shapefile, export_to_csv]
exclude = ['submiter_session_key', 'import_key', 'import_version',
diff --git a/chimere/migrations/0009_auto__add_field_importer_default_status.py b/chimere/migrations/0009_auto__add_field_importer_default_status.py
new file mode 100644
index 0000000..e29c599
--- /dev/null
+++ b/chimere/migrations/0009_auto__add_field_importer_default_status.py
@@ -0,0 +1,289 @@
+# -*- coding: utf-8 -*-
+import datetime
+from south.db import db
+from south.v2 import SchemaMigration
+from django.db import models
+
+
+class Migration(SchemaMigration):
+
+ def forwards(self, orm):
+ # Adding field 'Importer.default_status'
+ db.add_column('chimere_importer', 'default_status',
+ self.gf('django.db.models.fields.CharField')(default='I', max_length=1),
+ keep_default=False)
+
+
+ def backwards(self, orm):
+ # Deleting field 'Importer.default_status'
+ db.delete_column('chimere_importer', 'default_status')
+
+
+ models = {
+ 'chimere.aggregatedroute': {
+ 'Meta': {'object_name': 'AggregatedRoute', 'db_table': "'chimere_aggregated_routes'", 'managed': 'False'},
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'route': ('django.contrib.gis.db.models.fields.MultiLineStringField', [], {}),
+ 'status': ('django.db.models.fields.CharField', [], {'max_length': '1'}),
+ 'subcategory': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['chimere.SubCategory']"})
+ },
+ 'chimere.area': {
+ 'Meta': {'ordering': "('order', 'name')", 'object_name': 'Area'},
+ 'available': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
+ 'default': ('django.db.models.fields.NullBooleanField', [], {'null': 'True', 'blank': 'True'}),
+ 'default_subcategories': ('chimere.widgets.SelectMultipleField', [], {'to': "orm['chimere.SubCategory']", 'symmetrical': 'False', 'blank': 'True'}),
+ 'dynamic_categories': ('django.db.models.fields.NullBooleanField', [], {'null': 'True', 'blank': 'True'}),
+ 'external_css': ('django.db.models.fields.URLField', [], {'max_length': '200', 'null': 'True', 'blank': 'True'}),
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'layers': ('chimere.widgets.SelectMultipleField', [], {'symmetrical': 'False', 'related_name': "'areas'", 'blank': 'True', 'through': "orm['chimere.AreaLayers']", 'to': "orm['chimere.Layer']"}),
+ 'lower_right_corner': ('django.contrib.gis.db.models.fields.PointField', [], {'default': "'POINT(0 0)'"}),
+ 'name': ('django.db.models.fields.CharField', [], {'max_length': '150'}),
+ 'order': ('django.db.models.fields.IntegerField', [], {'unique': 'True'}),
+ 'restrict_to_extent': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
+ 'subcategories': ('chimere.widgets.SelectMultipleField', [], {'symmetrical': 'False', 'related_name': "'areas'", 'blank': 'True', 'db_table': "'chimere_subcategory_areas'", 'to': "orm['chimere.SubCategory']"}),
+ 'upper_left_corner': ('django.contrib.gis.db.models.fields.PointField', [], {'default': "'POINT(0 0)'"}),
+ 'urn': ('django.db.models.fields.SlugField', [], {'unique': 'True', 'max_length': '50', 'blank': 'True'}),
+ 'welcome_message': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'})
+ },
+ 'chimere.arealayers': {
+ 'Meta': {'ordering': "('order',)", 'object_name': 'AreaLayers'},
+ 'area': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['chimere.Area']"}),
+ 'default': ('django.db.models.fields.NullBooleanField', [], {'null': 'True', 'blank': 'True'}),
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'layer': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['chimere.Layer']"}),
+ 'order': ('django.db.models.fields.IntegerField', [], {})
+ },
+ 'chimere.category': {
+ 'Meta': {'ordering': "['order']", 'object_name': 'Category'},
+ 'available': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
+ 'description': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}),
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'name': ('django.db.models.fields.CharField', [], {'max_length': '150'}),
+ 'order': ('django.db.models.fields.IntegerField', [], {})
+ },
+ 'chimere.color': {
+ 'Meta': {'ordering': "['order']", 'object_name': 'Color'},
+ 'code': ('django.db.models.fields.CharField', [], {'max_length': '6'}),
+ 'color_theme': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['chimere.ColorTheme']"}),
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'order': ('django.db.models.fields.IntegerField', [], {})
+ },
+ 'chimere.colortheme': {
+ 'Meta': {'object_name': 'ColorTheme'},
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'name': ('django.db.models.fields.CharField', [], {'max_length': '150'})
+ },
+ 'chimere.icon': {
+ 'Meta': {'object_name': 'Icon'},
+ 'height': ('django.db.models.fields.IntegerField', [], {}),
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'image': ('django.db.models.fields.files.ImageField', [], {'max_length': '100'}),
+ 'name': ('django.db.models.fields.CharField', [], {'max_length': '150'}),
+ 'width': ('django.db.models.fields.IntegerField', [], {})
+ },
+ 'chimere.importer': {
+ 'Meta': {'object_name': 'Importer'},
+ 'associate_marker_to_way': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
+ 'automatic_update': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
+ 'categories': ('chimere.widgets.SelectMultipleField', [], {'symmetrical': 'False', 'to': "orm['chimere.SubCategory']", 'null': 'True', 'blank': 'True'}),
+ 'default_description': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}),
+ 'default_localisation': ('chimere.widgets.PointField', [], {'null': 'True', 'blank': 'True'}),
+ 'default_name': ('django.db.models.fields.CharField', [], {'max_length': '200', 'null': 'True', 'blank': 'True'}),
+ 'default_status': ('django.db.models.fields.CharField', [], {'default': "'I'", 'max_length': '1'}),
+ 'filtr': ('django.db.models.fields.CharField', [], {'max_length': '200', 'null': 'True', 'blank': 'True'}),
+ 'get_description': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'importer_type': ('django.db.models.fields.CharField', [], {'max_length': '4'}),
+ 'license': ('django.db.models.fields.CharField', [], {'max_length': '100', 'null': 'True', 'blank': 'True'}),
+ 'origin': ('django.db.models.fields.CharField', [], {'max_length': '100', 'null': 'True', 'blank': 'True'}),
+ 'overwrite': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
+ 'source': ('django.db.models.fields.CharField', [], {'max_length': '200', 'null': 'True', 'blank': 'True'}),
+ 'source_file': ('django.db.models.fields.files.FileField', [], {'max_length': '100', 'null': 'True', 'blank': 'True'}),
+ 'source_file_alt': ('django.db.models.fields.files.FileField', [], {'max_length': '100', 'null': 'True', 'blank': 'True'}),
+ 'srid': ('django.db.models.fields.IntegerField', [], {'null': 'True', 'blank': 'True'}),
+ 'state': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}),
+ 'zipped': ('django.db.models.fields.BooleanField', [], {'default': 'False'})
+ },
+ 'chimere.importerkeycategories': {
+ 'Meta': {'object_name': 'ImporterKeyCategories'},
+ 'category': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['chimere.SubCategory']"}),
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'importer': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'key_categories'", 'to': "orm['chimere.Importer']"}),
+ 'key': ('django.db.models.fields.CharField', [], {'max_length': '200'})
+ },
+ 'chimere.layer': {
+ 'Meta': {'object_name': 'Layer'},
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'layer_code': ('django.db.models.fields.TextField', [], {'max_length': '300'}),
+ 'name': ('django.db.models.fields.CharField', [], {'max_length': '150'})
+ },
+ 'chimere.marker': {
+ 'Meta': {'ordering': "('status', 'name')", 'object_name': 'Marker'},
+ 'available_date': ('django.db.models.fields.DateTimeField', [], {'null': 'True', 'blank': 'True'}),
+ 'categories': ('chimere.widgets.SelectMultipleField', [], {'to': "orm['chimere.SubCategory']", 'symmetrical': 'False'}),
+ 'description': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}),
+ 'end_date': ('django.db.models.fields.DateField', [], {'null': 'True', 'blank': 'True'}),
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'import_key': ('django.db.models.fields.CharField', [], {'max_length': '200', 'null': 'True', 'blank': 'True'}),
+ 'import_source': ('django.db.models.fields.CharField', [], {'max_length': '200', 'null': 'True', 'blank': 'True'}),
+ 'import_version': ('django.db.models.fields.IntegerField', [], {'null': 'True', 'blank': 'True'}),
+ 'is_front_page': ('django.db.models.fields.NullBooleanField', [], {'null': 'True', 'blank': 'True'}),
+ 'license': ('django.db.models.fields.CharField', [], {'max_length': '100', 'null': 'True', 'blank': 'True'}),
+ 'modified_since_import': ('django.db.models.fields.BooleanField', [], {'default': 'True'}),
+ 'name': ('django.db.models.fields.CharField', [], {'max_length': '150'}),
+ 'not_for_osm': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
+ 'origin': ('django.db.models.fields.CharField', [], {'max_length': '100', 'null': 'True', 'blank': 'True'}),
+ 'point': ('chimere.widgets.PointField', [], {}),
+ 'ref_item': ('django.db.models.fields.related.ForeignKey', [], {'blank': 'True', 'related_name': "'submited_marker'", 'null': 'True', 'to': "orm['chimere.Marker']"}),
+ 'route': ('django.db.models.fields.related.ForeignKey', [], {'blank': 'True', 'related_name': "'associated_marker'", 'null': 'True', 'to': "orm['chimere.Route']"}),
+ 'start_date': ('django.db.models.fields.DateField', [], {'null': 'True', 'blank': 'True'}),
+ 'status': ('django.db.models.fields.CharField', [], {'max_length': '1'}),
+ 'submiter_comment': ('django.db.models.fields.TextField', [], {'max_length': '200', 'null': 'True', 'blank': 'True'}),
+ 'submiter_email': ('django.db.models.fields.EmailField', [], {'max_length': '75', 'null': 'True', 'blank': 'True'}),
+ 'submiter_name': ('django.db.models.fields.CharField', [], {'max_length': '40', 'null': 'True', 'blank': 'True'}),
+ 'submiter_session_key': ('django.db.models.fields.CharField', [], {'max_length': '40', 'null': 'True', 'blank': 'True'})
+ },
+ 'chimere.multimediaextension': {
+ 'Meta': {'object_name': 'MultimediaExtension'},
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'multimedia_type': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'extensions'", 'to': "orm['chimere.MultimediaType']"}),
+ 'name': ('django.db.models.fields.CharField', [], {'max_length': '6'})
+ },
+ 'chimere.multimediafile': {
+ 'Meta': {'object_name': 'MultimediaFile'},
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'marker': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'multimedia_files'", 'to': "orm['chimere.Marker']"}),
+ 'miniature': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
+ 'multimedia_type': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['chimere.MultimediaType']", 'null': 'True', 'blank': 'True'}),
+ 'name': ('django.db.models.fields.CharField', [], {'max_length': '150'}),
+ 'order': ('django.db.models.fields.IntegerField', [], {'default': '1'}),
+ 'url': ('django.db.models.fields.URLField', [], {'max_length': '200'})
+ },
+ 'chimere.multimediatype': {
+ 'Meta': {'object_name': 'MultimediaType'},
+ 'available': ('django.db.models.fields.BooleanField', [], {'default': 'True'}),
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'iframe': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
+ 'media_type': ('django.db.models.fields.CharField', [], {'max_length': '1'}),
+ 'mime_type': ('django.db.models.fields.CharField', [], {'max_length': '50', 'null': 'True', 'blank': 'True'}),
+ 'name': ('django.db.models.fields.CharField', [], {'max_length': '150'})
+ },
+ 'chimere.news': {
+ 'Meta': {'object_name': 'News'},
+ 'areas': ('chimere.widgets.SelectMultipleField', [], {'symmetrical': 'False', 'to': "orm['chimere.Area']", 'null': 'True', 'blank': 'True'}),
+ 'available': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
+ 'content': ('django.db.models.fields.TextField', [], {}),
+ 'date': ('django.db.models.fields.DateField', [], {}),
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'is_front_page': ('django.db.models.fields.NullBooleanField', [], {'null': 'True', 'blank': 'True'}),
+ 'title': ('django.db.models.fields.CharField', [], {'max_length': '150'}),
+ 'url': ('django.db.models.fields.URLField', [], {'max_length': '200', 'null': 'True', 'blank': 'True'})
+ },
+ 'chimere.page': {
+ 'Meta': {'object_name': 'Page'},
+ 'available': ('django.db.models.fields.BooleanField', [], {'default': 'True'}),
+ 'content': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}),
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'mnemonic': ('django.db.models.fields.CharField', [], {'max_length': '10', 'null': 'True', 'blank': 'True'}),
+ 'order': ('django.db.models.fields.IntegerField', [], {'default': '10', 'null': 'True', 'blank': 'True'}),
+ 'template_path': ('django.db.models.fields.CharField', [], {'max_length': '150', 'null': 'True', 'blank': 'True'}),
+ 'title': ('django.db.models.fields.CharField', [], {'max_length': '150'})
+ },
+ 'chimere.picturefile': {
+ 'Meta': {'object_name': 'PictureFile'},
+ 'height': ('django.db.models.fields.IntegerField', [], {'null': 'True', 'blank': 'True'}),
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'marker': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'pictures'", 'to': "orm['chimere.Marker']"}),
+ 'miniature': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
+ 'name': ('django.db.models.fields.CharField', [], {'max_length': '150'}),
+ 'order': ('django.db.models.fields.IntegerField', [], {'default': '1'}),
+ 'picture': ('django.db.models.fields.files.ImageField', [], {'max_length': '100'}),
+ 'thumbnailfile': ('django.db.models.fields.files.ImageField', [], {'max_length': '100', 'null': 'True', 'blank': 'True'}),
+ 'thumbnailfile_height': ('django.db.models.fields.IntegerField', [], {'null': 'True', 'blank': 'True'}),
+ 'thumbnailfile_width': ('django.db.models.fields.IntegerField', [], {'null': 'True', 'blank': 'True'}),
+ 'width': ('django.db.models.fields.IntegerField', [], {'null': 'True', 'blank': 'True'})
+ },
+ 'chimere.property': {
+ 'Meta': {'object_name': 'Property'},
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'marker': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['chimere.Marker']"}),
+ 'propertymodel': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['chimere.PropertyModel']"}),
+ 'value': ('django.db.models.fields.TextField', [], {})
+ },
+ 'chimere.propertymodel': {
+ 'Meta': {'ordering': "('order',)", 'object_name': 'PropertyModel'},
+ 'available': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'mandatory': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
+ 'name': ('django.db.models.fields.CharField', [], {'max_length': '150'}),
+ 'order': ('django.db.models.fields.IntegerField', [], {}),
+ 'subcategories': ('chimere.widgets.SelectMultipleField', [], {'symmetrical': 'False', 'related_name': "'properties'", 'blank': 'True', 'to': "orm['chimere.SubCategory']"}),
+ 'type': ('django.db.models.fields.CharField', [], {'max_length': '1'})
+ },
+ 'chimere.propertymodelchoice': {
+ 'Meta': {'object_name': 'PropertyModelChoice'},
+ 'available': ('django.db.models.fields.BooleanField', [], {'default': 'True'}),
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'propertymodel': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'choices'", 'to': "orm['chimere.PropertyModel']"}),
+ 'value': ('django.db.models.fields.CharField', [], {'max_length': '150'})
+ },
+ 'chimere.route': {
+ 'Meta': {'ordering': "('status', 'name')", 'object_name': 'Route'},
+ 'associated_file': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['chimere.RouteFile']", 'null': 'True', 'blank': 'True'}),
+ 'categories': ('chimere.widgets.SelectMultipleField', [], {'to': "orm['chimere.SubCategory']", 'symmetrical': 'False'}),
+ 'end_date': ('django.db.models.fields.DateField', [], {'null': 'True', 'blank': 'True'}),
+ 'has_associated_marker': ('django.db.models.fields.BooleanField', [], {'default': 'True'}),
+ 'height': ('django.db.models.fields.IntegerField', [], {'null': 'True', 'blank': 'True'}),
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'import_key': ('django.db.models.fields.CharField', [], {'max_length': '200', 'null': 'True', 'blank': 'True'}),
+ 'import_source': ('django.db.models.fields.CharField', [], {'max_length': '200', 'null': 'True', 'blank': 'True'}),
+ 'import_version': ('django.db.models.fields.IntegerField', [], {'null': 'True', 'blank': 'True'}),
+ 'license': ('django.db.models.fields.CharField', [], {'max_length': '100', 'null': 'True', 'blank': 'True'}),
+ 'modified_since_import': ('django.db.models.fields.BooleanField', [], {'default': 'True'}),
+ 'name': ('django.db.models.fields.CharField', [], {'max_length': '150'}),
+ 'not_for_osm': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
+ 'origin': ('django.db.models.fields.CharField', [], {'max_length': '100', 'null': 'True', 'blank': 'True'}),
+ 'picture': ('django.db.models.fields.files.ImageField', [], {'max_length': '100', 'null': 'True', 'blank': 'True'}),
+ 'ref_item': ('django.db.models.fields.related.ForeignKey', [], {'blank': 'True', 'related_name': "'submited_route'", 'null': 'True', 'to': "orm['chimere.Route']"}),
+ 'route': ('chimere.widgets.RouteField', [], {}),
+ 'start_date': ('django.db.models.fields.DateField', [], {'null': 'True', 'blank': 'True'}),
+ 'status': ('django.db.models.fields.CharField', [], {'max_length': '1'}),
+ 'submiter_comment': ('django.db.models.fields.TextField', [], {'max_length': '200', 'null': 'True', 'blank': 'True'}),
+ 'submiter_email': ('django.db.models.fields.EmailField', [], {'max_length': '75', 'null': 'True', 'blank': 'True'}),
+ 'submiter_name': ('django.db.models.fields.CharField', [], {'max_length': '40', 'null': 'True', 'blank': 'True'}),
+ 'submiter_session_key': ('django.db.models.fields.CharField', [], {'max_length': '40', 'null': 'True', 'blank': 'True'}),
+ 'width': ('django.db.models.fields.IntegerField', [], {'null': 'True', 'blank': 'True'})
+ },
+ 'chimere.routefile': {
+ 'Meta': {'ordering': "('name',)", 'object_name': 'RouteFile'},
+ 'file_type': ('django.db.models.fields.CharField', [], {'max_length': '1'}),
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'name': ('django.db.models.fields.CharField', [], {'max_length': '150'}),
+ 'raw_file': ('django.db.models.fields.files.FileField', [], {'max_length': '100'}),
+ 'simplified_file': ('django.db.models.fields.files.FileField', [], {'max_length': '100', 'null': 'True', 'blank': 'True'})
+ },
+ 'chimere.subcategory': {
+ 'Meta': {'ordering': "['category', 'order']", 'object_name': 'SubCategory'},
+ 'as_layer': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
+ 'available': ('django.db.models.fields.BooleanField', [], {'default': 'True'}),
+ 'category': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'subcategories'", 'to': "orm['chimere.Category']"}),
+ 'color_theme': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['chimere.ColorTheme']", 'null': 'True', 'blank': 'True'}),
+ 'dated': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
+ 'description': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}),
+ 'hover_icon': ('django.db.models.fields.related.ForeignKey', [], {'blank': 'True', 'related_name': "'subcat_hovered'", 'null': 'True', 'to': "orm['chimere.Icon']"}),
+ 'icon': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['chimere.Icon']"}),
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'item_type': ('django.db.models.fields.CharField', [], {'max_length': '1'}),
+ 'name': ('django.db.models.fields.CharField', [], {'max_length': '150'}),
+ 'order': ('django.db.models.fields.IntegerField', [], {'default': '1000'}),
+ 'routing_warn': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
+ 'submission': ('django.db.models.fields.BooleanField', [], {'default': 'True'})
+ },
+ 'chimere.tinyurl': {
+ 'Meta': {'object_name': 'TinyUrl'},
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'parameters': ('django.db.models.fields.CharField', [], {'max_length': '500'})
+ }
+ }
+
+ complete_apps = ['chimere'] \ No newline at end of file
diff --git a/chimere/models.py b/chimere/models.py
index fdd1e4b..be84036 100644
--- a/chimere/models.py
+++ b/chimere/models.py
@@ -309,6 +309,13 @@ class SubCategory(models.Model):
def item_nb(self):
return Marker.objects.filter(categories=self).count()
+STATUS = (('S', _(u'Submited')),
+ ('A', _(u'Available')),
+ ('M', _(u'Modified')),
+ ('D', _(u'Disabled')),
+ ('I', _(u'Imported')))
+STATUS_DCT = dict(STATUS)
+
IMPORTERS = {'KML':KMLManager,
'OSM':OSMManager,
'SHP':ShapefileManager,
@@ -365,6 +372,8 @@ class Importer(models.Model):
u"a marker to a way"), default=False)
automatic_update = models.BooleanField(_(u"Automatically updated"),
default=False)
+ default_status = models.CharField(_(u"Default status"), max_length=1,
+ choices=STATUS, default='I')
default_localisation = PointField(_(u"Default localisation"),
srid=settings.CHIMERE_EPSG_DISPLAY_PROJECTION,
blank=True, null=True,
@@ -413,13 +422,6 @@ class ImporterKeyCategories(models.Model):
class Meta:
verbose_name = _(u"Importer - Key categories")
-STATUS = (('S', _(u'Submited')),
- ('A', _(u'Available')),
- ('M', _(u'Modified')),
- ('D', _(u'Disabled')),
- ('I', _(u'Imported')))
-STATUS_DCT = dict(STATUS)
-
class GeographicItem(models.Model):
name = models.CharField(_(u"Name"), max_length=150)
categories = SelectMultipleField(SubCategory)
@@ -478,7 +480,12 @@ class GeographicItem(models.Model):
if not _set:
new_keys += '%s:%s;' % (key, value)
self.import_key = new_keys
+ modified_since_import = self.modified_since_import
self.save()
+ # preserve modified_since_import
+ if modified_since_import != self.modified_since_import:
+ self.modified_since_import = modified_since_import
+ self.save()
def has_modified(self):
if (self.ref_item and self.ref_item != self) \
@@ -711,7 +718,8 @@ class Marker(GeographicItem):
return url
PRE_ATTRS = {
- 'Marker':('name', 'geometry', 'import_version', 'modified_since_import'),
+ 'Marker':('name', 'description', 'start_date', 'geometry', 'import_version',
+ 'modified_since_import'),
'Route':('name', 'geometry', 'import_version', 'modified_since_import'),
'Area':('urn', 'name'),
}
@@ -722,8 +730,9 @@ def geometry_pre_save(cls, pre_save_geom_values):
instance = kwargs['instance']
try:
instance = cls.objects.get(pk=instance.pk)
- pre_save_geom_values[instance.pk] = [getattr(instance, attr)
- for attr in PRE_ATTRS[cls.__name__]]
+ pre_save_geom_values[instance.pk] = dict(
+ [(attr, getattr(instance, attr))
+ for attr in PRE_ATTRS[cls.__name__]])
except ObjectDoesNotExist:
pass
return geom_pre_save
@@ -741,24 +750,25 @@ def geometry_post_save(pre_save_geom_values):
or kwargs['instance'].pk not in pre_save_geom_values:
return
instance = kwargs['instance']
- name, geometry, import_version, modified_since_import = \
- pre_save_geom_values[instance.pk]
+ pre = pre_save_geom_values[instance.pk]
# force the reinit of modified_since_import
- if modified_since_import != instance.modified_since_import:
+ if pre['modified_since_import'] != instance.modified_since_import:
return
- if (instance.import_version != import_version
+ if (instance.import_version != pre['import_version']
and instance.modified_since_import):
instance.modified_since_import = False
instance.save()
return
if instance.modified_since_import:
return
- if instance.name != name or instance.geometry != geometry:
+ if [key for key in pre if pre not in ('import_version',
+ 'modified_since_import') and
+ getattr(instance, key) != pre[key]]:
instance.modified_since_import = True
instance.save()
return geom_post_save
def marker_post_save(sender, **kwargs):
- if not kwargs['instance']:
+ if not kwargs['instance'] or kwargs['created']:
return
geometry_post_save(pre_save_marker_values)(sender, **kwargs)
post_save.connect(marker_post_save, sender=Marker)
@@ -1600,6 +1610,8 @@ class Property(models.Model):
value = models.TextField(_(u"Value"))
def __unicode__(self):
if self.propertymodel.type == 'C':
+ if not self.value:
+ return ''
try:
return unicode(PropertyModelChoice.objects.get(
pk=self.value).value)
diff --git a/chimere/static/chimere/js/importer_interface.js b/chimere/static/chimere/js/importer_interface.js
index 65bcf8c..5c77a8d 100644
--- a/chimere/static/chimere/js/importer_interface.js
+++ b/chimere/static/chimere/js/importer_interface.js
@@ -2,35 +2,37 @@ django.jQuery(function($) {
var importer_form_filter = {
OSM:new Array('field-filtr', 'field-default_name', 'field-categories',
'field-source', 'field-overwrite',
- 'field-automatic_update'),
+ 'field-automatic_update', 'field-default_status'),
KML:new Array('field-source', 'field-source_file', 'field-default_name',
'field-filtr', 'field-zipped', 'field-origin',
'field-license', 'field-categories', 'field-overwrite',
- 'field-get_description', 'field-automatic_update'),
+ 'field-get_description', 'field-automatic_update',
+ 'field-default_status'),
SHP:new Array('field-source', 'field-source_file', 'field-default_name',
'field-zipped', 'field-origin', 'field-srid',
'field-license', 'field-categories', 'field-overwrite',
- 'field-automatic_update'),
+ 'field-automatic_update', 'field-default_status'),
RSS:new Array('field-source', 'field-default_name', 'field-origin',
'field-srid', 'field-license', 'field-categories',
'field-overwrite', 'field-get_description',
- 'field-automatic_update'),
+ 'field-automatic_update', 'field-default_status'),
CSV:new Array('field-source', 'field-source_file', 'field-default_name',
'field-origin', 'field-srid', 'field-license',
'field-categories', 'field-overwrite',
- 'field-get_description', 'field-automatic_update'),
+ 'field-get_description', 'field-automatic_update',
+ 'field-default_status'),
XSLT:new Array('field-source', 'field-source_file',
'field-source_file_alt', 'field-default_name',
'field-origin', 'field-srid', 'field-license',
'field-categories', 'field-overwrite',
'field-get_description', 'field-default_localisation',
- 'field-automatic_update'),
+ 'field-automatic_update', 'field-default_status'),
XXLT:new Array('field-source', 'field-source_file',
'field-source_file_alt', 'field-default_name',
'field-origin', 'field-srid', 'field-license',
'field-categories', 'field-overwrite',
'field-get_description', 'field-default_localisation',
- 'field-automatic_update')
+ 'field-automatic_update', 'field-default_status')
}
var osm_map_initialized;
var edit_map_initialized;
@@ -118,10 +120,10 @@ django.jQuery(function($) {
value = $('input[name=id_filtr_type]:checked').val();
value += '[' + $("#id_filtr_tag").val() + ']';
value += '[bbox=';
- value += $('#upper_left_lon').val() + ',';
- value += $('#lower_right_lat').val() + ',';
- value += $('#lower_right_lon').val() + ',';
- value += $('#upper_left_lat').val();
+ value += Number($('#upper_left_lon').val()).toFixed(6) + ',';
+ value += Number($('#lower_right_lat').val()).toFixed(6) + ',';
+ value += Number($('#lower_right_lon').val()).toFixed(6) + ',';
+ value += Number($('#upper_left_lat').val()).toFixed(6);
value += ']';
$('#id_filtr').val(value);
return false;
diff --git a/chimere/static/chimere/js/jquery.chimere.js b/chimere/static/chimere/js/jquery.chimere.js
index 78cb3dc..f7e0785 100644
--- a/chimere/static/chimere/js/jquery.chimere.js
+++ b/chimere/static/chimere/js/jquery.chimere.js
@@ -43,7 +43,6 @@ OpenLayers.Layer.MapQuestOSM = OpenLayers.Class(OpenLayers.Layer.XYZ, {
else
return v; };
})( jQuery );
-
(function ($) {
/*
* Chimere jQuery plugin
@@ -756,7 +755,6 @@ OpenLayers.Layer.MapQuestOSM = OpenLayers.Class(OpenLayers.Layer.XYZ, {
} else {
par.removeClass('selected');
}
- methods.hidePopup(e);
methods.loadGeoObjects();
_toggle_categories($(this));
settings.permalink.updateLink();
@@ -764,6 +762,7 @@ OpenLayers.Layer.MapQuestOSM = OpenLayers.Class(OpenLayers.Layer.XYZ, {
$('#layer_cat_'+c_name).prop("checked",
this.checked);
}
+ methods.hidePopup(e);
});
$('#display_submited_check').bind("click", function () {
methods.loadGeoObjects();
@@ -1028,6 +1027,28 @@ OpenLayers.Layer.MapQuestOSM = OpenLayers.Class(OpenLayers.Layer.XYZ, {
cleanRoute: function(){
settings.layerVectors.removeAllFeatures();
},
+ // add json layer
+ addJSON: function(json_url){
+ var jsonStyle = new OpenLayers.Style({
+ 'strokeWidth':1,
+ 'fillColor':'#BBBBBB',
+ 'strokeColor':'#AAAAAA'
+ });
+
+ var jsonStyleMap = new OpenLayers.StyleMap({'default': jsonStyle});
+ settings.layerJson = new OpenLayers.Layer.Vector("GeoJSON", {
+ projection: EPSG_DISPLAY_PROJECTION,
+ strategies: [new OpenLayers.Strategy.Fixed()],
+ protocol: new OpenLayers.Protocol.HTTP({
+ url: json_url,
+ format: new OpenLayers.Format.GeoJSON()
+ }),
+ styleMap: jsonStyleMap
+ });
+ settings.map.addLayer(settings.layerJson);
+ settings.map.setLayerIndex(settings.layerJson, 0);
+ settings.layerJson.setOpacity(0.4);
+ },
// Put a route on the map
addRoute: function(route) {
var polyline = route.geometry;
diff --git a/chimere/templates/chimere/blocks/map_menu.html b/chimere/templates/chimere/blocks/map_menu.html
index 38fb4a8..02f415a 100644
--- a/chimere/templates/chimere/blocks/map_menu.html
+++ b/chimere/templates/chimere/blocks/map_menu.html
@@ -1,7 +1,7 @@
{% load i18n %}
<div id='chimere_map_menu'>
<ul>
- {% if routing %}
+ {% if routing and not simple %}
<li id='map_menu_from' class='routing_item'>{% trans "From" context "routing" %}</li>
<li id='map_menu_step' class='routing_item'>{% trans "Add a step" context "routing" %}</li>
<li id='map_menu_to' class='routing_item'>{% trans "To" context "routing" %}</li>
diff --git a/chimere/templatetags/chimere_tags.py b/chimere/templatetags/chimere_tags.py
index 344febb..a89b721 100644
--- a/chimere/templatetags/chimere_tags.py
+++ b/chimere/templatetags/chimere_tags.py
@@ -178,7 +178,8 @@ def head_form():
@register.inclusion_tag('chimere/blocks/map_menu.html', takes_context=True)
def map_menu(context):
context_data = {'routing': settings.CHIMERE_ENABLE_ROUTING \
- if hasattr(settings, 'CHIMERE_ENABLE_ROUTING') else False}
+ if hasattr(settings, 'CHIMERE_ENABLE_ROUTING') else False,
+ 'simple':context.get('simple')}
return context_data
@register.inclusion_tag('chimere/blocks/routing.html', takes_context=True)
diff --git a/chimere/utils.py b/chimere/utils.py
index 55fc45c..c5c59e9 100644
--- a/chimere/utils.py
+++ b/chimere/utils.py
@@ -100,7 +100,7 @@ class ImportManager(object):
return ref_item, None, None
if not self.importer_instance.overwrite \
and ref_item.modified_since_import:
- dct_import['ref_item'] = ref_item
+ return ref_item, None, None
else:
item = ref_item
for k in values:
@@ -124,13 +124,14 @@ class ImportManager(object):
self.importer_instance.default_description
values.update({
'import_source':self.importer_instance.source})
- values['status'] = 'I' \
- if not self.importer_instance.automatic_update else 'A'
+ values['status'] = self.importer_instance.default_status
if not self.importer_instance.associate_marker_to_way\
and cls.__name__ == 'Route':
values['has_associated_marker'] = False
try:
item = cls.objects.create(**values)
+ item.modified_since_import = False
+ item.save()
except TypeError:
# error on data source
return None, False, False
@@ -1063,7 +1064,8 @@ class HtmlXsltManager(ImportManager):
not "point" in item and not ("lat" in item and item['lat']):
return
cls = None
- dct = {'origin':"<a href='%s'>%s</a>" % (item['link'],
+ dct = {'origin':"<a href='%s' target='_blank'>%s</a>" % (
+ item.get('link') or '#',
self.importer_instance.origin),
'license':self.importer_instance.license,
'name':item['name']}