From 6113de33ec2468936697d4a2969f528ae9b6941c Mon Sep 17 00:00:00 2001 From: Krophil Date: Sun, 22 Oct 2017 21:10:02 +0200 Subject: [PATCH] Add comment in product type --- .../migrations/0016_producttype_comment.py | 19 +++++++++++++++++++ counter/models.py | 1 + counter/views.py | 4 ++-- eboutic/templates/eboutic/eboutic_main.jinja | 4 ++++ 4 files changed, 26 insertions(+), 2 deletions(-) create mode 100644 counter/migrations/0016_producttype_comment.py diff --git a/counter/migrations/0016_producttype_comment.py b/counter/migrations/0016_producttype_comment.py new file mode 100644 index 00000000..26244fe6 --- /dev/null +++ b/counter/migrations/0016_producttype_comment.py @@ -0,0 +1,19 @@ +# -*- coding: utf-8 -*- +from __future__ import unicode_literals + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('counter', '0015_merge'), + ] + + operations = [ + migrations.AddField( + model_name='producttype', + name='comment', + field=models.TextField(verbose_name='comment', blank=True, null=True), + ), + ] diff --git a/counter/models.py b/counter/models.py index 5183767f..7ca89c6b 100644 --- a/counter/models.py +++ b/counter/models.py @@ -112,6 +112,7 @@ class ProductType(models.Model): """ name = models.CharField(_('name'), max_length=30) description = models.TextField(_('description'), null=True, blank=True) + comment = models.TextField(_('comment'), null=True, blank=True) icon = models.ImageField(upload_to='products', null=True, blank=True) class Meta: diff --git a/counter/views.py b/counter/views.py index bc008d54..6a39619e 100644 --- a/counter/views.py +++ b/counter/views.py @@ -688,7 +688,7 @@ class ProductTypeCreateView(CounterAdminTabsMixin, CounterAdminMixin, CreateView A create view for the admins """ model = ProductType - fields = ['name', 'description', 'icon'] + fields = ['name', 'description', 'comment', 'icon'] template_name = 'core/create.jinja' current_tab = "products" @@ -699,7 +699,7 @@ class ProductTypeEditView(CounterAdminTabsMixin, CounterAdminMixin, UpdateView): """ model = ProductType template_name = 'core/edit.jinja' - fields = ['name', 'description', 'icon'] + fields = ['name', 'description', 'comment', 'icon'] pk_url_kwarg = "type_id" current_tab = "products" diff --git a/eboutic/templates/eboutic/eboutic_main.jinja b/eboutic/templates/eboutic/eboutic_main.jinja index 825435ce..042c7b4e 100644 --- a/eboutic/templates/eboutic/eboutic_main.jinja +++ b/eboutic/templates/eboutic/eboutic_main.jinja @@ -41,6 +41,10 @@ {% for t in categories %} {% if eboutic.products.filter(product_type=t).exists() %}
{{ t }}
+ {% if t.comment %} +

{{ t.comment }}

+ {% endif %} +
{% for p in eboutic.products.filter(product_type=t).all() %} {% set file = None %} {% if p.icon %}