lingo: add a description text field to invoice cells (#10453)
This commit is contained in:
parent
1b10f83a76
commit
ea55247799
|
@ -0,0 +1,25 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import migrations, models
|
||||
import ckeditor.fields
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('lingo', '0016_auto_20160319_2028'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name='activeitems',
|
||||
name='text',
|
||||
field=ckeditor.fields.RichTextField(null=True, verbose_name='Text', blank=True),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='itemshistory',
|
||||
name='text',
|
||||
field=ckeditor.fields.RichTextField(null=True, verbose_name='Text', blank=True),
|
||||
),
|
||||
]
|
|
@ -35,6 +35,8 @@ from django.utils import timezone
|
|||
from django.core.exceptions import PermissionDenied
|
||||
from django.utils.http import urlencode
|
||||
|
||||
from ckeditor.fields import RichTextField
|
||||
|
||||
from combo.data.models import CellBase
|
||||
from combo.data.library import register_cell_class
|
||||
from combo.utils import NothingInCacheException, sign_url
|
||||
|
@ -354,6 +356,7 @@ class LingoBasketLinkCell(CellBase):
|
|||
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'
|
||||
|
@ -371,14 +374,13 @@ class Items(CellBase):
|
|||
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 = ['regie', 'title']
|
||||
else:
|
||||
fields = ['title']
|
||||
widgets = {}
|
||||
widgets['regie'] = Select(choices=regies)
|
||||
fields.insert(0, 'regie')
|
||||
return model_forms.modelform_factory(self.__class__, fields=fields, widgets=widgets)
|
||||
|
||||
def get_regies(self):
|
||||
|
@ -387,7 +389,7 @@ class Items(CellBase):
|
|||
return Regie.objects.all()
|
||||
|
||||
def get_cell_extra_context(self, context):
|
||||
ctx = {'title': self.title}
|
||||
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)
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
{% load i18n %}
|
||||
{% if title %}<h2>{{ title|safe }}</h2>{% endif %}
|
||||
<div>
|
||||
{% if text %}{{ text|safe }}{% endif %}
|
||||
{% if items %}
|
||||
<table class="invoices">
|
||||
<thead>
|
||||
|
|
Loading…
Reference in New Issue