diff options
| author | etienne <etienne@9215b0d5-fb2c-4bbd-8d3e-bd2e9090e864> | 2008-11-23 22:37:53 +0000 |
|---|---|---|
| committer | etienne <etienne@9215b0d5-fb2c-4bbd-8d3e-bd2e9090e864> | 2008-11-23 22:37:53 +0000 |
| commit | 4f3c2faf2844c23167c6b79cc6536b7257356d7b (patch) | |
| tree | 91787bb07bbd3a978430502e97adae7c9fb1bad4 | |
| parent | 6f97020d6b56f19d37a0941b299e68b2e8837d68 (diff) | |
| download | Chimère-4f3c2faf2844c23167c6b79cc6536b7257356d7b.tar.bz2 Chimère-4f3c2faf2844c23167c6b79cc6536b7257356d7b.zip | |
Displaying details differently. Adding a news system.
git-svn-id: http://www.peacefrogs.net/svn/chimere/trunk@3 9215b0d5-fb2c-4bbd-8d3e-bd2e9090e864
| -rw-r--r-- | locale/fr/LC_MESSAGES/django.po | 72 | ||||
| -rw-r--r-- | locale/fr/LC_MESSAGES/djangojs.po | 21 | ||||
| -rw-r--r-- | main/admin.py | 11 | ||||
| -rw-r--r-- | main/models.py | 15 | ||||
| -rw-r--r-- | main/views.py | 18 | ||||
| -rw-r--r-- | static/main_map.js | 18 | ||||
| -rw-r--r-- | static/styles.css | 51 | ||||
| -rw-r--r-- | templates/base.html | 2 | ||||
| -rw-r--r-- | templates/detail.html | 9 | ||||
| -rw-r--r-- | templates/main_map.html | 6 | ||||
| -rw-r--r-- | urls.py | 32 |
11 files changed, 179 insertions, 76 deletions
diff --git a/locale/fr/LC_MESSAGES/django.po b/locale/fr/LC_MESSAGES/django.po index f9a779e..bac2183 100644 --- a/locale/fr/LC_MESSAGES/django.po +++ b/locale/fr/LC_MESSAGES/django.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2008-10-06 20:39+0200\n" +"POT-Creation-Date: 2008-11-23 16:08+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" "Language-Team: LANGUAGE <LL@li.org>\n" @@ -24,120 +24,124 @@ msgstr "Voir" msgid "Add" msgstr "Ajouter" -#: main/models.py:16 main/models.py:28 main/models.py:39 main/models.py:66 -#: main/models.py:120 +#: main/models.py:17 main/models.py:29 main/models.py:41 main/models.py:68 +#: main/models.py:138 msgid "Name" msgstr "Nom" -#: main/models.py:17 main/models.py:40 main/models.py:71 main/models.py:122 +#: main/models.py:18 main/models.py:42 main/models.py:74 main/models.py:140 msgid "Available" msgstr "Disponible" -#: main/models.py:18 main/models.py:42 main/models.py:121 +#: main/models.py:19 main/models.py:44 main/models.py:139 msgid "Order" msgstr "Ordre" -#: main/models.py:23 main/models.py:38 templates/edit.html:24 +#: main/models.py:24 main/models.py:40 templates/edit.html:18 msgid "Category" msgstr "Catégorie" -#: main/models.py:29 main/models.py:69 templates/edit.html:43 +#: main/models.py:30 main/models.py:71 templates/edit.html:37 msgid "Image" msgstr "Image" -#: main/models.py:33 main/models.py:41 +#: main/models.py:35 main/models.py:43 msgid "Icon" msgstr "Icone" -#: main/models.py:47 main/models.py:67 +#: main/models.py:49 main/models.py:69 msgid "Subcategory" msgstr "Sous-catégorie" -#: main/models.py:68 +#: main/models.py:70 msgid "Localisation" msgstr "Localisation" -#: main/models.py:70 +#: main/models.py:73 msgid "Submited" msgstr "Soumis" -#: main/models.py:72 +#: main/models.py:75 msgid "Disabled" msgstr "Désactivé" -#: main/models.py:76 +#: main/models.py:79 msgid "Status" msgstr "État" -#: main/models.py:84 main/models.py:144 +#: main/models.py:87 main/models.py:162 msgid "Point of interest" msgstr "Point d'intérêt" -#: main/models.py:123 +#: main/models.py:141 msgid "Text" msgstr "Texte" -#: main/models.py:124 +#: main/models.py:142 msgid "Long text" msgstr "Texte long" -#: main/models.py:125 +#: main/models.py:143 msgid "Password" msgstr "Mot de passe" -#: main/models.py:129 +#: main/models.py:147 msgid "Type" msgstr "Type" -#: main/models.py:134 main/models.py:146 +#: main/models.py:152 main/models.py:164 msgid "Property model" msgstr "Modèle de propriété" -#: main/models.py:147 +#: main/models.py:165 msgid "Value" msgstr "Valeur" -#: main/models.py:151 +#: main/models.py:169 msgid "Property" msgstr "Propriété" -#: main/widgets.py:71 +#: main/widgets.py:76 msgid "Latitude" msgstr "Latitude" -#: main/widgets.py:71 +#: main/widgets.py:76 msgid "Longitude" msgstr "Longitude" -#: templates/edit.html:15 templates/submited.html:7 +#: templates/base.html:28 +msgid "This site uses Chimère" +msgstr "Ce site utilise Chimère" + +#: templates/detail.html:10 +msgid "Close" +msgstr "Fermer" + +#: templates/edit.html:9 templates/submited.html:5 msgid "Add a new site" msgstr "Ajouter un nouveau site" -#: templates/edit.html:16 +#: templates/edit.html:10 msgid "indicates a mandatory field" msgstr "indique un champs obligatoire" -#: templates/edit.html:19 +#: templates/edit.html:13 msgid "Site name" msgstr "Nom du site" -#: templates/edit.html:38 +#: templates/edit.html:32 msgid "Point" msgstr "Point" -#: templates/edit.html:39 +#: templates/edit.html:33 msgid "Select a location for this new site" msgstr "Choisissez une localisation pour ce nouveau site" -#: templates/edit.html:54 +#: templates/edit.html:48 msgid "Propose" msgstr "Proposez" -#: templates/main_map.html:19 -msgid "Detail" -msgstr "Détail" - -#: templates/submited.html:8 +#: templates/submited.html:6 msgid "" "Your proposition has been submited. A moderator will treat your submission " "shortly. Thanks!" diff --git a/locale/fr/LC_MESSAGES/djangojs.po b/locale/fr/LC_MESSAGES/djangojs.po new file mode 100644 index 0000000..84823e0 --- /dev/null +++ b/locale/fr/LC_MESSAGES/djangojs.po @@ -0,0 +1,21 @@ +# SOME DESCRIPTIVE TITLE. +# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER +# This file is distributed under the same license as the PACKAGE package. +# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR. +# +#, fuzzy +msgid "" +msgstr "" +"Project-Id-Version: PACKAGE VERSION\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2008-11-23 15:35+0100\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" +"Language-Team: LANGUAGE <LL@li.org>\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" + +#: static/main_map.js:104 +msgid "Show details" +msgstr "Voir le détail" diff --git a/main/admin.py b/main/admin.py index 0ec485f..2bfa390 100644 --- a/main/admin.py +++ b/main/admin.py @@ -5,8 +5,7 @@ Settings for administration pages """ from chimere.main.models import Category, Icon, SubCategory, Marker, \ - PropertyModel, Property -from chimere.main.widgets import PointChooserWidget + PropertyModel, Property, News from chimere.main.forms import MarkerAdminForm from django.contrib import admin @@ -19,14 +18,8 @@ class MarkerAdmin(admin.ModelAdmin): list_filter = ('status', 'subcategory') form = MarkerAdminForm - """ - def formfield_for_dbfield(self, db_field, **kwargs): - if db_field.name == 'point': - kwargs['widget'] = PointChooserWidget - return super(MarkerAdmin, self).formfield_for_dbfield(db_field, - **kwargs) -""" # register of differents database fields +admin.site.register(News) admin.site.register(Category) admin.site.register(Icon) admin.site.register(SubCategory) diff --git a/main/models.py b/main/models.py index d4ba9be..61ae576 100644 --- a/main/models.py +++ b/main/models.py @@ -11,6 +11,20 @@ from django.contrib import admin from chimere import settings from chimere.main.widgets import PointField + +class News(models.Model): + """News of the site + """ + title = models.CharField(_("Name"), max_length=150) + available = models.BooleanField(_("Available")) + date = models.DateField(_("Date"), auto_now_add=True) + content = models.TextField() + def __unicode__(self): + ordering = ["-date"] + return self.title + class Meta: + verbose_name = _("News") + class Category(models.Model): """Category of Point Of Interest (POI) """ @@ -122,7 +136,6 @@ class Marker(models.Model): def getGeoJSON(self): '''Return a GeoJSON string ''' - print self.subcategory.icon.image return """{"type":"Feature", "geometry":{"type":"Point", \ "crs": "EPSG:%(epsg)d", "coordinates":[%(longitude)s, %(latitude)s]}, \ "properties":{"pk": %(id)d, "name": "%(name)s", \ diff --git a/main/views.py b/main/views.py index c0503ad..2a1bc14 100644 --- a/main/views.py +++ b/main/views.py @@ -7,12 +7,13 @@ 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 SubCategory, PropertyModel, Marker +from chimere.main.models import SubCategory, PropertyModel, Marker, News from chimere.main.widgets import getMapJS, PointChooserWidget, URL_OSM_JS from chimere.main.forms import MarkerForm @@ -28,11 +29,18 @@ def index(request): extra_js = "" for url in URL_OSM_JS + ["%smain_map.js" % settings.MEDIA_URL]: extra_js += '<script src="%s"></script>\n' % url + extra_js += '<script src="/chimere/jsi18n/"></script>\n' + # show the presentation page + detail_content = '' + if not 'visited' in request.session: + request.session['visited'] = '1' + detail_content = welcome(request) response_dct = {'actions':actions, 'action_selected':'view', 'error_message':'', 'sub_categories':subcategories, 'extra_head':extra_js + getMapJS(), 'media_path':settings.MEDIA_URL, + 'detail_content':detail_content, } return render_to_response('main_map.html', response_dct) @@ -69,6 +77,14 @@ def edit(request): response_dct['current_category'] = int(form.data['subcategory']) return render_to_response('edit.html', response_dct) +def welcome(request): + """ + Welcome string + """ + response_dct = {} + response_dct['news_lst'] = News.objects.filter(available=True) + return loader.render_to_string('welcome.html', response_dct) + def submited(request): """ Successful submission page diff --git a/static/main_map.js b/static/main_map.js index 1d5d845..0bcf972 100644 --- a/static/main_map.js +++ b/static/main_map.js @@ -97,10 +97,14 @@ function putMarker(mark) { /*feature.closeBox = false;*/ feature.pk = mark.properties.pk; feature.popupClass = OpenLayers.Class(OpenLayers.Popup.FramedCloud); - feature.data.popupContentHTML = "<div class='cloud'>" + mark.properties.name + "<br/> </div>"; + feature.data.popupContentHTML = "<div class='cloud'>"; + feature.data.popupContentHTML += mark.properties.name; + feature.data.popupContentHTML += "<br/><div id='popup_link'>\ +<a href='javascript:showDetail()'>"; + feature.data.popupContentHTML += gettext("Show details"); + feature.data.popupContentHTML += "</a></div></div>"; feature.data.overflow = 'hidden'; var marker = feature.createMarker(); - /* manage markers events */ var markerClick = function (evt) { currentFeature = this; @@ -145,13 +149,19 @@ function updateDetail(pk){ /* update the detail panel from an http response */ function setDetail(response){ if (response.responseText.indexOf('no results') == -1) { - document.getElementById('detail_content').innerHTML = response.responseText; + document.getElementById('detail').innerHTML = response.responseText; } } + +/* show the detail windows */ +function showDetail(){ + document.getElementById('detail').style.display = 'block'; +} + /* hide content of detail panel */ function hideDetail(){ - document.getElementById('detail_content').innerHTML = ''; + document.getElementById('detail').style.display = 'None'; } /* main initialisation function */ diff --git a/static/styles.css b/static/styles.css index a70c702..353fcbe 100644 --- a/static/styles.css +++ b/static/styles.css @@ -16,6 +16,10 @@ font-weight:bold; color:purple; } +a{ +color:purple; +} + h2{ font-size:16px; text-align:center; @@ -30,6 +34,10 @@ border:solid 1px purple; border-radius: 4px; } +h3{ +color:purple; +} + hr.spacer{ clear:both; border:None; @@ -68,6 +76,16 @@ text-decoration:None; color:black; } +#footer{ +position:absolute; +z-index:5; +background-color:white; +bottom:5px; +right:5px; +border:1px solid black; +padding:2px; +} + #panel{ padding:6px 10px; border: 1px solid black; @@ -85,17 +103,22 @@ opacity:0.8; border-radius:10px; } +#popup_link{ +text-align:center; +} + #detail{ +display:None; padding:6px 10px; border: 1px solid black; position:absolute; z-index:5; -top:274px; -bottom:18px; -right:18px; -width:250px; +top:50px; +bottom:58px; +left:80px; +right:310px; background-color:#FFF; -opacity:0.8; +opacity:0.9; -moz-border-radius:10px; -webkit-border-radius:10px; border-radius:10px; @@ -106,6 +129,10 @@ overflow:auto; height:90%; } +#detail_footer{ +text-align:center; +} + #map{ border: 1px solid black; position:absolute; @@ -115,6 +142,20 @@ left:8px; right:8px; } +.news{ +} + +.news h3{ +padding:0px; +margin:0; +} + +.info{ +border-top:1px dashed; +padding:10px; +margin:0; +} + ul#categories{ margin:0; padding:0; diff --git a/templates/base.html b/templates/base.html index 3f4e0ac..191d95d 100644 --- a/templates/base.html +++ b/templates/base.html @@ -1,3 +1,4 @@ +{% load i18n %} <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> @@ -24,6 +25,7 @@ <div id="content"> {% block content %}{% endblock %} </div> + <div id='footer'>{% trans "This site uses Chimère"%} - Copyright © 2008 <a href='http://redmine.peacefrogs.net/projects/show/chimere'>Chimère project</a></div> </body> </html> diff --git a/templates/detail.html b/templates/detail.html index 465d775..f8ef21d 100644 --- a/templates/detail.html +++ b/templates/detail.html @@ -1,7 +1,10 @@ {% load i18n %} -<h3>{{marker.name}}</h3> -<div>{%trans marker.subcategory.name%}</div> +<h2>{{ marker.name }}</h2> +<div id='detail_content'> +{%trans marker.subcategory.name%} {% if marker.picture %}<img src='{{media_path}}{{marker.picture}}' alt='{{marker.name}}'/>{%endif%} <div>{% for property in marker.getProperties %} <p id='{{property.propertymodel.getNamedId}}'>{{ property.value }}</p> -{% endfor %}</div>
\ No newline at end of file +{% endfor %}</div> +</div> +<div id='detail_footer'><a href='javascript:hideDetail();'>{% trans "Close" %}</a></div>
\ No newline at end of file diff --git a/templates/main_map.html b/templates/main_map.html index 3f43131..df422ee 100644 --- a/templates/main_map.html +++ b/templates/main_map.html @@ -12,10 +12,8 @@ </ul> </form> </div> -<div id='detail'> -<h2>{% trans "Detail" %}</h2> -<div id='detail_content'> -</div> +<div id='detail'{% if detail_content%} style="display:block;"{% endif %}> +{{ detail_content }} </div>{% endblock %} {% block content %}<div id='map'></div> <script type='text/javascript'><!-- @@ -5,20 +5,22 @@ admin.autodiscover() from settings import ROOT_PATH -urlpatterns = patterns('', - # Example: - # (r'^chimere/', include('chimere.foo.urls')), - (r'^chimere/admin/(.*)', admin.site.root), - (r'^chimere/$', 'chimere.main.views.index'), - (r'^chimere/edit/$', 'chimere.main.views.edit'), - (r'^chimere/submited/$', 'chimere.main.views.submited'), - (r'^chimere/getDetail/(?P<marker_id>\d+)/$', - 'chimere.main.views.getDetail'), - (r'^chimere/getMarkers/(?P<category_ids>\w+)/$', - 'chimere.main.views.getMarkers'), - (r'^chimere/static/(?P<path>.*)$', 'django.views.static.serve', - {'document_root': ROOT_PATH + 'static/'}), - (r'^chimere/media/(?P<path>.*)$', 'django.views.static.serve', - {'document_root': ROOT_PATH + 'media/'}), +js_info_dict = { + 'packages': 'chimere', +} +urlpatterns = patterns('', + (r'^chimere/admin/(.*)', admin.site.root), + (r'^chimere/$', 'chimere.main.views.index'), + (r'^chimere/edit/$', 'chimere.main.views.edit'), + (r'^chimere/submited/$', 'chimere.main.views.submited'), + (r'^chimere/getDetail/(?P<marker_id>\d+)/$', + 'chimere.main.views.getDetail'), + (r'^chimere/getMarkers/(?P<category_ids>\w+)/$', + 'chimere.main.views.getMarkers'), + (r'^chimere/static/(?P<path>.*)$', 'django.views.static.serve', + {'document_root': ROOT_PATH + 'static/'}), + (r'^chimere/media/(?P<path>.*)$', 'django.views.static.serve', + {'document_root': ROOT_PATH + 'media/'}), + (r'^chimere/jsi18n/$', 'django.views.i18n.javascript_catalog', js_info_dict), ) |
