summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorÉtienne Loks <etienne.loks@peacefrogs.net>2012-09-04 00:13:01 +0200
committerÉtienne Loks <etienne.loks@peacefrogs.net>2012-09-04 00:13:01 +0200
commite0f0fa81482618d160b665431ce7273ceb2165b0 (patch)
treeb20af9a28abf1054fc4d2704efe0b72eaffefb35
parentc89ba34380c86f8853a5e6af6cee345002ca381b (diff)
downloadChimère-e0f0fa81482618d160b665431ce7273ceb2165b0.tar.bz2
Chimère-e0f0fa81482618d160b665431ce7273ceb2165b0.zip
Add a new Page model to add simple pages as "actions"- Improve actions management
-rw-r--r--chimere/actions.py39
-rw-r--r--chimere/admin.py11
-rw-r--r--chimere/forms.py11
-rw-r--r--chimere/migrations/0032_auto__add_page.py252
-rw-r--r--chimere/models.py27
-rw-r--r--chimere/templates/chimere/blocks/actions.html4
-rw-r--r--chimere/templates/chimere/default_extra_page.html14
-rw-r--r--chimere/urls.py5
-rw-r--r--chimere/views.py40
9 files changed, 380 insertions, 23 deletions
diff --git a/chimere/actions.py b/chimere/actions.py
index 0363d54..a434279 100644
--- a/chimere/actions.py
+++ b/chimere/actions.py
@@ -22,21 +22,44 @@ Actions available in the main interface
"""
from django.conf import settings
from django.contrib.auth import models
+from django.core.urlresolvers import reverse
from django.utils.translation import ugettext_lazy as _
+from models import Page
+
class Action:
- def __init__(self, id, path, label):
+ def __init__(self, id, path, label, extra_url_args=[]):
self.id, self.path, self.label = id, path, label
+ self.extra_url_args, self.url = extra_url_args, None
+
+ def update_url(self, area_name):
+ self.url = reverse(self.path,
+ args=[area_name+'/'] + self.extra_url_args)
-actions = [(Action('view', '', _('View')), []),
- (Action('contribute', 'edit/', _('Contribute')),
- (Action('edit', 'edit/', _('Add a new point of interest')),
- Action('edit-route', 'edit-route/', _('Add a new route'))),
- ),]
+default_actions = [(Action('view', 'chimere:index', _('View')), []),
+ (Action('contribute', 'chimere:edit', _('Contribute')),
+ (Action('edit', 'chimere:edit', _('Add a new point of interest')),
+ Action('edit-route', 'chimere:editroute', _('Add a new route'))),
+ ),]
if settings.CHIMERE_FEEDS:
- actions.append((Action('rss', 'feeds', _('RSS feeds')), []))
+ default_actions.append((Action('rss', 'chimere:feeds-form',
+ _('RSS feeds')), []))
if settings.EMAIL_HOST:
- actions.append((Action('contact', 'contact', _('Contact us')), []),)
+ default_actions.append((Action('contact', 'chimere:contact',
+ _('Contact us')), []),)
+
+def actions(area_name=''):
+ acts = default_actions[:]
+ for act, childs in default_actions:
+ act.update_url(area_name)
+ for child_act in childs:
+ child_act.update_url(area_name)
+ for page in Page.objects.filter(available=True).order_by('order'):
+ act = Action(page.mnemonic, 'chimere:extra_page', page.title,
+ [page.mnemonic])
+ act.update_url(area_name)
+ acts.append((act, []))
+ return acts
diff --git a/chimere/admin.py b/chimere/admin.py
index 92e971d..2125bef 100644
--- a/chimere/admin.py
+++ b/chimere/admin.py
@@ -35,13 +35,12 @@ except ImportError:
pass
from chimere.forms import MarkerAdminForm, RouteAdminForm, AreaAdminForm,\
- NewsAdminForm, CategoryAdminForm, ImporterAdminForm
+ NewsAdminForm, CategoryAdminForm, ImporterAdminForm, PageAdminForm
from chimere.models import Category, Icon, SubCategory, Marker, \
PropertyModel, News, Route, Area, ColorTheme, Color, RouteFile,\
MultimediaType, MultimediaFile, PictureFile, Importer, Layer, AreaLayers,\
- PropertyModelChoice, MultimediaExtension
+ PropertyModelChoice, MultimediaExtension, Page
from chimere.utils import unicode_normalize, ShapefileManager, KMLManager
-from chimere.widgets import TextareaWidget
def get_areas_for_user(user):
"""
@@ -201,6 +200,11 @@ class ImporterAdmin(admin.ModelAdmin):
actions = [importing, cancel_import, cancel_export]
admin.site.register(Importer, ImporterAdmin)
+class PageAdmin(admin.ModelAdmin):
+ """
+ Use the TinyMCE widget for the page content
+ """
+ form = PageAdminForm
class NewsAdmin(admin.ModelAdmin):
"""
@@ -252,6 +256,7 @@ class PropertyModelAdmin(admin.ModelAdmin):
inlines = [PropertyModelChoiceInline]
# register of differents database fields
+admin.site.register(Page, PageAdmin)
admin.site.register(News, NewsAdmin)
admin.site.register(Category, CategoryAdmin)
admin.site.register(Icon, IconAdmin)
diff --git a/chimere/forms.py b/chimere/forms.py
index 32f6d30..b8bd7b1 100644
--- a/chimere/forms.py
+++ b/chimere/forms.py
@@ -33,7 +33,8 @@ from django.core.mail import EmailMessage, BadHeaderError
from chimere.models import Marker, Route, PropertyModel, Property, Area,\
News, Category, SubCategory, RouteFile, MultimediaFile, MultimediaType, \
- PictureFile, Importer, PropertyModelChoice, IFRAME_LINKS, MultimediaExtension
+ PictureFile, Importer, PropertyModelChoice, IFRAME_LINKS, \
+ MultimediaExtension, Page
from chimere.widgets import AreaField, PointField, TextareaWidget, \
DatePickerWidget, ButtonSelectWidget, NominatimWidget
@@ -94,6 +95,14 @@ class ContactForm(forms.Form):
email = forms.EmailField(label=_("Email (optional)"), required=False)
content = forms.CharField(label=_("Object"), widget=forms.Textarea)
+class PageAdminForm(forms.ModelForm):
+ """
+ Main form for extra pages
+ """
+ content = forms.CharField(widget=TextareaWidget)
+ class Meta:
+ model = Page
+
class NewsAdminForm(forms.ModelForm):
"""
Main form for news
diff --git a/chimere/migrations/0032_auto__add_page.py b/chimere/migrations/0032_auto__add_page.py
new file mode 100644
index 0000000..e39c4a8
--- /dev/null
+++ b/chimere/migrations/0032_auto__add_page.py
@@ -0,0 +1,252 @@
+# -*- 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 model 'Page'
+ db.create_table('chimere_page', (
+ ('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)),
+ ('title', self.gf('django.db.models.fields.CharField')(max_length=150)),
+ ('mnemonic', self.gf('django.db.models.fields.CharField')(max_length=10, null=True, blank=True)),
+ ('available', self.gf('django.db.models.fields.BooleanField')(default=True)),
+ ('order', self.gf('django.db.models.fields.IntegerField')(default=10, null=True, blank=True)),
+ ('template_path', self.gf('django.db.models.fields.CharField')(max_length=150, null=True, blank=True)),
+ ('content', self.gf('django.db.models.fields.TextField')(null=True, blank=True)),
+ ))
+ db.send_create_signal('chimere', ['Page'])
+
+
+ def backwards(self, orm):
+ # Deleting model 'Page'
+ db.delete_table('chimere_page')
+
+
+ models = {
+ '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', [], {}),
+ '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'},
+ 'categories': ('chimere.widgets.SelectMultipleField', [], {'to': "orm['chimere.SubCategory']", 'symmetrical': 'False'}),
+ 'filtr': ('django.db.models.fields.CharField', [], {'max_length': '200', 'null': 'True', 'blank': 'True'}),
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'importer_type': ('django.db.models.fields.CharField', [], {'max_length': '4'}),
+ 'source': ('django.db.models.fields.CharField', [], {'max_length': '200', 'null': 'True', 'blank': 'True'}),
+ 'srid': ('django.db.models.fields.IntegerField', [], {'null': 'True', 'blank': 'True'}),
+ 'state': ('django.db.models.fields.CharField', [], {'max_length': '200', 'null': 'True', 'blank': 'True'}),
+ 'zipped': ('django.db.models.fields.BooleanField', [], {'default': 'False'})
+ },
+ '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'}),
+ 'name': ('django.db.models.fields.CharField', [], {'max_length': '150'}),
+ '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']"}),
+ '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'},
+ 'available': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
+ 'content': ('django.db.models.fields.TextField', [], {}),
+ 'date': ('django.db.models.fields.DateField', [], {'auto_now_add': 'True', 'blank': 'True'}),
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'title': ('django.db.models.fields.CharField', [], {'max_length': '150'})
+ },
+ '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', [], {}),
+ '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', [], {})
+ },
+ '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'}),
+ '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'}),
+ 'name': ('django.db.models.fields.CharField', [], {'max_length': '150'}),
+ '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'},
+ 'available': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
+ 'category': ('django.db.models.fields.related.ForeignKey', [], {'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'}),
+ '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', [], {})
+ },
+ '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 5c98de7..9ff442b 100644
--- a/chimere/models.py
+++ b/chimere/models.py
@@ -44,6 +44,33 @@ from chimere.widgets import PointField, RouteField, SelectMultipleField, \
from chimere.managers import BaseGeoManager
from chimere.utils import KMLManager, OSMManager, ShapefileManager
+class Page(models.Model):
+ """Simple extra pages
+ """
+ title = models.CharField(_(u"Name"), max_length=150)
+ mnemonic = models.CharField(_(u"Mnemonic"), max_length=10, blank=True,
+ null=True)
+ available = models.BooleanField(_(u"Available"), default=True)
+ order = models.IntegerField(_(u"Order"), default=10, blank=True, null=True)
+ template_path = models.CharField(_(u"Template path"), max_length=150,
+ blank=True, null=True)
+ content = models.TextField(blank=True, null=True)
+ def __unicode__(self):
+ ordering = ["order"]
+ return self.title
+ class Meta:
+ verbose_name = _(u"Page")
+ verbose_name_plural = _(u"Page")
+
+def page_post_save(sender, **kwargs):
+ if not kwargs['instance']:
+ return
+ page = kwargs['instance']
+ if not page.mnemonic:
+ page.mnemonic = defaultfilters.slugify(page.title)
+ page.save()
+post_save.connect(page_post_save, sender=Page)
+
class News(models.Model):
"""News of the site
"""
diff --git a/chimere/templates/chimere/blocks/actions.html b/chimere/templates/chimere/blocks/actions.html
index 2806321..93debb0 100644
--- a/chimere/templates/chimere/blocks/actions.html
+++ b/chimere/templates/chimere/blocks/actions.html
@@ -2,7 +2,7 @@
<ul id='action' class='action'>
{% for action, subactions in actions %}
<li class='ui-widget ui-button ui-state-default ui-corner-all {% ifequal action.id action_selected.0 %} ui-state-active{% endifequal %}'>
- <a href='{{extra_url}}{{ action.path }}' onclick='jQuery("#map").chimere("saveExtent");'>{{ action.label }}</a>
+ <a href='{{ action.url }}' onclick='jQuery("#map").chimere("saveExtent");'>{{ action.label }}</a>
</li>
{% endfor %}
</ul>
@@ -11,7 +11,7 @@
{% ifequal action.id action_selected.0 %}{% if subactions %}
{% for subaction in subactions %}
<li class='ui-widget ui-button ui-state-default ui-corner-all{% ifequal subaction.id action_selected.1 %} ui-state-active{% endifequal %}'>
- <a href='{{extra_url}}{{ subaction.path }}' onclick='saveExtent();'>{{ subaction.label }}</a>
+ <a href='{{ subaction.url }}' onclick='saveExtent();'>{{ subaction.label }}</a>
</li>
{% endfor %}
{% endif %}{% endifequal %}
diff --git a/chimere/templates/chimere/default_extra_page.html b/chimere/templates/chimere/default_extra_page.html
new file mode 100644
index 0000000..337a991
--- /dev/null
+++ b/chimere/templates/chimere/default_extra_page.html
@@ -0,0 +1,14 @@
+{% extends "chimere/base.html" %}
+{% load i18n chimere_tags %}
+{% block extra_head %}
+ {{ block.super }}
+ {{ form.media }}
+ {% head_jquery %}
+{% endblock %}
+{% block message_map %}{% endblock %}
+{% block message_edit%}{% endblock %}
+{% block content %}
+ {{ block.super }}
+ {{content|safe}}
+{% endblock %}
+
diff --git a/chimere/urls.py b/chimere/urls.py
index a23af1b..086be3f 100644
--- a/chimere/urls.py
+++ b/chimere/urls.py
@@ -64,7 +64,8 @@ if settings.CHIMERE_ENABLE_ROUTING:
urlpatterns += patterns('chimere.views',
url(r'^charte/?$', 'charte', name="charte"),
- url(r'^(?P<area_name>[a-zA-Z0-9_-]+/)?contact/?$', 'contactus', name="contact"),
+ url(r'^(?P<area_name>[a-zA-Z0-9_-]+/)?contact/?$', 'contactus',
+ name="contact"),
url(r'^(?P<area_name>[a-zA-Z0-9_-]+/)?edit/$', 'edit',
name="edit"),
url(r'^(?P<area_name>[a-zA-Z0-9_-]+/)?edit/(?P<item_id>\w+)/(?P<submited>\w+)?$',
@@ -88,6 +89,8 @@ urlpatterns += patterns('chimere.views',
'uploadFile', name='upload_file'),
url(r'^(?P<area_name>[a-zA-Z0-9_-]+/)?process_route_file/(?P<file_id>\d+)/$',
'processRouteFile', name='process_route_file'),
+ url(r'^(?P<area_name>[a-zA-Z0-9_-]+/)?dyn/(?P<page_id>\w+)/$',
+ 'extraPage', name='extra_page'),
# At the end, because it catches large
url(r'^(?P<area_name>[a-zA-Z0-9_-]+)?', 'index', name="index"),
)
diff --git a/chimere/views.py b/chimere/views.py
index 4a97a62..366ac1a 100644
--- a/chimere/views.py
+++ b/chimere/views.py
@@ -41,7 +41,7 @@ from django.utils.http import urlquote
from django.utils.translation import ugettext as _
from chimere.actions import actions
-from chimere.models import Category, SubCategory, PropertyModel, \
+from chimere.models import Category, SubCategory, PropertyModel, Page,\
Marker, Route, News, SimpleArea, Area, Color, TinyUrl, RouteFile
from chimere.widgets import getMapJS, PointChooserWidget, \
@@ -127,7 +127,8 @@ def index(request, area_name=None, default_area=None, simple=False):
if settings.CHIMERE_ENABLE_ROUTING:
response_dct['itinerary_form'] = RoutingForm()
response_dct.update({
- 'actions':actions, 'action_selected':('view',),
+ 'actions':actions(response_dct['area_name']),
+ 'action_selected':('view',),
'error_message':'',
'news_visible': news_visible,
'areas_visible': settings.CHIMERE_DISPLAY_AREAS,
@@ -265,7 +266,7 @@ def edit(request, area_name="", item_id=None, submited=False):
filtered_properties = PropertyModel.objects.filter(available=True,
subcategories__id__isnull=False).all()
response_dct.update({
- 'actions':actions,
+ 'actions':actions(response_dct['area_name']),
'action_selected':('contribute', 'edit'),
'map_layer':settings.CHIMERE_DEFAULT_MAP_LAYER,
'form':form,
@@ -370,7 +371,7 @@ def editRoute(request, area_name="", item_id=None, submited=False):
if 'description' in declared_fields:
declared_fields.pop(declared_fields.index('description'))
response_dct.update({
- 'actions':actions,
+ 'actions':actions(response_dct['area_name']),
'action_selected':('contribute', 'edit-route'),
'error_message':'',
'map_layer':settings.CHIMERE_DEFAULT_MAP_LAYER,
@@ -413,7 +414,8 @@ def submited(request, area_name="", action=""):
response_dct, redir = get_base_response(area_name)
if redir:
return redir
- response_dct.update({'actions':actions, 'action_selected':action,})
+ response_dct.update({'actions':actions(response_dct['area_name']),
+ 'action_selected':action,})
return render_to_response('chimere/submited.html', response_dct,
context_instance=RequestContext(request))
@@ -424,7 +426,8 @@ def charte(request, area_name=""):
response_dct, redir = get_base_response(area_name)
if redir:
return redir
- response_dct.update({'actions':actions, 'action_selected':('charte',)})
+ response_dct.update({'actions':actions(response_dct['area_name']),
+ 'action_selected':('charte',)})
return render_to_response('chimere/charte.html', response_dct,
context_instance=RequestContext(request))
@@ -452,11 +455,31 @@ def contactus(request, area_name=""):
response_dct, redir = get_base_response(area_name)
if redir:
return redir
- response_dct.update({'actions':actions, 'action_selected':('contact',),
+ response_dct.update({'actions':actions(response_dct['area_name']),
+ 'action_selected':('contact',),
'contact_form':form, 'message':msg})
return render_to_response('chimere/contactus.html', response_dct,
context_instance=RequestContext(request))
+def extraPage(request, area_name="", page_id=""):
+ """
+ Extra dynamic pages
+ """
+ try:
+ page = Page.objects.get(available=True, mnemonic=page_id)
+ except ObjectDoesNotExist:
+ return redirect(reverse('chimere:index'))
+ response_dct, redir = get_base_response(area_name)
+ if redir:
+ return redir
+ response_dct.update({'actions':actions(response_dct['area_name']),
+ 'action_selected':(page_id,),
+ 'content':page.content})
+ tpl = page.template_path if page.template_path \
+ else 'chimere/default_extra_page.html'
+ return render_to_response(tpl, response_dct,
+ context_instance=RequestContext(request))
+
def getDetail(request, area_name, marker_id):
'''
Get the detail for a marker
@@ -679,7 +702,8 @@ def rss(request, area_name=''):
response_dct, redir = get_base_response(area_name)
if redir:
return redir
- response_dct.update({'actions':actions, 'action_selected':('rss',),
+ response_dct.update({'actions':actions(response_dct['area_name']),
+ 'action_selected':('rss',),
'category_rss_feed':'',})
# If the form has been submited
if request.method == "POST":