several changes required to make MapOSMatic work with Django 1.7.x

nimn-master
Hartmut Holzgraefe 2016-04-03 21:26:12 +02:00
rodzic 8d7b33f7c0
commit e860982d19
12 zmienionych plików z 26 dodań i 58 usunięć

Wyświetl plik

@ -32,6 +32,9 @@ import render
from www.maposmatic.models import MapRenderingJob
from www.settings import RENDERING_RESULT_PATH, RENDERING_RESULT_MAX_SIZE_GB
import django
django.setup()
_DEFAULT_CLEAN_FREQUENCY = 20 # Clean thread polling frequency, in
# seconds.
_DEFAULT_POLL_FREQUENCY = 10 # Daemon job polling frequency, in seconds

Wyświetl plik

@ -1,34 +0,0 @@
#!/usr/bin/python
# coding: utf-8
# maposmatic, the web front-end of the MapOSMatic city map generation system
# Copyright (C) 2009 David Decotigny
# Copyright (C) 2009 Frédéric Lehobey
# Copyright (C) 2009 David Mentré
# Copyright (C) 2009 Maxime Petazzoni
# Copyright (C) 2009 Thomas Petazzoni
# Copyright (C) 2009 Gaël Utard
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or 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 Affero General Public License for more details.
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
from django.core.management import execute_manager
try:
import settings # Assumed to be in the same directory.
except ImportError:
import sys
sys.stderr.write("Error: Can't find the file 'settings.py' in the directory containing %r. It appears you've customized things.\nYou'll have to run django-admin.py, passing it your settings module.\n(If the file settings.py does indeed exist, it's causing an ImportError somehow.)\n" % __file__)
sys.exit(1)
if __name__ == "__main__":
execute_manager(settings)

Wyświetl plik

@ -30,6 +30,5 @@ os.environ["DJANGO_SETTINGS_MODULE"] = 'www.settings'
os.environ["MAPOSMATIC_LOG_FILE"] = "/tmp/maposmatic-www.log"
os.environ["PGCONNECT_TIMEOUT"] = 1
import django.core.handlers.wsgi
application = django.core.handlers.wsgi.WSGIHandler()
from django.core.wsgi import get_wsgi_application
application = get_wsgi_application()

Wyświetl plik

