wrap around ORM in editor api
This commit is contained in:
parent
7e78bf0550
commit
344ab790a3
3 changed files with 30 additions and 9 deletions
|
@ -28,14 +28,18 @@ class Level(SpecificLocation, EditorFormMixin, models.Model):
|
|||
def __init__(self, *args, **kwargs):
|
||||
super().__init__(*args, **kwargs)
|
||||
|
||||
def lower(self):
|
||||
def lower(self, level_model=None):
|
||||
if self.on_top_of_id is not None:
|
||||
raise TypeError
|
||||
if level_model is not None:
|
||||
Level = level_model
|
||||
return Level.objects.filter(altitude__lt=self.altitude, on_top_of__isnull=True).order_by('-altitude')
|
||||
|
||||
def higher(self):
|
||||
def higher(self, level_model=None):
|
||||
if self.on_top_of_id is not None:
|
||||
raise TypeError
|
||||
if level_model is not None:
|
||||
Level = level_model
|
||||
return Level.objects.filter(altitude__gt=self.altitude, on_top_of__isnull=True).order_by('altitude')
|
||||
|
||||
@property
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue