momo: turn "icon for mobile" into a "meta for mobile", with description (#8797)
This commit is contained in:
parent
1f0d7e42eb
commit
1a14aa53e2
|
@ -0,0 +1,25 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import models, migrations
|
||||
import ckeditor.fields
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('momo', '0003_auto_20151021_1616'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterModelOptions(
|
||||
name='momoiconcell',
|
||||
options={'verbose_name': 'Meta for mobile'},
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='momoiconcell',
|
||||
name='description',
|
||||
field=ckeditor.fields.RichTextField(null=True, verbose_name='Description', blank=True),
|
||||
preserve_default=True,
|
||||
),
|
||||
]
|
|
@ -20,6 +20,8 @@ from django.forms import models as model_forms
|
|||
from django.forms import Select
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
|
||||
from ckeditor.fields import RichTextField
|
||||
|
||||
from combo.data.models import CellBase
|
||||
from combo.data.library import register_cell_class
|
||||
|
||||
|
@ -45,6 +47,9 @@ class MomoOptions(models.Model):
|
|||
|
||||
@register_cell_class
|
||||
class MomoIconCell(CellBase):
|
||||
# initially for icons, now it holds additional page metadata such as
|
||||
# description.
|
||||
|
||||
icon = models.CharField(_('Icon'), max_length=50,
|
||||
default='', blank=True,
|
||||
choices=[
|
||||
|
@ -63,9 +68,10 @@ class MomoIconCell(CellBase):
|
|||
('fa-car', _('Car')),
|
||||
('fa-road', _('Road')),
|
||||
])
|
||||
description = RichTextField(_('Description'), blank=True, null=True)
|
||||
|
||||
class Meta:
|
||||
verbose_name = _('Icon for mobile')
|
||||
verbose_name = _('Meta for mobile')
|
||||
|
||||
def render(self, context):
|
||||
return ''
|
||||
|
@ -78,5 +84,5 @@ class MomoIconCell(CellBase):
|
|||
sorted_icons = self._meta.get_field('icon').choices
|
||||
sorted_icons.sort(lambda x, y: cmp(x[1], y[1]))
|
||||
return model_forms.modelform_factory(self.__class__,
|
||||
fields=['icon'],
|
||||
fields=['icon', 'description'],
|
||||
widgets={'icon': Select(choices=sorted_icons)})
|
||||
|
|
|
@ -78,6 +78,7 @@ def get_page_dict(request, page, manifest):
|
|||
|
||||
if icon_cells:
|
||||
page_dict['icon'] = icon_cells[0].icon
|
||||
page_dict['description'] = icon_cells[0].description
|
||||
|
||||
if page.redirect_url:
|
||||
page_dict['external'] = True
|
||||
|
|
Loading…
Reference in New Issue