add RangingBeacon to mapdata
This commit is contained in:
parent
8efb1057d1
commit
320ae7b4c9
6 changed files with 130 additions and 5 deletions
84
src/c3nav/mapdata/migrations/0087_rangingbeacon.py
Normal file
84
src/c3nav/mapdata/migrations/0087_rangingbeacon.py
Normal file
|
@ -0,0 +1,84 @@
|
|||
# Generated by Django 4.2.1 on 2023-11-10 17:53
|
||||
|
||||
import c3nav.mapdata.fields
|
||||
from decimal import Decimal
|
||||
import django.core.validators
|
||||
from django.db import migrations, models
|
||||
import django.db.models.deletion
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
dependencies = [
|
||||
("mapdata", "0086_django_4_0"),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.CreateModel(
|
||||
name="RangingBeacon",
|
||||
fields=[
|
||||
(
|
||||
"id",
|
||||
models.AutoField(
|
||||
auto_created=True,
|
||||
primary_key=True,
|
||||
serialize=False,
|
||||
verbose_name="ID",
|
||||
),
|
||||
),
|
||||
(
|
||||
"import_tag",
|
||||
models.CharField(
|
||||
blank=True, max_length=32, null=True, verbose_name="import tag"
|
||||
),
|
||||
),
|
||||
(
|
||||
"geometry",
|
||||
c3nav.mapdata.fields.GeometryField(default=None, geomtype="point"),
|
||||
),
|
||||
(
|
||||
"bssid",
|
||||
models.CharField(
|
||||
max_length=17,
|
||||
unique=True,
|
||||
validators=[
|
||||
django.core.validators.RegexValidator(
|
||||
code="invalid_bssid",
|
||||
message="Must be a lower-case bssid",
|
||||
regex="^([a-f0-9]{2}:){5}[a-f0-9]{2}$",
|
||||
)
|
||||
],
|
||||
verbose_name="BSSID",
|
||||
),
|
||||
),
|
||||
(
|
||||
"altitude",
|
||||
models.DecimalField(
|
||||
decimal_places=2,
|
||||
default=0,
|
||||
max_digits=6,
|
||||
validators=[
|
||||
django.core.validators.MinValueValidator(Decimal("0"))
|
||||
],
|
||||
verbose_name="altitude above ground",
|
||||
),
|
||||
),
|
||||
(
|
||||
"comment",
|
||||
models.TextField(blank=True, null=True, verbose_name="comment"),
|
||||
),
|
||||
(
|
||||
"space",
|
||||
models.ForeignKey(
|
||||
on_delete=django.db.models.deletion.CASCADE,
|
||||
to="mapdata.space",
|
||||
verbose_name="space",
|
||||
),
|
||||
),
|
||||
],
|
||||
options={
|
||||
"verbose_name": "Ranging beacon",
|
||||
"verbose_name_plural": "Ranging beacons",
|
||||
"default_related_name": "ranging_beacons",
|
||||
},
|
||||
),
|
||||
]
|
|
@ -2,7 +2,7 @@ from decimal import Decimal
|
|||
|
||||
from django.conf import settings
|
||||
from django.core.exceptions import ObjectDoesNotExist
|
||||
from django.core.validators import MinValueValidator
|
||||
from django.core.validators import MinValueValidator, RegexValidator
|
||||
from django.db import models
|
||||
from django.urls import reverse
|
||||
from django.utils.functional import cached_property
|
||||
|
@ -398,3 +398,38 @@ class WifiMeasurement(SpaceGeometryMixin, models.Model):
|
|||
@property
|
||||
def geometry_changed(self):
|
||||
return False
|
||||
|
||||
|
||||
class RangingBeacon(SpaceGeometryMixin, models.Model):
|
||||
"""
|
||||
A ranging beacon
|
||||
"""
|
||||
geometry = GeometryField('point')
|
||||
bssid = models.CharField(_('BSSID'), max_length=17, unique=True,
|
||||
validators=[RegexValidator(
|
||||
regex='^([a-f0-9]{2}:){5}[a-f0-9]{2}$',
|
||||
message='Must be a lower-case bssid',
|
||||
code='invalid_bssid'
|
||||
)])
|
||||
altitude = models.DecimalField(_('altitude above ground'), max_digits=6, decimal_places=2, default=0,
|
||||
validators=[MinValueValidator(Decimal('0'))])
|
||||
comment = models.TextField(null=True, blank=True, verbose_name=_('comment'))
|
||||
|
||||
class Meta:
|
||||
verbose_name = _('Ranging beacon')
|
||||
verbose_name_plural = _('Ranging beacons')
|
||||
default_related_name = 'ranging_beacons'
|
||||
|
||||
@property
|
||||
def all_geometry_changed(self):
|
||||
return False
|
||||
|
||||
@property
|
||||
def geometry_changed(self):
|
||||
return False
|
||||
|
||||
@property
|
||||
def title(self):
|
||||
if self.comment:
|
||||
return f'{self.bssid} ({self.comment})'
|
||||
return self.bssid
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue