diff options
| -rw-r--r-- | chimere/forms.py | 2 | ||||
| -rw-r--r-- | chimere/models.py | 25 | ||||
| -rw-r--r-- | chimere/static/chimere/css/styles.css | 2 | ||||
| -rw-r--r-- | chimere/static/chimere/js/SimplePanZoom.js | 6 | ||||
| -rw-r--r-- | chimere/templates/chimere/blocks/head_chimere.html | 2 | ||||
| -rw-r--r-- | chimere/templates/chimere/blocks/map_params.html | 2 | ||||
| -rw-r--r-- | chimere/templatetags/chimere_tags.py | 22 | ||||
| -rw-r--r-- | chimere/views.py | 3 | ||||
| -rw-r--r-- | debian/control | 3 | ||||
| -rw-r--r-- | docs/install.rst | 55 |
10 files changed, 83 insertions, 39 deletions
diff --git a/chimere/forms.py b/chimere/forms.py index f49a903..20171df 100644 --- a/chimere/forms.py +++ b/chimere/forms.py @@ -163,8 +163,6 @@ class MarkerAdminFormBase(forms.ModelForm): if not pm.mandatory or self.cleaned_data[pm.getNamedId()]: continue pm_cats = pm.subcategories.all() - print self.cleaned_data['categories'] - print pm_cats if not pm_cats or \ [submited_cat for submited_cat in self.cleaned_data['categories'] if submited_cat in pm_cats]: diff --git a/chimere/models.py b/chimere/models.py index ca608e8..936353d 100644 --- a/chimere/models.py +++ b/chimere/models.py @@ -23,9 +23,8 @@ Models description import os, string, re import simplejson as json from lxml import etree -from datetime import datetime, timedelta +import datetime from subprocess import Popen, PIPE -import unidecode from django.conf import settings from django.contrib.gis.db import models @@ -36,6 +35,7 @@ from django.core.exceptions import ValidationError from django.core.urlresolvers import reverse from django.db.models.signals import post_save from django import forms +from django.template import defaultfilters from django.utils.translation import ugettext_lazy as _ from chimere.widgets import PointField, RouteField, SelectMultipleField, \ @@ -308,10 +308,10 @@ class Marker(GeographicItem): 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()) + attr_name = defaultfilters.slugify(property.propertymodel.name) + attr_name = re.sub(r'-','_', attr_name) if not hasattr(self, attr_name): - setattr(self, attr_name, property.value) + setattr(self, attr_name, property.python_value) def get_init_multi(self): multis = [forms.model_to_dict(multi) @@ -701,8 +701,9 @@ def getDateCondition(): ''' if not settings.CHIMERE_DAYS_BEFORE_EVENT: return "" - now = datetime.now().strftime('%Y-%m-%d') - after = (datetime.now() + timedelta(settings.CHIMERE_DAYS_BEFORE_EVENT) + now = datetime.datetime.now().strftime('%Y-%m-%d') + after = (datetime.datetime.now() + \ + datetime.timedelta(settings.CHIMERE_DAYS_BEFORE_EVENT) ).strftime('%Y-%m-%d') date_condition = " and %(alias)s.start_date is null or " date_condition += "(%(alias)s.start_date >= '" + now + "' and " @@ -938,3 +939,13 @@ class Property(models.Model): class Meta: verbose_name = _(u"Property") + @property + def python_value(self): + if self.propertymodel.type == 'D': + try: + return datetime.date(*[int(val) for val in self.value.split('-')]) + except: + return "" + else: + return self.value + diff --git a/chimere/static/chimere/css/styles.css b/chimere/static/chimere/css/styles.css index ceb3b60..25ee6e8 100644 --- a/chimere/static/chimere/css/styles.css +++ b/chimere/static/chimere/css/styles.css @@ -132,6 +132,8 @@ legend{ font-weight:bold; } +a img {border: none;} + h2{ font-size:16px; text-align:center; diff --git a/chimere/static/chimere/js/SimplePanZoom.js b/chimere/static/chimere/js/SimplePanZoom.js index e42dc54..45619c3 100644 --- a/chimere/static/chimere/js/SimplePanZoom.js +++ b/chimere/static/chimere/js/SimplePanZoom.js @@ -92,6 +92,11 @@ OpenLayers.Control.SimplePanZoom = OpenLayers.Class(OpenLayers.Control.PanZoom, buttons: null, /** + * Top position of the slider: change if the Y position of the slider have change + */ + startTop: 75, + + /** * APIMethod: destroy */ destroy: function() { @@ -200,7 +205,6 @@ OpenLayers.Control.SimplePanZoom = OpenLayers.Class(OpenLayers.Control.PanZoom, this.zoombarDiv = div; this.div.appendChild(div); - this.startTop = 75; this.div.appendChild(slider); this.map.events.register("zoomend", this, this.moveZoomBar); diff --git a/chimere/templates/chimere/blocks/head_chimere.html b/chimere/templates/chimere/blocks/head_chimere.html index 4ef1ae1..4031ac4 100644 --- a/chimere/templates/chimere/blocks/head_chimere.html +++ b/chimere/templates/chimere/blocks/head_chimere.html @@ -2,7 +2,7 @@ <link rel="stylesheet" href="{{ css_url }}" />{% endfor %} {% for js_url in OSM_JS_URLS %} <script src="{{ js_url }}"></script>{% endfor %} - +<script src="{{ STATIC_URL }}chimere/js/jquery.chimere.js"></script> <script type="text/javascript"> /* Global variables */ var STATIC_URL = static_url = "{{ STATIC_URL }}"; diff --git a/chimere/templates/chimere/blocks/map_params.html b/chimere/templates/chimere/blocks/map_params.html index 1afd722..27762a3 100644 --- a/chimere/templates/chimere/blocks/map_params.html +++ b/chimere/templates/chimere/blocks/map_params.html @@ -1,5 +1,7 @@ {% load i18n %} <script type="text/javascript"> + {% if single_category %} + $(function() {$('#panel').hide()});{% endif %} var chimere_init_options = {}; chimere_init_options["default_icon"] = '{{STATIC_URL}}img/marker-green.png'; chimere_init_options["map_layers"] = [{{map_layers|safe|escape}}]; diff --git a/chimere/templatetags/chimere_tags.py b/chimere/templatetags/chimere_tags.py index 946e769..132af09 100644 --- a/chimere/templatetags/chimere_tags.py +++ b/chimere/templatetags/chimere_tags.py @@ -10,7 +10,7 @@ from django.conf import settings from django.core.exceptions import ObjectDoesNotExist from django.core.urlresolvers import reverse -from chimere.models import Marker, Area, News +from chimere.models import Marker, Area, News, SubCategory from chimere.widgets import get_map_layers log = getLogger(__name__) @@ -136,7 +136,7 @@ def map_params(context): context_data['map_layers'] = ", ".join(map_layers) if default_area: context_data['selected_map_layer'] = default_area - context_data['p_checked_categories'] = "[]" + context_data['p_checked_categories'] = None area = None if area_name: try: @@ -156,7 +156,12 @@ def map_params(context): unicode(area.upper_left_corner.y), unicode(area.lower_right_corner.x), unicode(area.lower_right_corner.y))) - context_data['p_checked_categories'] = unicode([subcategory.pk + if area.subcategories.filter(available=True).count() == 1: + context_data['single_category'] = True + context_data['p_checked_categories'] = "[%d]" % \ + area.subcategories.all()[0].pk + elif area.default_subcategories.count(): + context_data['p_checked_categories'] = unicode([subcategory.pk for subcategory in area.default_subcategories.all()]) if area.restrict_to_extent: context_data['restricted_extent'] = """ @@ -165,6 +170,17 @@ bounds.extend(new OpenLayers.LonLat(%f, %f)); bounds.extend(new OpenLayers.LonLat(%f, %f)); """ % (area.upper_left_corner.x, area.upper_left_corner.y, area.lower_right_corner.x, area.lower_right_corner.y) + + if SubCategory.objects.filter(available=True).count() <= 1: + context_data['single_category'] = True + if not context_data['p_checked_categories']: + cat = '' + if SubCategory.objects.filter(available=True).count(): + cat = unicode(SubCategory.objects.filter(available=True + ).all()[0].pk) + context_data['p_checked_categories'] = "[%s]" % cat + if not context_data['p_checked_categories']: + context_data['p_checked_categories'] = "[]" context_data['dynamic_categories'] = 'true' \ if area and area.dynamic_categories else 'false' if 'request' not in context: diff --git a/chimere/views.py b/chimere/views.py index dd3f89a..59f6a8c 100644 --- a/chimere/views.py +++ b/chimere/views.py @@ -92,6 +92,7 @@ def get_base_response(area_name=""): area_name = area.urn except ObjectDoesNotExist: pass + base_response_dct['area'] = area base_response_dct['area_name'] = area_name if area and area.external_css: @@ -125,7 +126,7 @@ 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, 'action_selected':('view',), 'error_message':'', 'news_visible': news_visible, 'areas_visible': settings.CHIMERE_DISPLAY_AREAS, diff --git a/debian/control b/debian/control index 92cfa21..7317430 100644 --- a/debian/control +++ b/debian/control @@ -4,7 +4,6 @@ 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-unidecode + python-simplejson, gpsbabel, python-django-south 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 d0f918a..163c980 100644 --- a/docs/install.rst +++ b/docs/install.rst @@ -9,7 +9,7 @@ Chimère installation :Copyright: CC-BY 3.0 This documents presents the installation of Chimère. -The version has been updated for installation of version 2.0-RC3. +The version has been updated for installation of version 2.0-RC4. ----------------- Base installation @@ -60,8 +60,18 @@ 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 python-unidecode \ - gpsbabel + python-django-celery python-simplejson python-gdal gpsbabel + +On Debian Squeeze (you need to activate backports):: + + apt-get install -t squeeze-backports python-django + + apt-get install python python-django-south python-beautifulsoup tinymce \ + apache2 libgeos-3.2.0 proj-bin gdal-bin python-gdal python-lxml \ + python-psycopg2 python-imaging gettext postgresql-8.4 \ + postgresql-8.4-postgis libjs-jquery libjs-jquery-ui python-simplejson \ + python-gdal gpsbabel + If these packages do not exist in your distribution's repository, please refer to the applications' websites. @@ -78,9 +88,11 @@ chimere:: Then, you have to create the database and initialize the geographic types (adapt the paths accordingly to your needs):: + PG_VERSION=9.1 # 8.4 for debian Squeeze createdb --echo --owner chimere-user --encoding UNICODE chimere "My Chimère database" - psql -d chimere -f /usr/share/postgresql/9.1/contrib/postgis-1.5/postgis.sql - psql -d chimere -f /usr/share/postgresql/9.1/contrib/postgis-1.5/spatial_ref_sys.sql + createlang plpgsql chimere # only necessary on Debian Squeeze + psql -d chimere -f /usr/share/postgresql/$PG_VERSION/contrib/postgis-1.5/postgis.sql + psql -d chimere -f /usr/share/postgresql/$PG_VERSION/contrib/postgis-1.5/spatial_ref_sys.sql Install the sources ******************* @@ -88,7 +100,7 @@ Install the sources Choose a path to install your Chimère:: INSTALL_PATH=/var/local/django - sudo mkdir $INSTALL_PATH + mkdir $INSTALL_PATH From an archive +++++++++++++++ @@ -111,8 +123,8 @@ Download, unpack and move the files in an apache user (www-data for Debian) readable directory:: cd $INSTALL_PATH - sudo tar xvjf chimere-last.tar.bz2 - sudo chown -R myusername:www-data chimere + tar xvjf chimere-last.tar.bz2 + chown -R myusername:www-data chimere From the git repository +++++++++++++++++++++++ @@ -157,7 +169,6 @@ settings are initialized in settings.py. :: * PROJECT_NAME: name of the project * ROOT_URLCONF: url configuration for your project something like: 'mychimere_project.urls' - * ROOT_PATH: path to the installation of Chimère * EMAIL_HOST: smtp of an email server to send emails * TINYMCE_URL: url to tinymce path (default is appropriate for a Debian installation with tinymce activated) @@ -173,15 +184,15 @@ settings are initialized in settings.py. :: Manage media path permission:: cd $INSTALL_PATH/chimere/mychimere_project - sudo chown -R user:www-data media - sudo chmod -R g+w media + chown -R user:www-data media + chmod -R g+w media Create log file:: mkdir /var/log/django touch /var/log/django/chimere.log - sudo chown -R root:www-data /var/log/django/ - sudo chmod -R g+w /var/log/django/ + chown -R root:www-data /var/log/django/ + chmod -R g+w /var/log/django/ Regroup static files in one path:: @@ -236,26 +247,26 @@ Apache configuration with mod_wsgi Install mod_wsgi for apache:: - sudo apt-get install libapache2-mod-wsgi + apt-get install libapache2-mod-wsgi TODO: adapt apache-wsgi.conf Create and edit a configuration for Chimère:: - sudo cp $INSTALL_PATH/chimere/apache/django.wsgi \ + cp $INSTALL_PATH/chimere/apache/django.wsgi \ $INSTALL_PATH/chimere/apache/mydjango.wsgi - sudo vim $INSTALL_PATH/chimere/apache/mydjango.wsgi - sudo cp $INSTALL_PATH/chimere/apache/apache-wsgi.conf /etc/apache2/sites-available/chimere - sudo vim /etc/apache2/sites-available/chimere + vim $INSTALL_PATH/chimere/apache/mydjango.wsgi + cp $INSTALL_PATH/chimere/apache/apache-wsgi.conf /etc/apache2/sites-available/chimere + vim /etc/apache2/sites-available/chimere # create log dir - sudo mkdir /var/log/apache2/chimere/ + mkdir /var/log/apache2/chimere/ -Adapt the files *mydjango.wsgi* (with the correct sys path) and *chimere*. +Adapt the files *mydjango.wsgi* (with the correct sys path) and Apache *chimere*. To activate the website reload apache:: - sudo a2ensite chimere - sudo /etc/init.d/apache2 reload + a2ensite chimere + /etc/init.d/apache2 reload ------------------ Base configuration |
