# -*- coding: utf-8 -*- from django.db import models from models import Widget from grouping import create_group, add2group create_group('media', 'Мультимедиа') @add2group('Изображение', 'media') class SimpleImage(Widget): image = models.ImageField("Изображение", upload_to='media_widgets/image') alt = models.CharField(max_length=255, blank=True, default="") title = models.CharField(max_length=255, blank=True, default="") link = models.CharField(u'Ссылка', max_length=255, blank=True, default="") @add2group('Видео', 'media') class SimpleVideo(Widget): video = models.FileField("Видео", upload_to='media_widgets/video') alt = models.CharField(max_length=255, blank=True, default="") title = models.CharField(max_length=255, blank=True, default="")
# -*- coding: utf-8 -*- from django.db import models from models import Widget from grouping import create_group, add2group create_group('common', 'Другие') @add2group('Горизонтальная черта', 'common') class Hr(Widget): pass
# -*- coding: utf-8 -*- from django.db import models from models import Widget from grouping import create_group, add2group # # Tables # create_group('tables', 'Таблицы') @add2group('Таблица', 'tables') class Table(Widget): content = models.TextField("Содержимое тега TABLE (без него самого)", blank=True, default="")
# -*- coding: utf-8 -*- from django.db import models from models import Widget, Zone from grouping import create_group, add2group create_group('grids', 'Сетка') class GridWidget(Widget): own_template = "grid" GRID_CHOICES = ( (1, '100'), (2, '50/50'), (3, '66/33'), (4, '33/66'), (5, '33/33/33'), ) grid_type = models.PositiveIntegerField("Grid type", choices=GRID_CHOICES) grid_zone_1 = models.OneToOneField(Zone, related_name='grid_zone_1', verbose_name='Zone 1', null=True, blank=True) grid_zone_2 = models.OneToOneField(Zone, related_name='grid_zone_2', verbose_name='Zone 2', null=True, blank=True) grid_zone_3 = models.OneToOneField(Zone, related_name='grid_zone_3', verbose_name='Zone 3', null=True, blank=True) def columns(self): cols = self.type.split('_')[1:]
# -*- coding: utf-8 -*- from django.db import models from models import Widget from grouping import create_group, add2group from tinymce import models as tinymce_model # # Text # create_group('text', 'Текст') @add2group('Параграф', 'text') class SimpleText(Widget): TEXT_TYPE_CHOICES = ( (1, 'Анонс'), (2, 'Цитата'), (3, 'Заметки'), ) text = models.TextField("Текст", default="Text") text_type = models.PositiveIntegerField("Тип текстового блока", choices=TEXT_TYPE_CHOICES, default=1) @add2group('Таблица характеристик', 'text') class CharsTable(Widget): text = models.TextField("Текст", default="Свойство 1 :: Значение 1\nСвойство 2 :: Значение 2\nСвойство 3 :: Значение 3") def get_pairs(self): result = []
# -*- coding: utf-8 -*- from django.db import models from models import Widget from grouping import create_group, add2group # # Headers # create_group('headers', 'Заголовки') class HeaderWidget(Widget): HEADER_TYPE_CHOICES = ( (1, 'H1'), (2, 'H2'), (3, 'H3'), ) header_type = models.PositiveIntegerField("Тип заголовка", choices=HEADER_TYPE_CHOICES, default=1) header = models.CharField("Текст заголовка", default="Заголовок", max_length=255) @add2group('Заголовок 1', 'headers') class H1(HeaderWidget): def save(self, *args, **kwargs): if self.id is None: self.header_type = '1' self.type = 'HeaderWidget'
# -*- coding: utf-8 -*- from django.db import models from models import Widget from grouping import create_group, add2group # # Text # create_group("text", "Текст") @add2group("Параграф", "text") class Paragraph(Widget): text = models.TextField("Текст", default="Text") @add2group("Анонс", "text") class Announce(Widget): text = models.TextField("Текст", default="Text") @add2group("Цитата", "text") class Quote(Widget): text = models.TextField("Текст", default="Text") @add2group("Заметка", "text") class Note(Widget): text = models.TextField("Текст", default="Text")
# -*- coding: utf-8 -*- from django.db import models from models import Widget from grouping import create_group, add2group # # Lists # create_group('lists', 'Списки') class SimpleList(Widget): LIST_CHOICES = ( (1, 'Маркированный'), (2, 'Нумерованный'), ) content = models.TextField("Список (каждый пункт с новой строки)", blank=True, default="Пункт 1\nПункт 2\nПункт 3") list_type = models.PositiveIntegerField("Тип списка", choices=LIST_CHOICES, default='1') def get_items(self): result = [] for string in self.content.split("\n"): string = string.replace('<li>', '').replace('</li>', "\n") if string.isspace() or string == '': pass else: result.append(string) return result
# -*- coding: utf-8 -*- from django.db import models from models import Widget from grouping import create_group, add2group # # ... # create_group('icon', 'Иконка') @add2group('Иконка', 'icon') class SingleIcon(Widget): icon = models.ImageField("Изображение", upload_to='images/icon', blank=True, null=True) title = models.CharField('Текст заголовка', max_length=255, blank=True, null=True) url = models.CharField('URL (без http)', max_length=255, blank=True, null=True) description = models.TextField("Описание", blank=True, null=True)
# -*- coding: utf-8 -*- from django.db import models from models import Widget from grouping import create_group, add2group # # Images and galleries # create_group('images', 'Картинки и галереи') @add2group('Изображение', 'images') class SingleImage(Widget): image = models.ImageField(u"Изображение", upload_to='image') alt = models.CharField(max_length=255, blank=True, default="") title = models.CharField(max_length=255, blank=True, default="")
# -*- coding: utf-8 -*- from django.db import models from models import Widget from grouping import create_group, add2group create_group('upload', 'Загрузка') @add2group('Файл', 'upload') class UploadFile(Widget): title = models.CharField('Заголовок', max_length=255, blank=True) caption = models.CharField('Название', max_length=50, blank=True) file = models.FileField(upload_to='upload_widget/file')