@ -247,14 +247,14 @@ def api_nominatim(request):
contents = []
return HttpResponse(content=json_encode(contents),
mimetype='text/json')
content_type='text/json')
def api_nominatim_reverse(request, lat, lon):
"""Nominatim reverse geocoding query gateway."""
lat = float(lat)
lon = float(lon)
return HttpResponse(json_encode(nominatim.reverse_geo(lat, lon)),
mimetype='text/json')
content_type='text/json')
def api_papersize(request):
"""API handler to get the compatible paper sizes for the provided layout
@ -301,7 +301,7 @@ def api_papersize(request):
key = lambda p: p[1])
return HttpResponse(content=json_encode(paper_sizes),
mimetype='text/json')
content_type='text/json')
def api_bbox(request, osm_id):
@ -317,7 +317,7 @@ def api_bbox(request, osm_id):
bbox_wkt, area_wkt = renderer.get_geographic_info(osm_id)
bbox = ocitysmap.coords.BoundingBox.parse_wkt(bbox_wkt)
return HttpResponse(content=json_encode(bbox.as_json_bounds()),
mimetype='text/json')
content_type='text/json')
except:
LOG.exception("Error calculating bounding box for OSM ID %d!" % osm_id)

Wyświetl plik

@ -66,11 +66,11 @@
<div class="nav-collapse collapse">
<ul class="nav">
<li class="{% block menu-home %}{% endblock %}"><a href="{% url main %}"><i class="icon-white icon-home"></i> {% trans "Home" %}</a></li>
<li class="{% block menu-new %}{% endblock %}"><a href="{% url new %}"><i class="icon-white icon-edit"></i> {% trans "Create map" %}</a></li>
<li class="{% block menu-maps %}{% endblock %}"><a href="{% url maps %}"><i class="icon-white icon-list"></i> {% trans "Maps" %}</a></li>
<li class="{% block menu-about %}{% endblock %}"><a href="{% url about %}"><i class="icon-white icon-comment"></i> {% trans "About" %}</a></li>
<li class="{% block menu-donate %}{% endblock %}"><a href="{% url donate %}"><i class="icon-white icon-gift"></i> {% trans "Donate" %}</a></li>
<li class="{% block menu-home %}{% endblock %}"><a href="{% url "main" %}"><i class="icon-white icon-home"></i> {% trans "Home" %}</a></li>
<li class="{% block menu-new %}{% endblock %}"><a href="{% url "new" %}"><i class="icon-white icon-edit"></i> {% trans "Create map" %}</a></li>
<li class="{% block menu-maps %}{% endblock %}"><a href="{% url "maps" %}"><i class="icon-white icon-list"></i> {% trans "Maps" %}</a></li>
<li class="{% block menu-about %}{% endblock %}"><a href="{% url "about" %}"><i class="icon-white icon-comment"></i> {% trans "About" %}</a></li>
<li class="{% block menu-donate %}{% endblock %}"><a href="{% url "donate" %}"><i class="icon-white icon-gift"></i> {% trans "Donate" %}</a></li>
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown">
@ -88,7 +88,7 @@
</ul>
</li>
<form action="{% url maps %}" method="get" class="navbar-form form-horizontal pull-right">
<form action="{% url "maps" %}" method="get" class="navbar-form form-horizontal pull-right">
<div class="control-group">
<div class="controls">
<div class="input-prepend">

Wyświetl plik

@ -36,7 +36,7 @@
<h1>{% trans "Donate" %}</h1>
<h2>{% trans "Why are donations useful?" %}</h2>
{% url about as about_url %}
{% url "about" as about_url %}
<p>
{% blocktrans %}MapOSMatic is a project entirely developed and maintained by a

Wyświetl plik

@ -46,8 +46,8 @@
</p>
<p class="actions">
<a class="btn btn-large pull-right" href="{% url about %}">{% blocktrans %}Learn more{% endblocktrans %}</a>
<a class="btn btn-large btn-primary" href="{% url new %}">{% blocktrans %}Create a map &raquo;{% endblocktrans %}</a>
<a class="btn btn-large pull-right" href="{% url "about" %}">{% blocktrans %}Learn more{% endblocktrans %}</a>
<a class="btn btn-large btn-primary" href="{% url "new" %}">{% blocktrans %}Create a map &raquo;{% endblocktrans %}</a>
</p>
</div>

Wyświetl plik

@ -97,7 +97,7 @@
</a>
{% ifequal nonce map.nonce %}
<form method="post" action="{% url cancel %}" class="pull-right">
<form method="post" action="{% url "cancel" %}" class="pull-right">
<input type="hidden" name="id" value="{{ map.id }}" />
<input type="hidden" name="nonce" value="{{ map.nonce }}" />
<button type="submit" class="btn btn-large btn-danger tooltipped"

Wyświetl plik

@ -45,7 +45,7 @@
{% if map.needs_waiting and map.current_position_in_queue %}
<p class="queue-position">#{{ map.current_position_in_queue }}</p>
{% endif %}
<h2><a href="{% url map-by-id map.id %}">{{ map.maptitle }}</a></h2>
<h2><a href="{% url "map-by-id" map.id %}">{{ map.maptitle }}</a></h2>
<p class="details">
{% if map.administrative_city %}
@ -127,7 +127,7 @@
</a>
{% endif %}
<form class="form-horizontal pull-right" method="post" action="{% url recreate %}">
<form class="form-horizontal pull-right" method="post" action="{% url "recreate" %}">
<input type="hidden" name="id" value="{{ map.id }}" />
<button class="btn tooltipped"
data-original-title="{% trans "Recreate map" %}"
@ -159,7 +159,7 @@
{% ifequal form.cleaned_data.query "" %}
{% blocktrans %}Our database does not contain any rendered maps for the moment.{% endblocktrans %}
{% else %}
{% blocktrans %}No map matches your query.{% endblocktrans %} <a href="{% url new %}">{% trans "Create a new map!" %}</a>
{% blocktrans %}No map matches your query.{% endblocktrans %} <a href="{% url "new" %}">{% trans "Create a new map!" %}</a>
{% endifequal %}
</p>
{% endfor %}

Wyświetl plik

@ -42,7 +42,7 @@
<div class="row-fluid" style="margin-top: 30px;">
<div class="span12">
<form id="mainfrm" method="post" action="{% url new %}#submitmapform">
<form id="mainfrm" method="post" action="{% url "new" %}#submitmapform">
<div id="wizard" class="carousel slide">
<div class="carousel-inner">

Wyświetl plik

@ -31,13 +31,13 @@
<div class="pagination pull-right">
<ul>
<li class="{% if not data.has_previous %}disabled{% endif %}">
<a href="?{% if is_search %}query={{ query|urlencode }}&{% endif %}page={{ data.previous_page_number }}">&laquo;</a>
<a href={% if data.has_previous %}"?{% if is_search %}query={{ query|urlencode }}&{% endif %}page={{ data.previous_page_number }}"{% else %}"#"{% endif %}>&laquo;</a>
</li>
{% for num in pages %}<li class="{% ifequal num data.number %}active{% endifequal %} {% ifequal num "..." %}disabled{% endifequal %}">
{% ifequal num "..." %}<a>{{ num }}</a>{% else %}<a href="?{% if is_search %}query={{ query|urlencode }}&{% endif %}page={{ num }}">{{ num }}</a>{% endifequal %}
</li>{% endfor %}
<li class="{% if not data.has_next %}disabled{% endif %}">
<a href="?{% if is_search %}query={{ query|urlencode }}&{% endif %}page={{ data.next_page_number }}">&raquo;</a>
<a href={% if data.has_next %}"?{% if is_search %}query={{ query|urlencode }}&{% endif %}page={{ data.next_page_number }}"{% else %}"#"{% endif %}>&raquo;</a>
</li>
</ul>
</div>

Wyświetl plik

@ -23,7 +23,7 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
import django
from django.conf.urls.defaults import *
from django.conf.urls import patterns, url, include
# Uncomment the next two lines to enable the admin:
# from django.contrib import admin