From f039f513549029d52c008ed55f153b57cdd0ec98 Mon Sep 17 00:00:00 2001 From: Serghei Mihai Date: Wed, 30 Mar 2016 14:50:28 +0200 Subject: [PATCH 3/5] lingo: remove ActiveItems and ItemsHistory cell (#10483) --- .../lingo/migrations/0020_auto_20160330_1530.py | 36 ++++++++++ combo/apps/lingo/models.py | 76 ---------------------- 2 files changed, 36 insertions(+), 76 deletions(-) create mode 100644 combo/apps/lingo/migrations/0020_auto_20160330_1530.py diff --git a/combo/apps/lingo/migrations/0020_auto_20160330_1530.py b/combo/apps/lingo/migrations/0020_auto_20160330_1530.py new file mode 100644 index 0000000..27f252e --- /dev/null +++ b/combo/apps/lingo/migrations/0020_auto_20160330_1530.py @@ -0,0 +1,36 @@ +# -*- coding: utf-8 -*- +from __future__ import unicode_literals + +from django.db import models, migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ('lingo', '0019_auto_migrate_invoice_cells_20160330_2154'), + ] + + operations = [ + migrations.RemoveField( + model_name='activeitems', + name='groups', + ), + migrations.RemoveField( + model_name='activeitems', + name='page', + ), + migrations.DeleteModel( + name='ActiveItems', + ), + migrations.RemoveField( + model_name='itemshistory', + name='groups', + ), + migrations.RemoveField( + model_name='itemshistory', + name='page', + ), + migrations.DeleteModel( + name='ItemsHistory', + ), + ] diff --git a/combo/apps/lingo/models.py b/combo/apps/lingo/models.py index f76224e..0b785f5 100644 --- a/combo/apps/lingo/models.py +++ b/combo/apps/lingo/models.py @@ -418,79 +418,3 @@ class InvoicesCell(CellBase): if not context.get('synchronous'): raise NothingInCacheException() return super(Invoices, self).render(context) - - -class Items(CellBase): - regie = models.CharField(_('Regie'), max_length=50, blank=True) - title = models.CharField(_('Title'), max_length=200, blank=True) - text = RichTextField(_('Text'), blank=True, null=True) - - user_dependant = True - template_name = 'lingo/combo/items.html' - - class Meta: - abstract = True - - - class Media: - js = ('xstatic/jquery-ui.min.js', 'js/gadjo.js',) - css = {'all': ('xstatic/themes/smoothness/jquery-ui.min.css', )} - - @classmethod - def is_enabled(cls): - return Regie.objects.count() > 0 - - def get_default_form_class(self): - fields = ['title', 'text'] - widgets = {} - if Regie.objects.count() > 1: - regies = [('', _('All'))] - regies.extend([(r.slug, r.label) for r in Regie.objects.all()]) - widgets['regie'] = Select(choices=regies) - fields.insert(0, 'regie') - return model_forms.modelform_factory(self.__class__, fields=fields, widgets=widgets) - - def get_regies(self): - if self.regie: - return [Regie.objects.get(slug=self.regie)] - return Regie.objects.all() - - def get_cell_extra_context(self, context): - ctx = {'title': self.title, 'text': self.text} - items = self.get_items() - # sort items by creation date - items.sort(key=lambda i: i.creation_date, reverse=True) - ctx.update({'items': items}) - return ctx - - def render(self, context): - self.context = context - if not context.get('synchronous'): - raise NothingInCacheException() - return super(Items, self).render(context) - - -@register_cell_class -class ItemsHistory(Items): - - class Meta: - verbose_name = _('Items History Cell') - - def get_items(self): - items = [] - for r in self.get_regies(): - items.extend(r.get_past_items(self.context)) - return items - - -@register_cell_class -class ActiveItems(Items): - - class Meta: - verbose_name = _('Active Items Cell') - - def get_items(self): - items = [] - for r in self.get_regies(): - items.extend(r.get_items(self.context)) - return items -- 2.8.0.rc3