From ba6cc23feda63468d20af431e28707440e9b19f7 Mon Sep 17 00:00:00 2001 From: Maxime Bombar Date: Sat, 8 Sep 2018 12:59:45 +0200 Subject: [PATCH] Price is a decimal field --- printer/migrations/0006_auto_20180908_1258.py | 20 +++++++++++++++++++ printer/models.py | 8 ++++++-- 2 files changed, 26 insertions(+), 2 deletions(-) create mode 100644 printer/migrations/0006_auto_20180908_1258.py diff --git a/printer/migrations/0006_auto_20180908_1258.py b/printer/migrations/0006_auto_20180908_1258.py new file mode 100644 index 00000000..fde98b0b --- /dev/null +++ b/printer/migrations/0006_auto_20180908_1258.py @@ -0,0 +1,20 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.10.7 on 2018-09-08 10:58 +from __future__ import unicode_literals + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('printer', '0005_jobwithoptions_filename'), + ] + + operations = [ + migrations.AlterField( + model_name='jobwithoptions', + name='price', + field=models.DecimalField(decimal_places=2, default=0.0, max_digits=5, verbose_name='price'), + ), + ] diff --git a/printer/models.py b/printer/models.py index 55ccda40..10c5c500 100644 --- a/printer/models.py +++ b/printer/models.py @@ -77,7 +77,11 @@ class JobWithOptions(RevMixin, models.Model): endtime = models.DateTimeField(null=True) status = models.CharField(max_length=255, choices=STATUS_AVAILABLE) printAs = models.ForeignKey('users.User', on_delete=models.PROTECT, related_name='print_as_user', blank=True, null=True) - price = models.IntegerField(default=0) + price = models.DecimalField( + max_digits=5, + decimal_places=2, + verbose_name=_("price"), + default=0.0) pages = models.IntegerField(default=0) FORMAT_AVAILABLE = ( ('A4', 'A4'), @@ -118,4 +122,4 @@ class JobWithOptions(RevMixin, models.Model): def _update_price(self): - self.price = 0 + self.price = 0.0