kopia lustrzana https://github.com/hholzgra/maposmatic/
First import of maposmatic web service
commit
7c28357369
|
@ -0,0 +1,11 @@
|
|||
#!/usr/bin/python
|
||||
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)
|
|
@ -0,0 +1,24 @@
|
|||
from django.db import models
|
||||
|
||||
class MapRenderingJob(models.Model):
|
||||
|
||||
STATUS_LIST = (
|
||||
(0, 'Submitted'),
|
||||
(1, 'In progress'),
|
||||
(2, 'Done'),
|
||||
)
|
||||
|
||||
maptitle = models.CharField(max_length=256)
|
||||
administrative_city = models.CharField(max_length=256, blank=True, null=True)
|
||||
lat_upper_left = models.FloatField(blank=True, null=True)
|
||||
long_upper_left = models.FloatField(blank=True, null=True)
|
||||
lat_bottom_right = models.FloatField(blank=True, null=True)
|
||||
long_bottom_right = models.FloatField(blank=True, null=True)
|
||||
status = models.IntegerField(choices=STATUS_LIST)
|
||||
submission_time = models.DateTimeField(auto_now_add=True)
|
||||
startofrendering_time = models.DateTimeField(null=True)
|
||||
endofrendering_time = models.DateTimeField(null=True)
|
||||
resultmsg = models.CharField(max_length=256, null=True)
|
||||
submitterip = models.IPAddressField()
|
||||
index_queue_at_submission = models.IntegerField()
|
||||
|
|
@ -0,0 +1,47 @@
|
|||
# Create your views here.
|
||||
|
||||
from django.forms import ModelForm
|
||||
from django.shortcuts import get_object_or_404, render_to_response
|
||||
from django.http import HttpResponseRedirect
|
||||
from www.maposmatic.models import MapRenderingJob
|
||||
|
||||
class MapRenderingJobForm(ModelForm):
|
||||
class Meta:
|
||||
model = MapRenderingJob
|
||||
fields = ('maptitle', 'administrative_city', 'lat_upper_left', 'long_upper_left',
|
||||
'lat_bottom_right', 'long_bottom_right')
|
||||
|
||||
def index(request):
|
||||
if request.method == 'POST':
|
||||
print 'POST'
|
||||
form = MapRenderingJobForm(request.POST)
|
||||
if form.is_valid():
|
||||
print 'form_valid'
|
||||
job = MapRenderingJob()
|
||||
job.maptitle = form.cleaned_data['maptitle']
|
||||
job.administrative_city = form.cleaned_data['administrative_city']
|
||||
job.lat_upper_left = form.cleaned_data['lat_upper_left']
|
||||
job.long_upper_left = form.cleaned_data['long_upper_left']
|
||||
job.lat_bottom_right = form.cleaned_data['lat_bottom_right']
|
||||
job.long_bottom_right = form.cleaned_data['long_bottom_right']
|
||||
job.status = 0 # Submitted
|
||||
job.submitterip = request.META['REMOTE_ADDR']
|
||||
job.index_queue_at_submission = 0
|
||||
job.save()
|
||||
|
||||
return HttpResponseRedirect('/jobs/%d' % job.id)
|
||||
else:
|
||||
form = MapRenderingJobForm()
|
||||
return render_to_response('maposmatic/index.html',
|
||||
{ 'form' : form })
|
||||
|
||||
def job(request, job_id):
|
||||
job = get_object_or_404(MapRenderingJob, id=job_id)
|
||||
return render_to_response('maposmatic/job.html',
|
||||
{ 'job' : job })
|
||||
|
||||
def all_jobs(request):
|
||||
jobs = MapRenderingJob.objects.all()
|
||||
print jobs
|
||||
return render_to_response('maposmatic/all_jobs.html',
|
||||
{ 'jobs' : jobs })
|
|
@ -0,0 +1,69 @@
|
|||
html,body {
|
||||
margin:0;
|
||||
padding:0;
|
||||
}
|
||||
|
||||
body{font: 85%/1.3 sans-serif;
|
||||
text-align: left;background: #fff;padding-bottom:20px}
|
||||
a { color: #0066B3; background: inherit; text-decoration: none;}
|
||||
h1 { font: bold 2.1em Sans-Serif; color: #036DA7 }
|
||||
h2 { font: bold 1.1em Sans-Serif; padding: 0; margin: 0; }
|
||||
|
||||
div#header{width:100%;overflow:hidden;background: #BBD9EE; }
|
||||
div#header h1,div#menu{width:770px;margin:0 auto;text-align:left}
|
||||
div#header h1{padding: 30px 0 20px;color: #fff}
|
||||
|
||||
ul#nav,ul#nav li{list-style-type:none;margin:0;padding:0}
|
||||
ul#nav{float:right;font-size: 80%}
|
||||
ul#nav li{float:left;margin-left: 3px;text-align: center}
|
||||
ul#nav a{float:left;width: 95px;padding: 5px 0;background: #E7F1F8;text-decoration:none;color: #666; border-top : 1px solid #fff; border-left : 1px solid #fff; border-right : 1px solid #fff;}
|
||||
ul#nav a:hover{background: #fff;color: #000}
|
||||
ul#nav li.activelink a,ul#nav li.activelink a:hover{background: #FFF;color: #003}
|
||||
|
||||
#right {
|
||||
float: left;
|
||||
width: 76%;
|
||||
padding: 1em;
|
||||
margin-bottom: 1.2em;
|
||||
background: #eee;
|
||||
text-align: justify;
|
||||
}
|
||||
|
||||
#left {
|
||||
float: right;
|
||||
width: 20%;
|
||||
margin: 0 0 10px 0;
|
||||
}
|
||||
|
||||
#left .box {
|
||||
padding: 1em;
|
||||
margin: 0 0 1em 0;
|
||||
background : #FFF6BF;
|
||||
}
|
||||
|
||||
|
||||
#content {
|
||||
font: 95%/1.3 sans-serif;
|
||||
margin: 0 auto;
|
||||
padding: 15px;
|
||||
background: #fff;
|
||||
}
|
||||
|
||||
ul { padding: 0; margin: 0;}
|
||||
li { list-style-type: none;}
|
||||
|
||||
input {
|
||||
background: #FFF6BF;
|
||||
border: 3px solid #CCC;
|
||||
width: 300px;
|
||||
padding: 3px;
|
||||
}
|
||||
|
||||
input:hover {
|
||||
border: 3px solid #AAA;
|
||||
}
|
||||
|
||||
input[type="submit"]
|
||||
{
|
||||
width: auto;
|
||||
}
|
|
@ -0,0 +1,80 @@
|
|||
# Django settings for www project.
|
||||
|
||||
DEBUG = True
|
||||
TEMPLATE_DEBUG = DEBUG
|
||||
|
||||
ADMINS = (
|
||||
# ('Your Name', 'your_email@domain.com'),
|
||||
)
|
||||
|
||||
MANAGERS = ADMINS
|
||||
|
||||
DATABASE_ENGINE = 'postgresql_psycopg2' # 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'.
|
||||
DATABASE_NAME = 'testdb' # Or path to database file if using sqlite3.
|
||||
DATABASE_USER = 'test' # Not used with sqlite3.
|
||||
DATABASE_PASSWORD = 'test' # Not used with sqlite3.
|
||||
DATABASE_HOST = 'localhost' # Set to empty string for localhost. Not used with sqlite3.
|
||||
DATABASE_PORT = '' # Set to empty string for default. Not used with sqlite3.
|
||||
|
||||
# Local time zone for this installation. Choices can be found here:
|
||||
# http://en.wikipedia.org/wiki/List_of_tz_zones_by_name
|
||||
# although not all choices may be available on all operating systems.
|
||||
# If running in a Windows environment this must be set to the same as your
|
||||
# system time zone.
|
||||
TIME_ZONE = 'America/Chicago'
|
||||
|
||||
# Language code for this installation. All choices can be found here:
|
||||
# http://www.i18nguy.com/unicode/language-identifiers.html
|
||||
LANGUAGE_CODE = 'en-us'
|
||||
|
||||
SITE_ID = 1
|
||||
|
||||
# If you set this to False, Django will make some optimizations so as not
|
||||
# to load the internationalization machinery.
|
||||
USE_I18N = True
|
||||
|
||||
# Absolute path to the directory that holds media.
|
||||
# Example: "/home/media/media.lawrence.com/"
|
||||
MEDIA_ROOT = ''
|
||||
|
||||
# URL that handles the media served from MEDIA_ROOT. Make sure to use a
|
||||
# trailing slash if there is a path component (optional in other cases).
|
||||
# Examples: "http://media.lawrence.com", "http://example.com/media/"
|
||||
MEDIA_URL = ''
|
||||
|
||||
# URL prefix for admin media -- CSS, JavaScript and images. Make sure to use a
|
||||
# trailing slash.
|
||||
# Examples: "http://foo.com/media/", "/media/".
|
||||
ADMIN_MEDIA_PREFIX = '/media/'
|
||||
|
||||
# Make this unique, and don't share it with anybody.
|
||||
SECRET_KEY = 'tm+wb)lp5q%br=p0d2toz&km_-w)cmcelv!7inons&^v9(q!d2'
|
||||
|
||||
# List of callables that know how to import templates from various sources.
|
||||
TEMPLATE_LOADERS = (
|
||||
'django.template.loaders.filesystem.load_template_source',
|
||||
'django.template.loaders.app_directories.load_template_source',
|
||||
# 'django.template.loaders.eggs.load_template_source',
|
||||
)
|
||||
|
||||
MIDDLEWARE_CLASSES = (
|
||||
'django.middleware.common.CommonMiddleware',
|
||||
'django.contrib.sessions.middleware.SessionMiddleware',
|
||||
'django.contrib.auth.middleware.AuthenticationMiddleware',
|
||||
)
|
||||
|
||||
ROOT_URLCONF = 'www.urls'
|
||||
|
||||
import os.path
|
||||
|
||||
PROJECT_PATH = os.path.dirname(os.path.abspath(__file__))
|
||||
|
||||
TEMPLATE_DIRS = (
|
||||
os.path.join(PROJECT_PATH, 'templates'),
|
||||
)
|
||||
|
||||
LOCAL_MEDIA_PATH = os.path.join(PROJECT_PATH, 'media')
|
||||
|
||||
INSTALLED_APPS = (
|
||||
'www.maposmatic',
|
||||
)
|
|
@ -0,0 +1,28 @@
|
|||
{% extends "maposmatic/base.html" %}
|
||||
|
||||
{% block page %}
|
||||
|
||||
<p><b>Job list</b></p>
|
||||
|
||||
<table class="list">
|
||||
{% for job in jobs %}
|
||||
<tr class="{% cycle odd,even %}">
|
||||
<td>
|
||||
<a href="/jobs/{{ job.id }}">{{ job.maptitle }}</a><br/>
|
||||
</td>
|
||||
<td>
|
||||
{% ifequal job.status 0 %}
|
||||
Waiting rendering
|
||||
{% endifequal %}
|
||||
{% ifequal job.status 1 %}
|
||||
Rendering in progress...
|
||||
{% endifequal %}
|
||||
{% ifequal job.status 2 %}
|
||||
Rendering done or failed
|
||||
{% endifequal %}
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</table>
|
||||
|
||||
{% endblock %}
|
|
@ -0,0 +1,44 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
||||
|
||||
<head>
|
||||
<title>MapOSMatic</title>
|
||||
<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
|
||||
<meta http-equiv="Content-Language" content="fr-fr" />
|
||||
<link rel="stylesheet" type="text/css" href="/smedia/style.css" media="screen" />
|
||||
{% block extrahead %}{% endblock %}
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div id="header">
|
||||
<h1>MapOSMatic</h1>
|
||||
<div id="menu">
|
||||
<ul id="nav">
|
||||
<li><a href="#">Accueil</a></li>
|
||||
<li><a href="#">Cartes</a></li>
|
||||
<li><a href="#">À propos</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
<div id="content">
|
||||
<div id="right">
|
||||
{% block page %}{% endblock %}
|
||||
</div>
|
||||
|
||||
<div id="left">
|
||||
<div class="box">
|
||||
<h2>Liens :</h2>
|
||||
<ul>
|
||||
<li><a href="http://www.openstreetmap.org">OpenStreetMap</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<div class="box">
|
||||
<div style="font-size: 0.8em;">Design par <a href="http://www.minimalistic-design.net">Minimalistic Design</a></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,59 @@
|
|||
{% extends "maposmatic/base.html" %}
|
||||
|
||||
{% block extrahead %}
|
||||
<script language="JavaScript" type="text/javascript">
|
||||
function generation_mode_switch(mode)
|
||||
{
|
||||
if (mode == 'bbox-mode')
|
||||
{
|
||||
document.getElementById('admin-mode').style.display = 'none';
|
||||
document.getElementById('bbox-mode').style.display = '';
|
||||
}
|
||||
else if (mode == 'admin-mode')
|
||||
{
|
||||
document.getElementById('admin-mode').style.display = '';
|
||||
document.getElementById('bbox-mode').style.display = 'none';
|
||||
}
|
||||
}
|
||||
</script>
|
||||
{% endblock %}
|
||||
|
||||
{% block page %}
|
||||
<h1>MapOSMatic</h1>
|
||||
|
||||
<form method="post" action="">
|
||||
|
||||
<table>
|
||||
<tr>
|
||||
<td>Nom de la carte</td>
|
||||
<td>{{ form.maptitle }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Mode de génération</td>
|
||||
<td>
|
||||
<input type="radio" name="generation-mode" value="admin" checked="checked" onclick="generation_mode_switch('admin-mode');"/>Basé sur la limite administrative<br/>
|
||||
<input type="radio" name="generation-mode" value="bbox" onclick="generation_mode_switch('bbox-mode');"/>Basé sur une <i>bouding box</i>
|
||||
</td>
|
||||
</tr>
|
||||
<tr id="admin-mode">
|
||||
<td>Nom de la ville</td>
|
||||
<td>{{ form.administrative_city }}</td>
|
||||
</tr>
|
||||
<tr id="bbox-mode" style="display: none;">
|
||||
<td>Bounding box</td>
|
||||
<td style="text-align: center">
|
||||
<input type="text" id="id_lat_upper_left" style="width: 100px"/><br/>
|
||||
<input type="text" id="id_long_upper_left" style="width: 100px"/>
|
||||
<input type="text" id="id_long_bottom_right" style="width: 100px"/><br/>
|
||||
<input type="text" id="id_lat_bottom_right" style="width: 100px"/>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td><input type="submit" value="Générer"/></td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
</form>
|
||||
|
||||
{% endblock %}
|
|
@ -0,0 +1,8 @@
|
|||
{% extends "maposmatic/base.html" %}
|
||||
|
||||
{% block page %}
|
||||
<h1>MapOSMatic</h1>
|
||||
|
||||
{{ job.maptitle }}
|
||||
|
||||
{% endblock %}
|
|
@ -0,0 +1,17 @@
|
|||
from django.conf.urls.defaults import *
|
||||
|
||||
# Uncomment the next two lines to enable the admin:
|
||||
# from django.contrib import admin
|
||||
# admin.autodiscover()
|
||||
|
||||
import maposmatic.views
|
||||
import settings
|
||||
|
||||
urlpatterns = patterns('',
|
||||
(r'^$', maposmatic.views.index),
|
||||
(r'^smedia/(?P<path>.*)$',
|
||||
'django.views.static.serve',
|
||||
{'document_root': settings.LOCAL_MEDIA_PATH}),
|
||||
(r'^jobs/(?P<job_id>\d+)$', maposmatic.views.job),
|
||||
(r'^jobs/$', maposmatic.views.all_jobs),
|
||||
)
|
Ładowanie…
Reference in New Issue