add priority to LocationGroup and and default -priority ordering
This commit is contained in:
parent
6b8324f856
commit
f48298ae1d
2 changed files with 31 additions and 0 deletions
28
src/c3nav/mapdata/migrations/0021_auto_20170710_1916.py
Normal file
28
src/c3nav/mapdata/migrations/0021_auto_20170710_1916.py
Normal file
|
@ -0,0 +1,28 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# Generated by Django 1.11.2 on 2017-07-10 17:16
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('mapdata', '0020_auto_20170710_1848'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterModelOptions(
|
||||
name='locationgroup',
|
||||
options={'ordering': ('-priority',), 'verbose_name': 'Location Group', 'verbose_name_plural': 'Location Groups'},
|
||||
),
|
||||
migrations.AlterModelOptions(
|
||||
name='locationgroupcategory',
|
||||
options={'ordering': ('-priority',), 'verbose_name': 'Location Group Category', 'verbose_name_plural': 'Location Group Categories'},
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='locationgroup',
|
||||
name='priority',
|
||||
field=models.IntegerField(db_index=True, default=0),
|
||||
),
|
||||
]
|
|
@ -164,6 +164,7 @@ class LocationGroupCategory(TitledMixin, models.Model):
|
|||
verbose_name = _('Location Group Category')
|
||||
verbose_name_plural = _('Location Group Categories')
|
||||
default_related_name = 'locationgroupcategories'
|
||||
ordering = ('-priority', )
|
||||
|
||||
def _serialize(self, **kwargs):
|
||||
result = super()._serialize(**kwargs)
|
||||
|
@ -178,11 +179,13 @@ class LocationGroup(Location, models.Model):
|
|||
verbose_name=_('Category'))
|
||||
compiled_room = models.BooleanField(default=False, verbose_name=_('is a compiled room'))
|
||||
compiled_area = models.BooleanField(default=False, verbose_name=_('is a compiled area'))
|
||||
priority = models.IntegerField(default=0, db_index=True)
|
||||
|
||||
class Meta:
|
||||
verbose_name = _('Location Group')
|
||||
verbose_name_plural = _('Location Groups')
|
||||
default_related_name = 'locationgroups'
|
||||
ordering = ('-priority',)
|
||||
|
||||
def _serialize(self, **kwargs):
|
||||
result = super()._serialize(**kwargs)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue