lingo: remove ActiveItems and ItemsHistory cell (#10483)
This commit is contained in:
parent
58822107c8
commit
70562bc7df
|
@ -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_manual_migrate_invoice_cells_20160404_1356'),
|
||||
]
|
||||
|
||||
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',
|
||||
),
|
||||
]
|
|
@ -420,79 +420,3 @@ class InvoicesCell(CellBase):
|
|||
if not context.get('synchronous'):
|
||||
raise NothingInCacheException()
|
||||
return super(InvoicesCell, 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
|
||||
|
|
Loading…
Reference in New Issue