From dea5c621b770f9e72d41cab42e4a15e49a0bc1a9 Mon Sep 17 00:00:00 2001 From: Étienne Loks Date: Wed, 17 Nov 2010 17:54:46 +0100 Subject: Adapt with the new way of defining database in Django 1.2 --- chimere/settings.py.example | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) (limited to 'chimere/settings.py.example') diff --git a/chimere/settings.py.example b/chimere/settings.py.example index c0f6cb6..edfaa2e 100644 --- a/chimere/settings.py.example +++ b/chimere/settings.py.example @@ -49,12 +49,16 @@ ADMINS = ( MANAGERS = ADMINS -DATABASE_ENGINE = 'postgresql_psycopg2' # 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'ado_mssql'. -DATABASE_NAME = 'ratatouille' # Or path to database file if using sqlite3. -DATABASE_USER = 'ratatouille' # Not used with sqlite3. -DATABASE_PASSWORD = 'wiki' # Not used with sqlite3. -DATABASE_HOST = '' # Set to empty string for localhost. Not used with sqlite3. -DATABASE_PORT = '' # Set to empty string for default. Not used with sqlite3. +DATABASES = { + 'default': { + 'NAME': 'ratatouille', + 'ENGINE': 'django.contrib.gis.db.backends.postgis', + 'HOST': 'localhost', + 'PORT': '5432', + 'USER': 'ratatouille', + 'PASSWORD': 'wiki', + }, +} # Local time zone for this installation. Choices can be found here: # http://www.postgresql.org/docs/8.1/static/datetime-keywords.html#DATETIME-TIMEZONE-SET-TABLE -- cgit v1.2.3 From 52b79196688dacf5a7874db254bbd9b9748d8ee3 Mon Sep 17 00:00:00 2001 From: Étienne Loks Date: Thu, 18 Nov 2010 22:50:17 +0100 Subject: Make the management of dated object optionnal (refs #270) --- chimere/main/models.py | 18 ++++++++++-------- chimere/scripts/upgrade.py | 30 +++++++++++++++--------------- chimere/settings.py.example | 3 +++ 3 files changed, 28 insertions(+), 23 deletions(-) (limited to 'chimere/settings.py.example') diff --git a/chimere/main/models.py b/chimere/main/models.py index 489d48d..28f1446 100644 --- a/chimere/main/models.py +++ b/chimere/main/models.py @@ -197,10 +197,11 @@ class Marker(models.Model): for key, label in STATUS: STATUS_DCT[key] = label status = models.CharField(_("Status"), max_length=1, choices=STATUS) - start_date = models.DateField(_("Start date"), blank=True, null=True, - help_text=_("Not mandatory. Set it for dated item such as event.")) - end_date = models.DateField(_("End date"), blank=True, null=True, - help_text=_("Not mandatory. Set it only if you have set a start date.")) + if settings.DAYS_BEFORE_EVENT: + start_date = models.DateField(_("Start date"), blank=True, null=True, +help_text=_("Not mandatory. Set it for dated item such as event.")) + end_date = models.DateField(_("End date"), blank=True, null=True, +help_text=_("Not mandatory. Set it only if you have set a start date.")) objects = models.GeoManager() def __unicode__(self): @@ -272,10 +273,11 @@ class Route(models.Model): STATUS_DCT = {} for key, label in STATUS: STATUS_DCT[key] = label - start_date = models.DateField(_("Start date"), blank=True, null=True, - help_text=_("Not mandatory. Set it for dated item such as event.")) - end_date = models.DateField(_("End date"), blank=True, null=True, - help_text=_("Not mandatory. Set it only if you have set a start date.")) + if settings.DAYS_BEFORE_EVENT: + start_date = models.DateField(_("Start date"), blank=True, null=True, +help_text=_("Not mandatory. Set it for dated item such as event.")) + end_date = models.DateField(_("End date"), blank=True, null=True, +help_text=_("Not mandatory. Set it only if you have set a start date.")) status = models.CharField(_("Status"), max_length=1, choices=STATUS) objects = models.GeoManager() diff --git a/chimere/scripts/upgrade.py b/chimere/scripts/upgrade.py index bd6e46e..8f5c65a 100755 --- a/chimere/scripts/upgrade.py +++ b/chimere/scripts/upgrade.py @@ -189,22 +189,22 @@ for cls, attr in ((Icon, "image"), (Marker, "picture"), print " * height and width of " + table + " corrected" # changement from version 1.0 to 1.1: add dated fields to markers and routes - -for cls in (Marker, Route): - table = cls._meta.db_table - query = QUERY_CHECK_FIELD % (table, 'start_date') - cursor.execute(query) - transaction.commit_unless_managed() - - row = cursor.fetchone() - if not row: - query_update = "ALTER TABLE "+table+" ADD COLUMN start_date date" - cursor.execute(query_update) - transaction.commit_unless_managed() - query_update = "ALTER TABLE "+table+" ADD COLUMN end_date date" - cursor.execute(query_update) +if settings.DAYS_BEFORE_EVENT: + for cls in (Marker, Route): + table = cls._meta.db_table + query = QUERY_CHECK_FIELD % (table, 'start_date') + cursor.execute(query) transaction.commit_unless_managed() - print " * start_date and end_date added to table " + table + "." + + row = cursor.fetchone() + if not row: + query_update = "ALTER TABLE "+table+" ADD COLUMN start_date date" + cursor.execute(query_update) + transaction.commit_unless_managed() + query_update = "ALTER TABLE "+table+" ADD COLUMN end_date date" + cursor.execute(query_update) + transaction.commit_unless_managed() + print " * start_date and end_date added to table " + table + "." # changement from version 1.0 to 1.1: multiple selection of categories diff --git a/chimere/settings.py.example b/chimere/settings.py.example index edfaa2e..ebb4fc5 100644 --- a/chimere/settings.py.example +++ b/chimere/settings.py.example @@ -31,6 +31,9 @@ DYNAMIC_CATEGORIES = False DISPLAY_AREAS = True # specific css for areas CSS_AREAS = True +# number of day before an event to display +# if equal to 0: disable event management +DAYS_BEFORE_EVENT = 30 # default id category to check on the map DEFAULT_CATEGORIES = [1] -- cgit v1.2.3 From 005b59d77fbb07900209afacc31c0f39f4f40d0d Mon Sep 17 00:00:00 2001 From: Étienne Loks Date: Fri, 19 Nov 2010 00:52:08 +0100 Subject: Verify that a start date is provided when an end date is set (refs #270) --- chimere/main/forms.py | 13 +++++++++++++ chimere/settings.py.example | 3 +++ 2 files changed, 16 insertions(+) (limited to 'chimere/settings.py.example') diff --git a/chimere/main/forms.py b/chimere/main/forms.py index c3cd810..76a2a17 100644 --- a/chimere/main/forms.py +++ b/chimere/main/forms.py @@ -116,6 +116,19 @@ required=False)' % (property.order, property.id, property.name, self.fields['start_date'].widget = AdminDateWidget() self.fields['end_date'].widget = AdminDateWidget() + def clean(self): + ''' + Verify that a start date is provided when an end date is set + ''' + if not settings.DAYS_BEFORE_EVENT: + return self.cleaned_data + if self.cleaned_data['end_date'] and \ + not self.cleaned_data['start_date']: + msg = _(u"End date has been set with no start date") + self._errors["end_date"] = self.error_class([msg]) + del self.cleaned_data['end_date'] + return self.cleaned_data + def save(self, *args, **keys): """ Custom save method in order to manage associeted properties diff --git a/chimere/settings.py.example b/chimere/settings.py.example index ebb4fc5..d59d119 100644 --- a/chimere/settings.py.example +++ b/chimere/settings.py.example @@ -33,6 +33,9 @@ DISPLAY_AREAS = True CSS_AREAS = True # number of day before an event to display # if equal to 0: disable event management +# if you change this value from 0 to a value in a production environnement +# don't forget to run the upgrade.py script to create appropriate fields in +# the database DAYS_BEFORE_EVENT = 30 # default id category to check on the map -- cgit v1.2.3 From 7211864b0d3212d1439f93ab2aa213b47827bf02 Mon Sep 17 00:00:00 2001 From: Étienne Loks Date: Fri, 19 Nov 2010 18:21:14 +0100 Subject: Add a new application "rss". Add urls to manage RSS. Rough integration of work of Pierre Clarenc and Samuel Renard (refs #65) --- chimere/main/actions.py | 6 +- chimere/main/forms.py | 8 ++ chimere/main/models.py | 3 + chimere/rss/__init__.py | 1 + chimere/rss/feeds.py | 253 ++++++++++++++++++++++++++++++++++++++++++++ chimere/rss/urls.py | 42 ++++++++ chimere/rss/views.py | 153 +++++++++++++++++++++++++++ chimere/settings.py.example | 3 + chimere/urls.py | 46 ++++---- 9 files changed, 493 insertions(+), 22 deletions(-) create mode 100644 chimere/rss/__init__.py create mode 100644 chimere/rss/feeds.py create mode 100644 chimere/rss/urls.py create mode 100644 chimere/rss/views.py (limited to 'chimere/settings.py.example') diff --git a/chimere/main/actions.py b/chimere/main/actions.py index f86e954..c6d2060 100644 --- a/chimere/main/actions.py +++ b/chimere/main/actions.py @@ -23,7 +23,7 @@ Actions available in the main interface from django.utils.translation import ugettext_lazy as _ from django.contrib.auth import models -from chimere.settings import EXTRA_URL, EMAIL_HOST +from chimere.settings import EXTRA_URL, EMAIL_HOST, INSTALLED_APPS class Action: def __init__(self, id, path, label): @@ -36,3 +36,7 @@ actions = [(Action('view', '', _('View')), []), ),] if EMAIL_HOST: actions.append((Action('contact', 'contact', _('Contact us')), []),) + +if 'chimere.rss' in INSTALLED_APPS: + actions.append(Action('rss', 'rss', _('Feeds')), []) + diff --git a/chimere/main/forms.py b/chimere/main/forms.py index 76a2a17..e1e3168 100644 --- a/chimere/main/forms.py +++ b/chimere/main/forms.py @@ -288,3 +288,11 @@ class AreaAdminForm(forms.ModelForm): if perm: perm[0].delete() return new_area + +class AreaForm(AreaAdminForm): + """ + Form for the edit page + """ + class Meta: + model = Area + diff --git a/chimere/main/models.py b/chimere/main/models.py index 51e8693..093918b 100644 --- a/chimere/main/models.py +++ b/chimere/main/models.py @@ -206,6 +206,9 @@ Format YYYY-MM-DD")) end_date = models.DateField(_("End date"), blank=True, null=True, help_text=_("Not mandatory. Set it only if you have a multi-day event. \ Format YYYY-MM-DD")) + if 'chimere.rss' in settings.INSTALLED_APPS: + available_date = models.DateTimeField(_("Available Date"), blank=True, + null=True) objects = models.GeoManager() def __unicode__(self): diff --git a/chimere/rss/__init__.py b/chimere/rss/__init__.py new file mode 100644 index 0000000..792d600 --- /dev/null +++ b/chimere/rss/__init__.py @@ -0,0 +1 @@ +# diff --git a/chimere/rss/feeds.py b/chimere/rss/feeds.py new file mode 100644 index 0000000..c24281c --- /dev/null +++ b/chimere/rss/feeds.py @@ -0,0 +1,253 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- +# Copyright (C) 2010 Pierre Clarenc , +# Samuel Renard , +# Étienne Loks + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +# See the file COPYING for details. + +from django.contrib.syndication.feeds import Feed +from django.contrib.syndication.feeds import FeedDoesNotExist +from chimere.main.models import Category, SubCategory, Marker, Area +from django.core.exceptions import ObjectDoesNotExist +from django.contrib.gis.geos import * + +from chimere import settings + + +class LatestPOIsByCategory(Feed): + ''' + Last Points of interests by category in Feeds + ''' + + title_template = "rss_title.html" + description_template = "rss_descr.html" + # Get extra url, after rss/category/ -> bits[0]=id of category + def get_object(self, bits): + if len(bits) != 1: + raise ObjectDoesNotExist + return Category.objects.get(id__exact=bits[0]) + # Define the title of the feed, here The name of the category + def title(self, obj): + return "Chimere - %s" % obj.name + # Define the link of the feed. Feeds agregators update at this link + def link(self, obj): + if not obj: + raise FeedDoesNotExist + return settings.BASE_URL + 'rss/category/' + str(obj.id) + # Description of the feed + def description(self, obj): + return obj.description + # Link of the item/POI. Here the link is the permalink of the marker/POI + def item_link(self, item): + # Return the permalink of the POI : + # Get thirst the attribute point of the marker + # Then we had to transform this to the good system metric. From srid=4326 to srid=900913 + coord = item.point + coord.transform(settings.EPSG_PROJECTION) + return settings.BASE_URL + '?zoom=16&lat=' + str(coord.y) + '&lon=' + str(coord.x) + '&layers=BTT&checked_categories=1&display_submited=false' + # Date of the Marker when it has been available + def item_pubdate(self,item): + return item.avail_date + # Requests to marker where its category match the category is requested AND its status is available + # This returns a list of the 15 last markers/POIs ordering by date + def items(self, obj): + return Marker.objects.filter(subcategory__category__id__exact=obj.id, status__exact='A').order_by('-avail_date')[:15] + +class LatestPOIsBySubCategory(Feed): + ''' + Last Points of interests by SubCategory in Feeds + ''' + title_template = "rss_title.html" + description_template = "rss_descr.html" + + def get_object(self, bits): + if len(bits) != 1: + raise ObjectDoesNotExist + return SubCategory.objects.get(id__exact=bits[0]) + + def title(self, obj): + return obj.category.name + "Chimere - %s" % obj.name + + def link(self, obj): + if not obj: + raise FeedDoesNotExist + return settings.BASE_URL + 'rss/subcategory/' + str(obj.id) + + def description(self, obj): + return "" + + def item_link(self, item): + # Renvoyer le permalink du POI : + coord = item.point + coord.transform(settings.EPSG_PROJECTION) + return settings.BASE_URL + '?zoom=16&lat=' + str(coord.y) + '&lon=' + str(coord.x) + '&layers=BTT&checked_categories=1&display_submited=false' + + def item_pubdate(self,item): + return item.avail_date + + def items(self, obj): + return Marker.objects.filter(subcategory__id__exact=obj.id, status__exact='A').order_by('-avail_date')[:15] + +class LatestPOIs(Feed): + ''' + Last Points of interests + ''' + title_template = "rss_title.html" + description_template = "rss_descr.html" + + def title(self): + return "Chimere - Last POIs" + + def link(self): + return settings.BASE_URL + 'rss/categories/' + + def description(self): + return "Latest POIs from Chimere" + + def item_link(self, item): + # Renvoyer le permalink du POI : + coord = item.point + coord.transform(settings.EPSG_PROJECTION) + return settings.BASE_URL + '?zoom=16&lat=' + str(coord.y) + '&lon=' + str(coord.x) + '&layers=BTT&checked_categories=1&display_submited=false' + + def item_pubdate(self,item): + return item.avail_date + + def items(self): + return Marker.objects.filter(status__exact='A').order_by('-avail_date')[:15] + + +class LatestPOIsByZone(Feed): + ''' + Last Points of interests by zone by coordinates + ''' + title_template = "rss_title.html" + description_template = "rss_descr.html" + # Attributes which store coordinates of the requested zone + upper_left_lat = 0 + upper_left_lon = 0 + lower_right_lat = 0 + lower_right_lon = 0 + + def get_object(self, bits): + if len(bits) != 1: + raise ObjectDoesNotExist + # Get the extra url. Parameters are the coordinates of the zone (the upper left and lower right points) + # Then define the upper right and lower left points + coordinates = str(bits[0]).split(',') + upper_left_lat = float(coordinates[0]) + upper_left_lon = float(coordinates[1]) + lower_right_lat = float(coordinates[2]) + lower_right_lon = float(coordinates[3]) + + upper_right_lat = upper_left_lat + upper_right_lon = lower_right_lon + lower_left_lat = lower_right_lat + lower_left_lon = upper_left_lon + # Define a Polygon with the 4 points of the zone. + # Cordinates are define with a srid=900913, use by google, yahoo but no OpenStreeMap + areaBox = Polygon(((upper_left_lon, upper_left_lat), + (upper_right_lon, upper_right_lat), + (lower_right_lon, lower_right_lat), + (lower_left_lon, lower_left_lat), + (upper_left_lon, upper_left_lat)), + srid=settings.EPSG_PROJECTION) + # OSM uses the standard srid=4326, wich uses the real pairs latitude/longitude in degrees. + areaBox.transform(settings.EPSG_DISPLAY_PROJECTION) + + return areaBox + + def title(self, obj): + return "Chimere - Last POIs by area" + # Define the link of the feed. It's the same url as we get in the method get_object + def link(self, obj): + if not obj: + raise FeedDoesNotExist + return settings.BASE_URL + 'rss/area/' + str(self.upper_left_lat) + ',' + str(self.upper_left_lon) + ',' + str(self.lower_right_lat) + ',' + str(self.lower_right_lon) + + def description(self, obj): + return "" + + # Link of the item/POI. Here the link is the permalink of the marker/POI + def item_link(self, item): + # Return the permalink of the POI : + # Get thirst the attribute point of the marker + # Then we had to transform this to the good system metric. From srid=4326 to srid=900913 + coord = item.point + coord.transform(settings.EPSG_PROJECTION) + return settings.BASE_URL + '?zoom=16&lat=' + str(coord.y) + '&lon=' + str(coord.x) + '&layers=BTT&checked_categories=1&display_submited=false' + # Return the date of the Marker + def item_pubdate(self,item): + return item.avail_date + # Request to return Markers WHERE there points are containes in the zone which is requested. + # This returns a list of the 15 last markers/POIs ordering by date + def items(self, obj): + return Marker.objects.filter(point__contained=obj, status__exact='A').order_by('-avail_date')[:15] + +class LatestPOIsByZoneID(Feed): + ''' + Last Points of interests by zone by id + ''' + title_template = "rss_title.html" + description_template = "rss_descr.html" + + def get_object(self, bits): + if len(bits) != 1: + raise ObjectDoesNotExist + + return Area.objects.get(id__exact=bits[0]) + + def title(self, obj): + return "Chimere - Last POIs of %s" % obj.name + + def link(self, obj): + if not obj: + raise FeedDoesNotExist + return settings.BASE_URL + 'rss/areaid/' + str(obj.id) + + def description(self, obj): + return "" + + def item_link(self, item): + coord = item.point + coord.transform(settings.EPSG_PROJECTION) + return settings.BASE_URL + '?zoom=16&lat=' + str(coord.y) + '&lon=' + str(coord.x) + '&layers=BTT&checked_categories=1&display_submited=false' + + def item_pubdate(self,item): + return item.avail_date + + def items(self, obj): + upper_left_lat = float(obj.upper_left_corner.x) + upper_left_lon = float(obj.upper_left_corner.y) + lower_right_lat = float(obj.lower_right_corner.x) + lower_right_lon = float(obj.lower_right_corner.y) + + upper_right_lat = upper_left_lat + upper_right_lon = lower_right_lon + lower_left_lat = lower_right_lat + lower_left_lon = upper_left_lon + + areaBox = Polygon(((upper_left_lon, upper_left_lat), + (upper_right_lon, upper_right_lat), + (lower_right_lon, lower_right_lat), + (lower_left_lon, lower_left_lat), + (upper_left_lon, upper_left_lat)), + srid=settings.EPSG_PROJECTION) + + areaBox.transform(settings.EPSG_DISPLAY_PROJECTION) + + return Marker.objects.filter(point__contained=areaBox) diff --git a/chimere/rss/urls.py b/chimere/rss/urls.py new file mode 100644 index 0000000..3b61969 --- /dev/null +++ b/chimere/rss/urls.py @@ -0,0 +1,42 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- +# Copyright (C) 2010 Pierre Clarenc , +# Samuel Renard , +# Étienne Loks + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +# See the file COPYING for details. + + +from django.conf.urls.defaults import * + +from chimere.rss.feeds import LatestPOIsByCategory, LatestPOIsBySubCategory, \ + LatestPOIs, LatestPOIsByZone, LatestPOIsByZoneID +from chimere.urls import BASE, EXTRA + +feeds = { + 'category': LatestPOIsByCategory, + 'subcategory': LatestPOIsBySubCategory, + 'global': LatestPOIs, + 'area': LatestPOIsByZone, + 'areaid': LatestPOIsByZoneID +} + +urlpatterns = patterns('', + (BASE + EXTRA + r'rss/$', 'chimere.rss.views.rss'), + (BASE + EXTRA + r'rss/(?P.*)/$', + 'django.contrib.syndication.views.feed', {'feed_dict': feeds}), +) + diff --git a/chimere/rss/views.py b/chimere/rss/views.py new file mode 100644 index 0000000..12269cd --- /dev/null +++ b/chimere/rss/views.py @@ -0,0 +1,153 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- +# Copyright (C) 2010 Pierre Clarenc , +# Samuel Renard , +# Étienne Loks + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +# See the file COPYING for details. + +""" +Views of the project +""" + +import datetime + +from django.shortcuts import render_to_response +from django.template import loader +from django.http import HttpResponseRedirect, HttpResponse +from django.core import serializers + +from chimere import settings +from chimere.main.actions import actions + +from chimere.main.models import Category, SubCategory, PropertyModel, Marker, \ + Route, News, Area, Color + +# Pierre CLARENC : 19/01/2010 : Add AreaWidget +from chimere.main.widgets import getMapJS, PointChooserWidget, \ + RouteChooserWidget, URL_OSM_JS, URL_OSM_CSS, AreaWidget +# Pierre CLARENC : 19/01/2010 : End +# Pierre CLARENC : 19/01/2010 : Add AreaAdminForm +from chimere.main.forms import MarkerForm, RouteForm, AreaForm, notifyStaff +# Pierre CLARENC : 19/01/2010 : End + +def rss(request): + ''' + Redirect to RSS subscription page + ''' + # If the form has been submited + if request.method == "POST": + + # User has defined the kind of POI he is interested in : POI in a area (GET method is used for the link with RSS icon in the browser) + if 'rss_category' in request.POST: + #User wants to follow all the new POI + if request.POST['rss_category'] == 'global': + feeds_link = '/' + settings.EXTRA_URL + 'rss/global/' + return HttpResponseRedirect(feeds_link) + # User wants to follow all the new POI by category or subcategory + elif request.POST['rss_category'] == 'poi': + response_dct = {'actions':actions, 'action_selected':'rss', + 'media_path':settings.MEDIA_URL, + 'extra_url':settings.EXTRA_URL, + 'category_rss_feed':'category', + 'sub_categories':SubCategory.getAvailable(['M', 'B']) + } + return render_to_response('rss.html', response_dct) + # User wants to follow all the new POI situated in a defined area + elif request.POST['rss_category'] == 'area': + # An unbound form + form = AreaForm() + response_dct = {'actions':actions, 'action_selected':'rss', + 'media_path':settings.MEDIA_URL, + 'extra_url':settings.EXTRA_URL, + 'map_layer':settings.MAP_LAYER, + 'extra_head':form.media, + 'form':form, + 'category_rss_feed':'area', + 'area_id':Area.getAvailable(), + 'area_widget':AreaWidget().render('area', None) + } + return render_to_response('rss.html', response_dct) + # Error when submitting the form + else: + response_dct = {'actions':actions, 'action_selected':'rss', + 'media_path':settings.MEDIA_URL, + 'extra_url':settings.EXTRA_URL, + 'error_message':'Error - Please choose a correct choice in the list', + 'category_rss_feed':'category', + 'sub_categories':SubCategory.getAvailable(['M', 'B']) + } + return render_to_response('rss.html', response_dct) + + # User has specified the category or subcategory he wants to follow => we redirect him towards the related rss feed + if 'subcategory' in request.POST and request.POST['subcategory'] != '': + idCat = request.POST['subcategory'] + if idCat.find("cat_") != -1 : + list_Cat = idCat.split('_') + feeds_link = '/' + settings.EXTRA_URL + 'rss/category/' + list_Cat[1] + return HttpResponseRedirect(feeds_link) + + else: + feeds_link = '/' + settings.EXTRA_URL + 'rss/subcategory/' + idCat + return HttpResponseRedirect(feeds_link) + + # User has specified the ID of the area he wants to follow + if 'id_area' in request.POST and request.POST['id_area'] != '': + feeds_link = '/' + settings.EXTRA_URL + 'rss/areaid/' + request.POST['id_area'] + return HttpResponseRedirect(feeds_link) + + # User has specified the area he wants to follow => we redirect him towards the related rss feed (using upper left and lower right coordinates) + elif 'upper_left_lat' in request.POST and request.POST['upper_left_lat'] != '' and 'upper_left_lon' in request.POST and request.POST['upper_left_lon'] != '' and 'lower_right_lon' in request.POST and request.POST['lower_right_lon'] != '' and 'lower_right_lat' in request.POST and request.POST['lower_right_lat'] != '' : + feeds_link = '/' + settings.EXTRA_URL + 'rss/area/' + request.POST['upper_left_lat'] + ',' + request.POST['upper_left_lon'] + ',' + request.POST['lower_right_lat'] + ',' + request.POST['lower_right_lon'] + return HttpResponseRedirect(feeds_link) + + + # GET method is used for linking with the RSS icon in the browser when user wants to choose a category to follow + elif request.method == "GET" and 'rss_category' in request.GET: + if request.GET['rss_category'] == 'global': + feeds_link = '/' + settings.EXTRA_URL + 'rss/global/' + return HttpResponseRedirect(feeds_link) + if request.GET['rss_category'] == 'poi': + response_dct = {'actions':actions, 'action_selected':'rss', + 'media_path':settings.MEDIA_URL, + 'extra_url':settings.EXTRA_URL, + 'category_rss_feed':'category', + 'sub_categories':SubCategory.getAvailable(['M', 'B']) + } + return render_to_response('rss.html', response_dct) + if request.GET['rss_category'] == 'area': + # An unbound form + form = AreaForm() + response_dct = {'actions':actions, 'action_selected':'rss', + 'media_path':settings.MEDIA_URL, + 'extra_url':settings.EXTRA_URL, + 'map_layer':settings.MAP_LAYER, + 'extra_head':form.media, + 'form':form, + 'category_rss_feed':'area', + 'area_id':Area.getAvailable(), + 'area_widget':AreaWidget().render('area', None) + } + return render_to_response('rss.html', response_dct) + + # User access to the RSS tab + else: + response_dct = {'actions':actions, 'action_selected':'rss', + 'media_path':settings.MEDIA_URL, + 'category_rss_feed':'', + 'extra_url':settings.EXTRA_URL + } + return render_to_response('rss.html', response_dct) diff --git a/chimere/settings.py.example b/chimere/settings.py.example index d59d119..54118a9 100644 --- a/chimere/settings.py.example +++ b/chimere/settings.py.example @@ -142,5 +142,8 @@ INSTALLED_APPS = ( 'django.contrib.sessions', 'django.contrib.sites', 'chimere.main', + # activate it if you want to use migration scripts 'chimere.scripts', + # activate it if you want to use RSS feeds + 'chimere.rss' ) diff --git a/chimere/urls.py b/chimere/urls.py index 5ba0630..d32b628 100644 --- a/chimere/urls.py +++ b/chimere/urls.py @@ -31,47 +31,51 @@ js_info_dict = { 'packages': 'chimere', } -base = '^' + EXTRA_URL +BASE = '^' + EXTRA_URL urlpatterns = patterns('', - (base + r'admin/(.*)', admin.site.root), - (base + r'static/(?P.*)$', 'django.views.static.serve', + (BASE + r'admin/(.*)', admin.site.root), + (BASE + r'static/(?P.*)$', 'django.views.static.serve', {'document_root': ROOT_PATH + 'static/'}), - (base + r'media/(?P.*)$', 'django.views.static.serve', + (BASE + r'media/(?P.*)$', 'django.views.static.serve', {'document_root': ROOT_PATH + 'media/'}), - (base + r'jsi18n/$', 'django.views.i18n.javascript_catalog', js_info_dict), + (BASE + r'jsi18n/$', 'django.views.i18n.javascript_catalog', js_info_dict), ) urlpatterns += patterns('chimere.main.views', ) url_areas = Area.objects.filter(urn__isnull=False) -urlpatterns += patterns('chimere.main.views', (base + r'$', 'index'), - (base + r'simple/?$', 'index', {'simple':True}) ) +urlpatterns += patterns('chimere.main.views', (BASE + r'$', 'index'), + (BASE + r'simple/?$', 'index', {'simple':True}) ) for area in url_areas: urlpatterns += patterns('chimere.main.views', - (base + '(' + area.urn + ')/?$', 'index', {'default_area':area}), - (base + '(' + area.urn + ')/simple/?$', 'index', {'default_area':area, + (BASE + '(' + area.urn + ')/?$', 'index', {'default_area':area}), + (BASE + '(' + area.urn + ')/simple/?$', 'index', {'default_area':area, 'simple':True}),) -extra = "|".join([area.urn for area in url_areas]) +EXTRA = "|".join([area.urn for area in url_areas]) default_dct = {} -if extra: - extra = "(?P%s)?/?" % extra +if EXTRA: + EXTRA = "(?P%s)?/?" % EXTRA else: default_dct = {'area_name':''} urlpatterns += patterns('chimere.main.views', -(base + extra + r'contact/$', 'contactus', default_dct), -(base + extra + r'edit/$', 'edit', default_dct), -(base + extra + r'edit_route/$', 'editRoute', default_dct), -(base + extra + r'submited/(?P\w+)/$', 'submited', default_dct), -(base + extra + r'getDetail/(?P\d+)/$', 'getDetail', default_dct), -(base + extra + r'getDescriptionDetail/(?P\d+)/$', +(BASE + EXTRA + r'contact/$', 'contactus', default_dct), +(BASE + EXTRA + r'edit/$', 'edit', default_dct), +(BASE + EXTRA + r'edit_route/$', 'editRoute', default_dct), +(BASE + EXTRA + r'submited/(?P\w+)/$', 'submited', default_dct), +(BASE + EXTRA + r'getDetail/(?P\d+)/$', 'getDetail', default_dct), +(BASE + EXTRA + r'getDescriptionDetail/(?P\d+)/$', 'getDescriptionDetail', default_dct), -(base + extra + r'getGeoObjects/(?P\w+)(/(?P\w+))?$', +(BASE + EXTRA + r'getGeoObjects/(?P\w+)(/(?P\w+))?$', 'getGeoObjects', default_dct), -(base + extra + r'getAvailableCategories/((?P\w+))?(/(?P\w+))?(/(?P\w+))?$', +(BASE + EXTRA + r'getAvailableCategories/((?P\w+))?(/(?P\w+))?(/(?P\w+))?$', 'getAvailableCategories', default_dct), -(base + extra + r'ty/(?P\w+)$', 'redirectFromTinyURN', default_dct), +(BASE + EXTRA + r'ty/(?P\w+)$', 'redirectFromTinyURN', default_dct), ) + +if 'chimere.rss' in settings.INSTALLED_APPS: + urlpatterns += patterns('', + (r'^' + EXTRA_URL, include('chimere.rss.urls')),) -- cgit v1.2.3 From 91e36a67f858d25fe6d7f38310a589a59c798f21 Mon Sep 17 00:00:00 2001 From: Étienne Loks Date: Fri, 19 Nov 2010 20:16:55 +0100 Subject: Cosmetic changes (refs #65) --- chimere/rss/feeds.py | 94 +++++++++++++++++++++++++-------------------- chimere/rss/views.py | 92 ++++++++++++++++++++++++++------------------ chimere/settings.py.example | 7 +++- 3 files changed, 113 insertions(+), 80 deletions(-) (limited to 'chimere/settings.py.example') diff --git a/chimere/rss/feeds.py b/chimere/rss/feeds.py index c24281c..af7956b 100644 --- a/chimere/rss/feeds.py +++ b/chimere/rss/feeds.py @@ -32,7 +32,6 @@ class LatestPOIsByCategory(Feed): ''' Last Points of interests by category in Feeds ''' - title_template = "rss_title.html" description_template = "rss_descr.html" # Get extra url, after rss/category/ -> bits[0]=id of category @@ -42,7 +41,7 @@ class LatestPOIsByCategory(Feed): return Category.objects.get(id__exact=bits[0]) # Define the title of the feed, here The name of the category def title(self, obj): - return "Chimere - %s" % obj.name + return u"%s - %s" % (settings.PROJECT_NAME, obj.name) # Define the link of the feed. Feeds agregators update at this link def link(self, obj): if not obj: @@ -57,15 +56,19 @@ class LatestPOIsByCategory(Feed): # Get thirst the attribute point of the marker # Then we had to transform this to the good system metric. From srid=4326 to srid=900913 coord = item.point - coord.transform(settings.EPSG_PROJECTION) - return settings.BASE_URL + '?zoom=16&lat=' + str(coord.y) + '&lon=' + str(coord.x) + '&layers=BTT&checked_categories=1&display_submited=false' + #coord.transform(settings.EPSG_PROJECTION) + lnk = settings.BASE_URL + '?zoom=16&lat=' + str(coord.y) + '&lon=' + \ +str(coord.x) + '&layers=BTT&checked_categories=1&display_submited=false' + return lnk # Date of the Marker when it has been available def item_pubdate(self,item): - return item.avail_date + return item.available_date # Requests to marker where its category match the category is requested AND its status is available # This returns a list of the 15 last markers/POIs ordering by date def items(self, obj): - return Marker.objects.filter(subcategory__category__id__exact=obj.id, status__exact='A').order_by('-avail_date')[:15] + return Marker.objects.filter(status__exact='A', + categories__subcategory__category__id__exact=obj.id).order_by( + '-available_date')[:15] class LatestPOIsBySubCategory(Feed): ''' @@ -73,14 +76,14 @@ class LatestPOIsBySubCategory(Feed): ''' title_template = "rss_title.html" description_template = "rss_descr.html" - def get_object(self, bits): if len(bits) != 1: raise ObjectDoesNotExist return SubCategory.objects.get(id__exact=bits[0]) def title(self, obj): - return obj.category.name + "Chimere - %s" % obj.name + return obj.category.name + u"%s - %s" % (settings.PROJECT_NAME, + obj.name) def link(self, obj): if not obj: @@ -93,14 +96,16 @@ class LatestPOIsBySubCategory(Feed): def item_link(self, item): # Renvoyer le permalink du POI : coord = item.point - coord.transform(settings.EPSG_PROJECTION) - return settings.BASE_URL + '?zoom=16&lat=' + str(coord.y) + '&lon=' + str(coord.x) + '&layers=BTT&checked_categories=1&display_submited=false' + #coord.transform(settings.EPSG_PROJECTION) + return settings.BASE_URL + '?zoom=16&lat=' + str(coord.y) + '&lon=' + \ +str(coord.x) + '&layers=BTT&checked_categories=1&display_submited=false' def item_pubdate(self,item): - return item.avail_date + return item.available_date def items(self, obj): - return Marker.objects.filter(subcategory__id__exact=obj.id, status__exact='A').order_by('-avail_date')[:15] + return Marker.objects.filter(categories_subcategory__id__exact=obj.id, + status__exact='A').order_by('-available_date')[:15] class LatestPOIs(Feed): ''' @@ -110,7 +115,7 @@ class LatestPOIs(Feed): description_template = "rss_descr.html" def title(self): - return "Chimere - Last POIs" + return u"%s - Last POIs" % settings.PROJECT_NAME def link(self): return settings.BASE_URL + 'rss/categories/' @@ -121,14 +126,16 @@ class LatestPOIs(Feed): def item_link(self, item): # Renvoyer le permalink du POI : coord = item.point - coord.transform(settings.EPSG_PROJECTION) - return settings.BASE_URL + '?zoom=16&lat=' + str(coord.y) + '&lon=' + str(coord.x) + '&layers=BTT&checked_categories=1&display_submited=false' + #coord.transform(settings.EPSG_PROJECTION) + return settings.BASE_URL + '?zoom=16&lat=' + str(coord.y) + '&lon=' + \ +str(coord.x) + '&layers=BTT&checked_categories=1&display_submited=false' def item_pubdate(self,item): - return item.avail_date + return item.available_date def items(self): - return Marker.objects.filter(status__exact='A').order_by('-avail_date')[:15] + return Marker.objects.filter(status__exact='A' + ).order_by('-available_date')[:15] class LatestPOIsByZone(Feed): @@ -146,18 +153,19 @@ class LatestPOIsByZone(Feed): def get_object(self, bits): if len(bits) != 1: raise ObjectDoesNotExist - # Get the extra url. Parameters are the coordinates of the zone (the upper left and lower right points) + # Get the extra url. Parameters are the coordinates of the zone (the + # upper left and lower right points) # Then define the upper right and lower left points coordinates = str(bits[0]).split(',') upper_left_lat = float(coordinates[0]) upper_left_lon = float(coordinates[1]) lower_right_lat = float(coordinates[2]) lower_right_lon = float(coordinates[3]) - + """ upper_right_lat = upper_left_lat upper_right_lon = lower_right_lon lower_left_lat = lower_right_lat - lower_left_lon = upper_left_lon + lower_left_lon = upper_left_lon""" # Define a Polygon with the 4 points of the zone. # Cordinates are define with a srid=900913, use by google, yahoo but no OpenStreeMap areaBox = Polygon(((upper_left_lon, upper_left_lat), @@ -167,36 +175,42 @@ class LatestPOIsByZone(Feed): (upper_left_lon, upper_left_lat)), srid=settings.EPSG_PROJECTION) # OSM uses the standard srid=4326, wich uses the real pairs latitude/longitude in degrees. - areaBox.transform(settings.EPSG_DISPLAY_PROJECTION) + #areaBox.transform(settings.EPSG_DISPLAY_PROJECTION) return areaBox - + def title(self, obj): - return "Chimere - Last POIs by area" + return u"%s - Last POIs by area" % settings.PROJECT_NAME # Define the link of the feed. It's the same url as we get in the method get_object def link(self, obj): if not obj: raise FeedDoesNotExist - return settings.BASE_URL + 'rss/area/' + str(self.upper_left_lat) + ',' + str(self.upper_left_lon) + ',' + str(self.lower_right_lat) + ',' + str(self.lower_right_lon) + return settings.BASE_URL + 'rss/area/' \ + + str(self.upper_left_lat) + ',' + str(self.upper_left_lon) + \ + ',' + str(self.lower_right_lat) + ',' + str(self.lower_right_lon) def description(self, obj): return "" - + # Link of the item/POI. Here the link is the permalink of the marker/POI def item_link(self, item): # Return the permalink of the POI : # Get thirst the attribute point of the marker # Then we had to transform this to the good system metric. From srid=4326 to srid=900913 coord = item.point - coord.transform(settings.EPSG_PROJECTION) - return settings.BASE_URL + '?zoom=16&lat=' + str(coord.y) + '&lon=' + str(coord.x) + '&layers=BTT&checked_categories=1&display_submited=false' + #coord.transform(settings.EPSG_PROJECTION) + return settings.BASE_URL + '?zoom=16&lat=' + str(coord.y) + '&lon=' + \ +str(coord.x) + '&layers=BTT&checked_categories=1&display_submited=false' + # Return the date of the Marker def item_pubdate(self,item): - return item.avail_date + return item.available_date + # Request to return Markers WHERE there points are containes in the zone which is requested. # This returns a list of the 15 last markers/POIs ordering by date def items(self, obj): - return Marker.objects.filter(point__contained=obj, status__exact='A').order_by('-avail_date')[:15] + return Marker.objects.filter(point__contained=obj, status__exact='A' + ).order_by('-available_date')[:15] class LatestPOIsByZoneID(Feed): ''' @@ -204,15 +218,14 @@ class LatestPOIsByZoneID(Feed): ''' title_template = "rss_title.html" description_template = "rss_descr.html" - + def get_object(self, bits): if len(bits) != 1: raise ObjectDoesNotExist - return Area.objects.get(id__exact=bits[0]) def title(self, obj): - return "Chimere - Last POIs of %s" % obj.name + return u"%s - Last POIs of %s" % (settings.PROJECT_NAME, obj.name) def link(self, obj): if not obj: @@ -225,29 +238,28 @@ class LatestPOIsByZoneID(Feed): def item_link(self, item): coord = item.point coord.transform(settings.EPSG_PROJECTION) - return settings.BASE_URL + '?zoom=16&lat=' + str(coord.y) + '&lon=' + str(coord.x) + '&layers=BTT&checked_categories=1&display_submited=false' + return settings.BASE_URL + '?zoom=16&lat=' + str(coord.y) + '&lon=' + \ +str(coord.x) + '&layers=BTT&checked_categories=1&display_submited=false' def item_pubdate(self,item): - return item.avail_date + return item.available_date def items(self, obj): upper_left_lat = float(obj.upper_left_corner.x) upper_left_lon = float(obj.upper_left_corner.y) lower_right_lat = float(obj.lower_right_corner.x) lower_right_lon = float(obj.lower_right_corner.y) - + ''' upper_right_lat = upper_left_lat upper_right_lon = lower_right_lon lower_left_lat = lower_right_lat lower_left_lon = upper_left_lon - - areaBox = Polygon(((upper_left_lon, upper_left_lat), + ''' + areaBox = Polygon(((upper_left_lon, upper_left_lat), (upper_right_lon, upper_right_lat), (lower_right_lon, lower_right_lat), (lower_left_lon, lower_left_lat), (upper_left_lon, upper_left_lat)), srid=settings.EPSG_PROJECTION) - - areaBox.transform(settings.EPSG_DISPLAY_PROJECTION) - - return Marker.objects.filter(point__contained=areaBox) + #areaBox.transform(settings.EPSG_DISPLAY_PROJECTION) + return Marker.objects.filter(point__contained=areaBox) diff --git a/chimere/rss/views.py b/chimere/rss/views.py index 12269cd..dc42584 100644 --- a/chimere/rss/views.py +++ b/chimere/rss/views.py @@ -36,11 +36,11 @@ from chimere.main.actions import actions from chimere.main.models import Category, SubCategory, PropertyModel, Marker, \ Route, News, Area, Color -# Pierre CLARENC : 19/01/2010 : Add AreaWidget +# Pierre CLARENC : 19/01/2010 : Add AreaWidget from chimere.main.widgets import getMapJS, PointChooserWidget, \ RouteChooserWidget, URL_OSM_JS, URL_OSM_CSS, AreaWidget # Pierre CLARENC : 19/01/2010 : End -# Pierre CLARENC : 19/01/2010 : Add AreaAdminForm +# Pierre CLARENC : 19/01/2010 : Add AreaAdminForm from chimere.main.forms import MarkerForm, RouteForm, AreaForm, notifyStaff # Pierre CLARENC : 19/01/2010 : End @@ -50,96 +50,114 @@ def rss(request): ''' # If the form has been submited if request.method == "POST": - - # User has defined the kind of POI he is interested in : POI in a area (GET method is used for the link with RSS icon in the browser) + # User has defined the kind of POI he is interested in : POI in a area + # (GET method is used for the link with RSS icon in the browser) if 'rss_category' in request.POST: #User wants to follow all the new POI if request.POST['rss_category'] == 'global': feeds_link = '/' + settings.EXTRA_URL + 'rss/global/' return HttpResponseRedirect(feeds_link) # User wants to follow all the new POI by category or subcategory - elif request.POST['rss_category'] == 'poi': + elif request.POST['rss_category'] == 'poi': response_dct = {'actions':actions, 'action_selected':'rss', - 'media_path':settings.MEDIA_URL, - 'extra_url':settings.EXTRA_URL, - 'category_rss_feed':'category', - 'sub_categories':SubCategory.getAvailable(['M', 'B']) + 'media_path':settings.MEDIA_URL, + 'extra_url':settings.EXTRA_URL, + 'category_rss_feed':'category', + 'sub_categories':SubCategory.getAvailable(['M', 'B']) } return render_to_response('rss.html', response_dct) # User wants to follow all the new POI situated in a defined area - elif request.POST['rss_category'] == 'area': + elif request.POST['rss_category'] == 'area': # An unbound form - form = AreaForm() + form = AreaForm() response_dct = {'actions':actions, 'action_selected':'rss', 'media_path':settings.MEDIA_URL, 'extra_url':settings.EXTRA_URL, 'map_layer':settings.MAP_LAYER, 'extra_head':form.media, - 'form':form, - 'category_rss_feed':'area', + 'form':form, + 'category_rss_feed':'area', 'area_id':Area.getAvailable(), - 'area_widget':AreaWidget().render('area', None) + 'area_widget':AreaWidget().render('area', None) } return render_to_response('rss.html', response_dct) # Error when submitting the form else: + error = _("Error - Please choose a correct choice in the list") response_dct = {'actions':actions, 'action_selected':'rss', 'media_path':settings.MEDIA_URL, 'extra_url':settings.EXTRA_URL, - 'error_message':'Error - Please choose a correct choice in the list', + 'error_message':error, 'category_rss_feed':'category', - 'sub_categories':SubCategory.getAvailable(['M', 'B']) + 'sub_categories':SubCategory.getAvailable(['M', + 'B']) } return render_to_response('rss.html', response_dct) - # User has specified the category or subcategory he wants to follow => we redirect him towards the related rss feed - if 'subcategory' in request.POST and request.POST['subcategory'] != '': + # User has specified the category or subcategory he wants to follow => + # we redirect him towards the related rss feed + if 'subcategory' in request.POST and request.POST['subcategory'] != '': idCat = request.POST['subcategory'] if idCat.find("cat_") != -1 : - list_Cat = idCat.split('_') - feeds_link = '/' + settings.EXTRA_URL + 'rss/category/' + list_Cat[1] + list_Cat = idCat.split('_') + feeds_link = '/' + settings.EXTRA_URL + 'rss/category/' + feeds_link += list_Cat[1] return HttpResponseRedirect(feeds_link) else: - feeds_link = '/' + settings.EXTRA_URL + 'rss/subcategory/' + idCat - return HttpResponseRedirect(feeds_link) + feeds_link = '/' + settings.EXTRA_URL + 'rss/subcategory/' + \ + idCat + return HttpResponseRedirect(feeds_link) - # User has specified the ID of the area he wants to follow + # User has specified the ID of the area he wants to follow if 'id_area' in request.POST and request.POST['id_area'] != '': - feeds_link = '/' + settings.EXTRA_URL + 'rss/areaid/' + request.POST['id_area'] + feeds_link = '/' + settings.EXTRA_URL + 'rss/areaid/' \ + + request.POST['id_area'] return HttpResponseRedirect(feeds_link) - # User has specified the area he wants to follow => we redirect him towards the related rss feed (using upper left and lower right coordinates) - elif 'upper_left_lat' in request.POST and request.POST['upper_left_lat'] != '' and 'upper_left_lon' in request.POST and request.POST['upper_left_lon'] != '' and 'lower_right_lon' in request.POST and request.POST['lower_right_lon'] != '' and 'lower_right_lat' in request.POST and request.POST['lower_right_lat'] != '' : - feeds_link = '/' + settings.EXTRA_URL + 'rss/area/' + request.POST['upper_left_lat'] + ',' + request.POST['upper_left_lon'] + ',' + request.POST['lower_right_lat'] + ',' + request.POST['lower_right_lon'] + # User has specified the area he wants to follow => we redirect him + # towards the related rss feed (using upper left and lower right + # coordinates) + elif 'upper_left_lat' in request.POST and \ + request.POST['upper_left_lat'] != '' and \ + 'upper_left_lon' in request.POST and \ + request.POST['upper_left_lon'] != '' and \ + 'lower_right_lon' in request.POST and \ + request.POST['lower_right_lon'] != '' and \ + 'lower_right_lat' in request.POST and \ + request.POST['lower_right_lat'] != '' : + feeds_link = '/' + settings.EXTRA_URL + 'rss/area/' + \ +request.POST['upper_left_lat'] + ',' + request.POST['upper_left_lon'] + ',' + \ +request.POST['lower_right_lat'] + ',' + request.POST['lower_right_lon'] return HttpResponseRedirect(feeds_link) - - # GET method is used for linking with the RSS icon in the browser when user wants to choose a category to follow + + # GET method is used for linking with the RSS icon in the browser when user + # wants to choose a category to follow elif request.method == "GET" and 'rss_category' in request.GET: if request.GET['rss_category'] == 'global': feeds_link = '/' + settings.EXTRA_URL + 'rss/global/' return HttpResponseRedirect(feeds_link) if request.GET['rss_category'] == 'poi': response_dct = {'actions':actions, 'action_selected':'rss', - 'media_path':settings.MEDIA_URL, - 'extra_url':settings.EXTRA_URL, - 'category_rss_feed':'category', - 'sub_categories':SubCategory.getAvailable(['M', 'B']) + 'media_path':settings.MEDIA_URL, + 'extra_url':settings.EXTRA_URL, + 'category_rss_feed':'category', + 'sub_categories':SubCategory.getAvailable(['M', 'B']) } return render_to_response('rss.html', response_dct) if request.GET['rss_category'] == 'area': # An unbound form - form = AreaForm() + form = AreaForm() response_dct = {'actions':actions, 'action_selected':'rss', 'media_path':settings.MEDIA_URL, 'extra_url':settings.EXTRA_URL, 'map_layer':settings.MAP_LAYER, 'extra_head':form.media, - 'form':form, - 'category_rss_feed':'area', + 'form':form, + 'category_rss_feed':'area', 'area_id':Area.getAvailable(), - 'area_widget':AreaWidget().render('area', None) + 'area_widget':AreaWidget().render('area', None) } return render_to_response('rss.html', response_dct) diff --git a/chimere/settings.py.example b/chimere/settings.py.example index 54118a9..48785d5 100644 --- a/chimere/settings.py.example +++ b/chimere/settings.py.example @@ -128,12 +128,12 @@ MIDDLEWARE_CLASSES = ( ROOT_URLCONF = 'chimere.urls' -TEMPLATE_DIRS = ( +TEMPLATE_DIRS = [ # Put strings here, like "/home/html/django_templates" or "C:/www/django/templates". # Always use forward slashes, even on Windows. # Don't forget to use absolute paths, not relative paths. ROOT_PATH + 'templates', -) +] INSTALLED_APPS = ( 'django.contrib.auth', @@ -147,3 +147,6 @@ INSTALLED_APPS = ( # activate it if you want to use RSS feeds 'chimere.rss' ) + +if 'chimere.rss' in INSTALLED_APPS: + TEMPLATE_DIRS.append(ROOT_PATH + 'rss/templates') -- cgit v1.2.3