general: make it possible to set initial level of menu cells (#10040)
This commit is contained in:
parent
f2ec4031a1
commit
dea29f02a5
|
@ -0,0 +1,20 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import models, migrations
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('data', '0013_parameterscell'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name='menucell',
|
||||
name='initial_level',
|
||||
field=models.IntegerField(default=-1, verbose_name='Initial Level', choices=[(-1, 'Same as page'), (1, 1), (2, 2)]),
|
||||
preserve_default=True,
|
||||
),
|
||||
]
|
|
@ -499,13 +499,16 @@ class BlurpCell(CellBase):
|
|||
class MenuCell(CellBase):
|
||||
depth = models.PositiveIntegerField(_('Depth'),
|
||||
choices=[(i, i) for i in range(1, 3)], default=1, null=False)
|
||||
initial_level = models.IntegerField(_('Initial Level'),
|
||||
choices=[(-1, _('Same as page'))] +
|
||||
[(i, i) for i in range(1, 3)], default=-1, null=False)
|
||||
|
||||
class Meta:
|
||||
verbose_name = _('Menu')
|
||||
|
||||
def render(self, context):
|
||||
from combo.public.menu import render_menu
|
||||
return render_menu(context, level=-1, depth=self.depth)
|
||||
return render_menu(context, level=self.initial_level, depth=self.depth)
|
||||
|
||||
|
||||
@register_cell_class
|
||||
|
|
Loading…
Reference in New Issue