mirror of
https://github.com/ae-utbm/sith.git
synced 2025-07-10 11:59:23 +00:00
Improve counter app and migrate products/producttypes/refillings/sellings
This commit is contained in:
29
counter/migrations/0004_auto_20160817_1655.py
Normal file
29
counter/migrations/0004_auto_20160817_1655.py
Normal file
@ -0,0 +1,29 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('counter', '0003_auto_20160814_1634'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterField(
|
||||
model_name='counter',
|
||||
name='type',
|
||||
field=models.CharField(choices=[('BAR', 'Bar'), ('OFFICE', 'Office'), ('EBOUTIC', 'Eboutic')], verbose_name='counter type', max_length=255),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='refilling',
|
||||
name='bank',
|
||||
field=models.CharField(default='OTHER', choices=[('OTHER', 'Autre'), ('SOCIETE-GENERALE', 'Société générale'), ('BANQUE-POPULAIRE', 'Banque populaire'), ('BNP', 'BNP'), ('CAISSE-EPARGNE', "Caisse d'épargne"), ('CIC', 'CIC'), ('CREDIT-AGRICOLE', 'Crédit Agricole'), ('CREDIT-MUTUEL', 'Credit Mutuel'), ('CREDIT-LYONNAIS', 'Credit Lyonnais'), ('LA-POSTE', 'La Poste')], verbose_name='bank', max_length=255),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='refilling',
|
||||
name='payment_method',
|
||||
field=models.CharField(default='CASH', choices=[('CHECK', 'Check'), ('CASH', 'Cash')], verbose_name='payment method', max_length=255),
|
||||
),
|
||||
]
|
24
counter/migrations/0005_auto_20160817_2251.py
Normal file
24
counter/migrations/0005_auto_20160817_2251.py
Normal file
@ -0,0 +1,24 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('counter', '0004_auto_20160817_1655'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterField(
|
||||
model_name='product',
|
||||
name='code',
|
||||
field=models.CharField(verbose_name='code', max_length=10, blank=True),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='product',
|
||||
name='name',
|
||||
field=models.CharField(verbose_name='name', max_length=64),
|
||||
),
|
||||
]
|
19
counter/migrations/0006_auto_20160817_2253.py
Normal file
19
counter/migrations/0006_auto_20160817_2253.py
Normal file
@ -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_20160817_2251'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterField(
|
||||
model_name='product',
|
||||
name='code',
|
||||
field=models.CharField(blank=True, max_length=16, verbose_name='code'),
|
||||
),
|
||||
]
|
21
counter/migrations/0007_selling_club.py
Normal file
21
counter/migrations/0007_selling_club.py
Normal file
@ -0,0 +1,21 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('club', '0004_auto_20160813_1551'),
|
||||
('counter', '0006_auto_20160817_2253'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name='selling',
|
||||
name='club',
|
||||
field=models.ForeignKey(default=1, related_name='sellings', to='club.Club'),
|
||||
preserve_default=False,
|
||||
),
|
||||
]
|
19
counter/migrations/0008_auto_20160818_0231.py
Normal file
19
counter/migrations/0008_auto_20160818_0231.py
Normal file
@ -0,0 +1,19 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('counter', '0007_selling_club'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterField(
|
||||
model_name='selling',
|
||||
name='label',
|
||||
field=models.CharField(max_length=64, verbose_name='label'),
|
||||
),
|
||||
]
|
@ -74,10 +74,10 @@ class Product(models.Model):
|
||||
"""
|
||||
This describes a product, with all its related informations
|
||||
"""
|
||||
name = models.CharField(_('name'), max_length=30)
|
||||
name = models.CharField(_('name'), max_length=64)
|
||||
description = models.TextField(_('description'), blank=True)
|
||||
product_type = models.ForeignKey(ProductType, related_name='products', null=True, blank=True)
|
||||
code = models.CharField(_('code'), max_length=10)
|
||||
code = models.CharField(_('code'), max_length=16, blank=True)
|
||||
purchase_price = CurrencyField(_('purchase price'))
|
||||
selling_price = CurrencyField(_('selling price'))
|
||||
special_selling_price = CurrencyField(_('special selling price'))
|
||||
@ -105,7 +105,7 @@ class Counter(models.Model):
|
||||
name = models.CharField(_('name'), max_length=30)
|
||||
club = models.ForeignKey(Club, related_name="counters")
|
||||
products = models.ManyToManyField(Product, related_name="counters", blank=True)
|
||||
type = models.CharField(_('subscription type'),
|
||||
type = models.CharField(_('counter type'),
|
||||
max_length=255,
|
||||
choices=[('BAR',_('Bar')), ('OFFICE',_('Office')), ('EBOUTIC',_('Eboutic'))])
|
||||
sellers = models.ManyToManyField(Subscriber, verbose_name=_('sellers'), related_name='counters', blank=True)
|
||||
@ -208,9 +208,9 @@ class Refilling(models.Model):
|
||||
customer = models.ForeignKey(Customer, related_name="refillings", blank=False)
|
||||
date = models.DateTimeField(_('date'), auto_now=True)
|
||||
payment_method = models.CharField(_('payment method'), max_length=255,
|
||||
choices=settings.SITH_COUNTER_PAYMENT_METHOD, default='cash')
|
||||
choices=settings.SITH_COUNTER_PAYMENT_METHOD, default='CASH')
|
||||
bank = models.CharField(_('bank'), max_length=255,
|
||||
choices=settings.SITH_COUNTER_BANK, default='other')
|
||||
choices=settings.SITH_COUNTER_BANK, default='OTHER')
|
||||
is_validated = models.BooleanField(_('is validated'), default=False)
|
||||
|
||||
class Meta:
|
||||
@ -234,9 +234,10 @@ class Selling(models.Model):
|
||||
"""
|
||||
Handle the sellings
|
||||
"""
|
||||
label = models.CharField(_("label"), max_length=30)
|
||||
label = models.CharField(_("label"), max_length=64)
|
||||
product = models.ForeignKey(Product, related_name="sellings", null=True, blank=True)
|
||||
counter = models.ForeignKey(Counter, related_name="sellings", blank=False)
|
||||
club = models.ForeignKey(Club, related_name="sellings", blank=False)
|
||||
unit_price = CurrencyField(_('unit price'))
|
||||
quantity = models.IntegerField(_('quantity'))
|
||||
seller = models.ForeignKey(User, related_name="sellings_as_operator", blank=False)
|
||||
|
@ -1,13 +0,0 @@
|
||||
{% extends "core/base.jinja" %}
|
||||
|
||||
{% block content %}
|
||||
<h2>{% trans %}Edit counter{% endtrans %}</h2>
|
||||
<form action="" method="post">
|
||||
{% csrf_token %}
|
||||
{{ form.as_p() }}
|
||||
<p><input type="submit" value="{% trans %}Save{% endtrans %}" /></p>
|
||||
</form>
|
||||
{% endblock %}
|
||||
|
||||
|
||||
|
@ -242,7 +242,7 @@ class CounterClick(DetailView):
|
||||
if uprice * infos['qty'] > self.customer.amount:
|
||||
raise DataError(_("You have not enough money to buy all the basket"))
|
||||
request.session['last_basket'].append("%d x %s" % (infos['qty'], p.name))
|
||||
s = Selling(label=p.name, product=p, counter=self.object, unit_price=uprice,
|
||||
s = Selling(label=p.name, product=p, club=p.club, counter=self.object, unit_price=uprice,
|
||||
quantity=infos['qty'], seller=self.operator, customer=self.customer)
|
||||
s.save()
|
||||
request.session['last_customer'] = self.customer.user.get_display_name()
|
||||
@ -336,7 +336,7 @@ class CounterEditView(CanEditPropMixin, UpdateView):
|
||||
'products':CheckboxSelectMultiple,
|
||||
'sellers':CheckboxSelectMultiple})
|
||||
pk_url_kwarg = "counter_id"
|
||||
template_name = 'counter/counter_edit.jinja'
|
||||
template_name = 'core/edit.jinja'
|
||||
|
||||
class CounterCreateView(CanEditMixin, CreateView):
|
||||
"""
|
||||
@ -345,7 +345,7 @@ class CounterCreateView(CanEditMixin, CreateView):
|
||||
model = Counter
|
||||
form_class = modelform_factory(Counter, fields=['name', 'club', 'type', 'products'],
|
||||
widgets={'products':CheckboxSelectMultiple})
|
||||
template_name = 'counter/counter_edit.jinja'
|
||||
template_name = 'core/create.jinja'
|
||||
|
||||
class CounterDeleteView(CanEditMixin, DeleteView):
|
||||
"""
|
||||
|
Reference in New Issue
Block a user