mirror of
https://github.com/HaitiData/haitidata.git
synced 2026-10-26 17:35:17 +00:00
Merge pull request #19 from sbsimo/issue#99_on_chart
proposed solution to https://github.com/HaitiData/haitidata/issues/99
This commit is contained in:
commit
a2cafa4782
3 files changed
+34
-3
No files matched your search
@@ -0,0 +1,24 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('charts_app', '0002_auto_20170705_0742'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterField(
|
||||
model_name='chart',
|
||||
name='quantity',
|
||||
field=models.CharField(max_length=200, blank=True),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='chart',
|
||||
name='title',
|
||||
field=models.CharField(max_length=128),
|
||||
),
|
||||
]
|
||||
@@ -45,7 +45,7 @@ class Chart(models.Model):
|
||||
layer = models.ForeignKey(Layer, validators=[validate_wfs])
|
||||
title = models.CharField(max_length=128, blank=False)
|
||||
category = models.CharField(max_length=200)
|
||||
quantity = models.CharField(max_length=200)
|
||||
quantity = models.CharField(max_length=200, blank=True)
|
||||
type = models.SmallIntegerField(choices=CHART_TYPES, default=0)
|
||||
aggr_type = models.SmallIntegerField(choices=AGGREGATION_TYPES, default=3)
|
||||
abstract = models.TextField(blank=True)
|
||||
@@ -60,7 +60,7 @@ class ChartForm(ModelForm):
|
||||
layer = cleaned_data.get('layer')
|
||||
category = cleaned_data.get('category')
|
||||
quantity = cleaned_data.get('quantity')
|
||||
|
||||
aggr_type = cleaned_data.get('aggr_type')
|
||||
categories, quantities = get_fields(layer)
|
||||
|
||||
if category not in categories:
|
||||
@@ -69,7 +69,7 @@ class ChartForm(ModelForm):
|
||||
code='non_extant_category_field',
|
||||
params={'lyr_title': lyr.title, 'category': category})
|
||||
|
||||
if quantity not in quantities:
|
||||
if quantity not in quantities and aggr_type != 2:
|
||||
lyr = Layer.objects.get(pk=layer)
|
||||
raise VE(_('%(lyr_title)s does not contain the field %(quantity)s'),
|
||||
code='non_extant_quantity_field',
|
||||
|
||||
@@ -668,7 +668,14 @@
|
||||
}
|
||||
}
|
||||
|
||||
function check_quantity(){
|
||||
if (document.f.quantity.value == ''){
|
||||
document.f.aggr_type.value = 2;
|
||||
}
|
||||
}
|
||||
|
||||
function updateLinkAndTitle(){
|
||||
check_quantity();
|
||||
update_link();
|
||||
chart_title();
|
||||
attachAbstract();
|
||||
|
||||
Reference in new issue
Block a user