diff --git a/combo/data/forms.py b/combo/data/forms.py index 704f66be..17632464 100644 --- a/combo/data/forms.py +++ b/combo/data/forms.py @@ -52,7 +52,7 @@ class LinkCellForm(forms.ModelForm): class LinkListCellForm(forms.ModelForm): class Meta: model = LinkListCell - fields = ['title'] + fields = ['title', 'limit'] def __init__(self, *args, **kwargs): super(LinkListCellForm, self).__init__(*args, **kwargs) diff --git a/combo/data/migrations/0045_link_list_limit.py b/combo/data/migrations/0045_link_list_limit.py new file mode 100644 index 00000000..67ffa69a --- /dev/null +++ b/combo/data/migrations/0045_link_list_limit.py @@ -0,0 +1,20 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.11.18 on 2020-03-17 09:34 +from __future__ import unicode_literals + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('data', '0044_validity_info'), + ] + + operations = [ + migrations.AddField( + model_name='linklistcell', + name='limit', + field=models.PositiveSmallIntegerField(blank=True, null=True, verbose_name='Limit'), + ), + ] diff --git a/combo/data/models.py b/combo/data/models.py index da8fce5f..1f1945fd 100644 --- a/combo/data/models.py +++ b/combo/data/models.py @@ -1184,6 +1184,7 @@ class LinkCell(CellBase): @register_cell_class class LinkListCell(CellBase): title = models.CharField(_('Title'), max_length=150, blank=True) + limit = models.PositiveSmallIntegerField(_('Limit'), null=True, blank=True) template_name = 'combo/link-list-cell.html' manager_form_template = 'combo/manager/link-list-cell-form.html' @@ -1225,6 +1226,10 @@ class LinkListCell(CellBase): continue links.append(cell.get_cell_extra_context(context)) extra_context['links'] = links + extra_context['more_links'] = [] + if self.limit: + extra_context['more_links'] = extra_context['links'][self.limit:] + extra_context['links'] = extra_context['links'][:self.limit] extra_context['title'] = self.title return extra_context diff --git a/combo/public/templates/combo/link-list-cell.html b/combo/public/templates/combo/link-list-cell.html index 38dd02c1..8b4a4eb3 100644 --- a/combo/public/templates/combo/link-list-cell.html +++ b/combo/public/templates/combo/link-list-cell.html @@ -1,12 +1,19 @@ {% block cell-content %} {% spaceless %} +{% if title %}