kopia lustrzana https://github.com/hholzgra/maposmatic/
add indexer choice
rodzic
62c2a2dbb8
commit
43126ea003
|
@ -456,6 +456,9 @@ class JobRenderer(threading.Thread):
|
|||
self.job.lon_bottom_right)
|
||||
|
||||
config.language = self.job.map_language
|
||||
|
||||
config.indexer = self.job.indexer
|
||||
|
||||
config.stylesheet = renderer.get_stylesheet_by_name(
|
||||
self.job.stylesheet)
|
||||
config.overlays = []
|
||||
|
|
|
@ -55,7 +55,7 @@ class MapRenderingJobForm(forms.ModelForm):
|
|||
"""
|
||||
class Meta:
|
||||
model = models.MapRenderingJob
|
||||
fields = ('layout', 'stylesheet', 'overlay',
|
||||
fields = ('layout', 'indexer', 'stylesheet', 'overlay',
|
||||
'maptitle', 'administrative_city',
|
||||
'lat_upper_left', 'lon_upper_left',
|
||||
'lat_bottom_right', 'lon_bottom_right',
|
||||
|
@ -63,6 +63,7 @@ class MapRenderingJobForm(forms.ModelForm):
|
|||
|
||||
mode = forms.CharField(initial='bbox', widget=forms.HiddenInput)
|
||||
layout = forms.ChoiceField(choices=(), widget=forms.RadioSelect(attrs= { 'onchange' : 'clearPaperSize(this.value); $("#layout-preview").attr("src","/media/img/layout/"+this.value+".png");'}))
|
||||
indexer = forms.ChoiceField(choices=(), widget=forms.RadioSelect())
|
||||
stylesheet = forms.ChoiceField(choices=(), widget=forms.Select(attrs= { 'onchange' : '$("#style-preview").attr("src","/media/img/style/"+this.value+".jpg");'}))
|
||||
overlay = forms.MultipleChoiceField(choices=(), widget=forms.SelectMultiple(attrs= { 'class': 'multipleSelect' }), required=False)
|
||||
paper_width_mm = forms.IntegerField(widget=forms.NumberInput(attrs= {'onchange' : 'change_papersize();', 'style': 'width: 5em;'}), min_value=100, max_value=2000)
|
||||
|
@ -122,6 +123,14 @@ class MapRenderingJobForm(forms.ModelForm):
|
|||
if not self.fields['layout'].initial:
|
||||
self.fields['layout'].initial = layout_renderers[0].name
|
||||
|
||||
self.fields['indexer'].choices = [
|
||||
('Street', 'Streets and selected amenities'),
|
||||
('Health', 'Health related facilities'),
|
||||
]
|
||||
|
||||
if not self.fields['indexer'].initial:
|
||||
self.fields['indexer'].initial = 'Street' # TODO: make configurable
|
||||
|
||||
style_choices = {"": []}
|
||||
for s in stylesheets:
|
||||
if s.description is not None:
|
||||
|
@ -136,7 +145,7 @@ class MapRenderingJobForm(forms.ModelForm):
|
|||
group = s.group
|
||||
else:
|
||||
group = ""
|
||||
|
||||
|
||||
if group not in style_choices:
|
||||
style_choices[group] = []
|
||||
style_choices[s.group].append((s.name, description))
|
||||
|
@ -185,6 +194,7 @@ class MapRenderingJobForm(forms.ModelForm):
|
|||
city = cleaned_data.get("administrative_city")
|
||||
title = cleaned_data.get("maptitle")
|
||||
layout = cleaned_data.get("layout")
|
||||
indexer = cleaned_data.get("indexer")
|
||||
stylesheet = cleaned_data.get("stylesheet")
|
||||
overlay_array = []
|
||||
try:
|
||||
|
@ -199,6 +209,11 @@ class MapRenderingJobForm(forms.ModelForm):
|
|||
self._errors["layout"] = ErrorList([msg])
|
||||
del cleaned_data["layout"]
|
||||
|
||||
if indexer == '':
|
||||
msg = _(u"Indexer required")
|
||||
self._errors["indexer"] = ErrorList([msg])
|
||||
del cleaned_data["indexer"]
|
||||
|
||||
if stylesheet == '':
|
||||
msg = _(u"Stylesheet required")
|
||||
self._errors["stylesheet"] = ErrorList([msg])
|
||||
|
@ -293,6 +308,7 @@ class MapPaperSizeForm(forms.Form):
|
|||
"""
|
||||
osmid = forms.IntegerField(required=False)
|
||||
layout = forms.CharField(max_length=256)
|
||||
indexer = forms.CharField(max_length=256)
|
||||
stylesheet = forms.CharField(max_length=256)
|
||||
lat_upper_left = forms.FloatField(required=False, min_value=-90.0, max_value=90.0)
|
||||
lon_upper_left = forms.FloatField(required=False, min_value=-180.0, max_value=180.0)
|
||||
|
|
|
@ -247,6 +247,10 @@ $('#error-modal').modal('show')
|
|||
<legend>{% trans "Layout" %}</legend>
|
||||
{{ form.layout }}
|
||||
</fieldset>
|
||||
<fieldset>
|
||||
<legend>{% trans "Indexer" %}</legend>
|
||||
{{ form.indexer }}
|
||||
</fieldset>
|
||||
</div>
|
||||
<div class="col-lg-6">
|
||||
<img id="layout-preview" align="right" src="/media/img/layout/{{request.session.new_layout}}.png"/>
|
||||
|
|
|
@ -55,7 +55,10 @@ function preparePaperSize() {
|
|||
};
|
||||
}
|
||||
|
||||
// make the next two lines work with select boxes, too
|
||||
args['layout'] = $('input[name=layout]:checked').val();
|
||||
args['indexer'] = $('input[name=indexer]:checked').val();
|
||||
|
||||
args['stylesheet'] = $('input[name=stylesheet]:checked').val();
|
||||
if (!args['stylesheet']) {
|
||||
args['stylesheet'] = $('#id_stylesheet :selected').val();
|
||||
|
|
|
@ -142,6 +142,7 @@ def new(request):
|
|||
form = forms.MapRenderingJobForm(request.POST, request.FILES)
|
||||
if form.is_valid():
|
||||
request.session['new_layout'] = form.cleaned_data.get('layout')
|
||||
request.session['new_indexer'] = form.cleaned_data.get('indexer')
|
||||
request.session['new_stylesheet'] = form.cleaned_data.get('stylesheet')
|
||||
request.session['new_overlay'] = form.cleaned_data.get('overlay')
|
||||
request.session['new_paper_width_mm'] = form.cleaned_data.get('paper_width_mm')
|
||||
|
@ -154,6 +155,7 @@ def new(request):
|
|||
job.layout = form.cleaned_data.get('layout')
|
||||
if job.layout.startswith('multi'):
|
||||
job.queue = 'multipage'
|
||||
job.indexer = form.cleaned_data.get('indexer')
|
||||
job.paper_width_mm = form.cleaned_data.get('paper_width_mm')
|
||||
job.paper_height_mm = form.cleaned_data.get('paper_height_mm')
|
||||
job.status = 0 # Submitted
|
||||
|
@ -191,6 +193,11 @@ def new(request):
|
|||
else:
|
||||
request.session['new_layout'] = oc.get_all_renderer_names()[0]
|
||||
|
||||
if not 'indexer' in init_vals and 'new_indexer' in request.session :
|
||||
init_vals['indexer'] = request.session['new_indexer']
|
||||
else:
|
||||
request.session['new_indexer'] = 'Street' # TODO make configurable
|
||||
|
||||
if not 'stylesheet' in init_vals and 'new_stylesheet' in request.session:
|
||||
init_vals['stylesheet'] = request.session['new_stylesheet']
|
||||
else:
|
||||
|
@ -324,9 +331,11 @@ def recreate(request):
|
|||
newjob.lat_bottom_right = job.lat_bottom_right
|
||||
newjob.lon_bottom_right = job.lon_bottom_right
|
||||
|
||||
newjob.layout = job.layout
|
||||
newjob.indexer = job.indexer
|
||||
newjob.stylesheet = job.stylesheet
|
||||
newjob.overlay = job.overlay
|
||||
newjob.layout = job.layout
|
||||
|
||||
newjob.queue = "default"
|
||||
if job.layout.startswith('multi'):
|
||||
newjob.queue = 'multipage'
|
||||
|
|
Ładowanie…
Reference in New Issue