summaryrefslogtreecommitdiffstats
path: root/combo/data/models.py
diff options
context:
space:
mode:
Diffstat (limited to 'combo/data/models.py')
-rw-r--r--combo/data/models.py17
1 files changed, 15 insertions, 2 deletions
diff --git a/combo/data/models.py b/combo/data/models.py
index 699a6ee..9723e0f 100644
--- a/combo/data/models.py
+++ b/combo/data/models.py
@@ -440,8 +440,10 @@ class MenuCell(CellBase):
@register_cell_class
class LinkCell(CellBase):
- title = models.CharField(_('Title'), max_length=150)
- url = models.URLField(_('URL'))
+ title = models.CharField(_('Title'), max_length=150, blank=True)
+ url = models.URLField(_('URL'), blank=True)
+ link_page = models.ForeignKey('data.Page', related_name='link_cell', null=True)
+ anchor = models.CharField(_('Anchor'), max_length=150, blank=True)
template_name = 'combo/link-cell.html'
@@ -452,3 +454,14 @@ class LinkCell(CellBase):
if not self.title:
return None
return utils.ellipsize(self.title)
+
+ def render(self, context):
+ if self.link_page:
+ context['url'] = self.link_page.get_online_url()
+ context['title'] = self.title or self.link_page.title
+ else:
+ context['url'] = self.url
+ context['title'] = self.title or self.url
+ if self.anchor:
+ context['url'] += '#' + self.anchor
+ return super(LinkCell, self).render(context)