height fields should not have negative values
This commit is contained in:
parent
d5ad497327
commit
32192e8fac
4 changed files with 58 additions and 5 deletions
42
src/c3nav/mapdata/migrations/0052_auto_20171125_1335.py
Normal file
42
src/c3nav/mapdata/migrations/0052_auto_20171125_1335.py
Normal file
|
@ -0,0 +1,42 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# Generated by Django 1.11.6 on 2017-11-25 13:35
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from decimal import Decimal
|
||||
import django.core.validators
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('mapdata', '0051_auto_20171125_1241'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterField(
|
||||
model_name='level',
|
||||
name='default_height',
|
||||
field=models.DecimalField(decimal_places=2, default=3.0, max_digits=6, validators=[django.core.validators.MinValueValidator(Decimal('0'))], verbose_name='default space height'),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='level',
|
||||
name='door_height',
|
||||
field=models.DecimalField(decimal_places=2, default=2.0, max_digits=6, validators=[django.core.validators.MinValueValidator(Decimal('0'))], verbose_name='door height'),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='lineobstacle',
|
||||
name='height',
|
||||
field=models.DecimalField(decimal_places=2, default=0.8, max_digits=6, validators=[django.core.validators.MinValueValidator(Decimal('0'))], verbose_name='height'),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='obstacle',
|
||||
name='height',
|
||||
field=models.DecimalField(decimal_places=2, default=0.8, max_digits=6, validators=[django.core.validators.MinValueValidator(Decimal('0'))], verbose_name='height'),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='space',
|
||||
name='height',
|
||||
field=models.DecimalField(blank=True, decimal_places=2, max_digits=6, null=True, validators=[django.core.validators.MinValueValidator(Decimal('0'))], verbose_name='height'),
|
||||
),
|
||||
]
|
|
@ -4,6 +4,7 @@ from itertools import chain, combinations
|
|||
from operator import attrgetter, itemgetter
|
||||
|
||||
import numpy as np
|
||||
from django.core.validators import MinValueValidator
|
||||
from django.db import models
|
||||
from django.urls import reverse
|
||||
from django.utils.text import format_lazy
|
||||
|
@ -100,7 +101,8 @@ class Space(LevelGeometryMixin, SpecificLocation, models.Model):
|
|||
An accessible space. Shouldn't overlap with spaces on the same level.
|
||||
"""
|
||||
geometry = GeometryField('polygon')
|
||||
height = models.DecimalField(_('height'), max_digits=6, decimal_places=2, null=True, blank=True)
|
||||
height = models.DecimalField(_('height'), max_digits=6, decimal_places=2, null=True, blank=True,
|
||||
validators=[MinValueValidator(Decimal('0'))])
|
||||
outside = models.BooleanField(default=False, verbose_name=_('only outside of building'))
|
||||
|
||||
class Meta:
|
||||
|
|
|
@ -1,3 +1,6 @@
|
|||
from decimal import Decimal
|
||||
|
||||
from django.core.validators import MinValueValidator
|
||||
from django.db import models
|
||||
from django.urls import reverse
|
||||
from django.utils.functional import cached_property
|
||||
|
@ -137,7 +140,8 @@ class Obstacle(SpaceGeometryMixin, models.Model):
|
|||
An obstacle
|
||||
"""
|
||||
geometry = GeometryField('polygon')
|
||||
height = models.DecimalField(_('height'), max_digits=6, decimal_places=2, default=0.8)
|
||||
height = models.DecimalField(_('height'), max_digits=6, decimal_places=2, default=0.8,
|
||||
validators=[MinValueValidator(Decimal('0'))])
|
||||
|
||||
class Meta:
|
||||
verbose_name = _('Obstacle')
|
||||
|
@ -156,7 +160,8 @@ class LineObstacle(SpaceGeometryMixin, models.Model):
|
|||
"""
|
||||
geometry = GeometryField('linestring')
|
||||
width = models.DecimalField(_('width'), max_digits=4, decimal_places=2, default=0.15)
|
||||
height = models.DecimalField(_('height'), max_digits=6, decimal_places=2, default=0.8)
|
||||
height = models.DecimalField(_('height'), max_digits=6, decimal_places=2, default=0.8,
|
||||
validators=[MinValueValidator(Decimal('0'))])
|
||||
|
||||
class Meta:
|
||||
verbose_name = _('Line Obstacle')
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
from decimal import Decimal
|
||||
from itertools import chain
|
||||
from operator import attrgetter
|
||||
|
||||
from django.core.validators import MinValueValidator
|
||||
from django.db import models
|
||||
from django.urls import reverse
|
||||
from django.utils.functional import cached_property
|
||||
|
@ -15,8 +17,10 @@ class Level(SpecificLocation, models.Model):
|
|||
A map level
|
||||
"""
|
||||
base_altitude = models.DecimalField(_('base altitude'), null=False, unique=True, max_digits=6, decimal_places=2)
|
||||
default_height = models.DecimalField(_('default space height'), max_digits=6, decimal_places=2, default=3.0)
|
||||
door_height = models.DecimalField(_('door height'), max_digits=6, decimal_places=2, default=2.0)
|
||||
default_height = models.DecimalField(_('default space height'), max_digits=6, decimal_places=2, default=3.0,
|
||||
validators=[MinValueValidator(Decimal('0'))])
|
||||
door_height = models.DecimalField(_('door height'), max_digits=6, decimal_places=2, default=2.0,
|
||||
validators=[MinValueValidator(Decimal('0'))])
|
||||
on_top_of = models.ForeignKey('mapdata.Level', null=True, on_delete=models.CASCADE,
|
||||
related_name='levels_on_top', verbose_name=_('on top of'))
|
||||
short_label = models.SlugField(max_length=20, verbose_name=_('short label'), unique=True)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue