diff --git a/core/templates/core/create.jinja b/core/templates/core/create.jinja index ca6a591c..04d8f866 100644 --- a/core/templates/core/create.jinja +++ b/core/templates/core/create.jinja @@ -6,7 +6,7 @@ {% block content %}

{% trans name=form.instance.__class__._meta.verbose_name %}Create {{ name }}{% endtrans %}

-
+ {% csrf_token %} {{ form.as_p() }}

diff --git a/core/templates/core/edit.jinja b/core/templates/core/edit.jinja index c27a3cd3..82513bd4 100644 --- a/core/templates/core/edit.jinja +++ b/core/templates/core/edit.jinja @@ -6,7 +6,7 @@ {% block content %}

{% trans obj=object %}Edit {{ obj }}{% endtrans %}

- + {% csrf_token %} {{ form.as_p() }}

diff --git a/counter/migrations/0006_auto_20160831_1304.py b/counter/migrations/0006_auto_20160831_1304.py new file mode 100644 index 00000000..3db83884 --- /dev/null +++ b/counter/migrations/0006_auto_20160831_1304.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', '0005_auto_20160826_2330'), + ] + + operations = [ + migrations.AlterField( + model_name='product', + name='buying_groups', + field=models.ManyToManyField(related_name='products', verbose_name='buying groups', blank=True, to='core.Group'), + ), + ] diff --git a/counter/models.py b/counter/models.py index 5ae9feb7..c9b23392 100644 --- a/counter/models.py +++ b/counter/models.py @@ -88,7 +88,7 @@ class Product(models.Model): tray = models.BooleanField(_('tray price'), default=False) parent_product = models.ForeignKey('self', related_name='children_products', verbose_name=_("parent product"), null=True, blank=True, on_delete=models.SET_NULL) - buying_groups = models.ManyToManyField(Group, related_name='products', verbose_name=_("buying groups")) + buying_groups = models.ManyToManyField(Group, related_name='products', verbose_name=_("buying groups"), blank=True) class Meta: verbose_name = _('product') diff --git a/counter/views.py b/counter/views.py index 65c33818..dab11b89 100644 --- a/counter/views.py +++ b/counter/views.py @@ -463,6 +463,7 @@ class ProductListView(CanEditPropMixin, ListView): """ model = Product template_name = 'counter/product_list.jinja' + ordering = ['name'] class ProductEditForm(forms.ModelForm): class Meta: @@ -470,7 +471,7 @@ class ProductEditForm(forms.ModelForm): fields = ['name', 'description', 'product_type', 'code', 'parent_product', 'buying_groups', 'purchase_price', 'selling_price', 'special_selling_price', 'icon', 'club', 'limit_age', 'tray'] parent_product = AutoCompleteSelectField('products', show_help_text=False, label=_("Parent product"), required=False) - buying_groups = AutoCompleteSelectMultipleField('groups', show_help_text=False, help_text="", label=_("Buying groups")) + buying_groups = AutoCompleteSelectMultipleField('groups', show_help_text=False, help_text="", label=_("Buying groups"), required=False) club = AutoCompleteSelectField('clubs', show_help_text=False) counters = AutoCompleteSelectMultipleField('counters', show_help_text=False, help_text="", label=_("Counters"), required=False)