mirror of
https://github.com/RoboSats/robosats.git
synced 2025-01-18 20:21:35 +00:00
fix warnings DecimalField should be Decimal type (#1334)
This commit is contained in:
parent
daf9ce4d3f
commit
1f2a1abc75
@ -1,5 +1,6 @@
|
|||||||
import json
|
import json
|
||||||
|
|
||||||
|
from decimal import Decimal
|
||||||
from django.core.validators import MinValueValidator
|
from django.core.validators import MinValueValidator
|
||||||
from django.db import models
|
from django.db import models
|
||||||
from django.utils import timezone
|
from django.utils import timezone
|
||||||
@ -18,7 +19,7 @@ class Currency(models.Model):
|
|||||||
decimal_places=4,
|
decimal_places=4,
|
||||||
default=None,
|
default=None,
|
||||||
null=True,
|
null=True,
|
||||||
validators=[MinValueValidator(0)],
|
validators=[MinValueValidator(Decimal(0))],
|
||||||
)
|
)
|
||||||
timestamp = models.DateTimeField(default=timezone.now)
|
timestamp = models.DateTimeField(default=timezone.now)
|
||||||
|
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
import uuid
|
import uuid
|
||||||
|
|
||||||
|
from decimal import Decimal
|
||||||
from decouple import config
|
from decouple import config
|
||||||
from django.core.validators import MaxValueValidator, MinValueValidator
|
from django.core.validators import MaxValueValidator, MinValueValidator
|
||||||
from django.db import models
|
from django.db import models
|
||||||
@ -27,21 +28,24 @@ class MarketTick(models.Model):
|
|||||||
decimal_places=2,
|
decimal_places=2,
|
||||||
default=None,
|
default=None,
|
||||||
null=True,
|
null=True,
|
||||||
validators=[MinValueValidator(0)],
|
validators=[MinValueValidator(Decimal(0))],
|
||||||
)
|
)
|
||||||
volume = models.DecimalField(
|
volume = models.DecimalField(
|
||||||
max_digits=8,
|
max_digits=8,
|
||||||
decimal_places=8,
|
decimal_places=8,
|
||||||
default=None,
|
default=None,
|
||||||
null=True,
|
null=True,
|
||||||
validators=[MinValueValidator(0)],
|
validators=[MinValueValidator(Decimal(0))],
|
||||||
)
|
)
|
||||||
premium = models.DecimalField(
|
premium = models.DecimalField(
|
||||||
max_digits=5,
|
max_digits=5,
|
||||||
decimal_places=2,
|
decimal_places=2,
|
||||||
default=None,
|
default=None,
|
||||||
null=True,
|
null=True,
|
||||||
validators=[MinValueValidator(-100), MaxValueValidator(999)],
|
validators=[
|
||||||
|
MinValueValidator(Decimal(-100)),
|
||||||
|
MaxValueValidator(Decimal(999))
|
||||||
|
],
|
||||||
blank=True,
|
blank=True,
|
||||||
)
|
)
|
||||||
currency = models.ForeignKey("api.Currency", null=True, on_delete=models.SET_NULL)
|
currency = models.ForeignKey("api.Currency", null=True, on_delete=models.SET_NULL)
|
||||||
@ -52,7 +56,10 @@ class MarketTick(models.Model):
|
|||||||
max_digits=4,
|
max_digits=4,
|
||||||
decimal_places=4,
|
decimal_places=4,
|
||||||
default=0,
|
default=0,
|
||||||
validators=[MinValueValidator(0), MaxValueValidator(1)],
|
validators=[
|
||||||
|
MinValueValidator(Decimal(0)),
|
||||||
|
MaxValueValidator(Decimal(1))
|
||||||
|
],
|
||||||
)
|
)
|
||||||
|
|
||||||
def log_a_tick(order):
|
def log_a_tick(order):
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
from decimal import Decimal
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
from django.contrib.auth.models import User
|
from django.contrib.auth.models import User
|
||||||
from django.core.validators import MaxValueValidator, MinValueValidator
|
from django.core.validators import MaxValueValidator, MinValueValidator
|
||||||
@ -58,7 +59,10 @@ class OnchainPayment(models.Model):
|
|||||||
default=2.05,
|
default=2.05,
|
||||||
null=False,
|
null=False,
|
||||||
blank=False,
|
blank=False,
|
||||||
validators=[MinValueValidator(1), MaxValueValidator(999)],
|
validators=[
|
||||||
|
MinValueValidator(Decimal(1)),
|
||||||
|
MaxValueValidator(Decimal(999))
|
||||||
|
],
|
||||||
)
|
)
|
||||||
mining_fee_rate = models.DecimalField(
|
mining_fee_rate = models.DecimalField(
|
||||||
max_digits=6,
|
max_digits=6,
|
||||||
@ -66,7 +70,10 @@ class OnchainPayment(models.Model):
|
|||||||
default=2.05,
|
default=2.05,
|
||||||
null=False,
|
null=False,
|
||||||
blank=False,
|
blank=False,
|
||||||
validators=[MinValueValidator(1), MaxValueValidator(999)],
|
validators=[
|
||||||
|
MinValueValidator(Decimal(1)),
|
||||||
|
MaxValueValidator(Decimal(999))
|
||||||
|
],
|
||||||
)
|
)
|
||||||
mining_fee_sats = models.PositiveBigIntegerField(default=0, null=False, blank=False)
|
mining_fee_sats = models.PositiveBigIntegerField(default=0, null=False, blank=False)
|
||||||
|
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
# We use custom seeded UUID generation during testing
|
# We use custom seeded UUID generation during testing
|
||||||
import uuid
|
import uuid
|
||||||
|
|
||||||
|
from decimal import Decimal
|
||||||
from decouple import config
|
from decouple import config
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
from django.contrib.auth.models import User
|
from django.contrib.auth.models import User
|
||||||
@ -90,7 +91,10 @@ class Order(models.Model):
|
|||||||
decimal_places=2,
|
decimal_places=2,
|
||||||
default=0,
|
default=0,
|
||||||
null=True,
|
null=True,
|
||||||
validators=[MinValueValidator(-100), MaxValueValidator(999)],
|
validators=[
|
||||||
|
MinValueValidator(Decimal(-100)),
|
||||||
|
MaxValueValidator(Decimal(999))
|
||||||
|
],
|
||||||
blank=True,
|
blank=True,
|
||||||
)
|
)
|
||||||
# explicit
|
# explicit
|
||||||
@ -135,8 +139,8 @@ class Order(models.Model):
|
|||||||
default=settings.DEFAULT_BOND_SIZE,
|
default=settings.DEFAULT_BOND_SIZE,
|
||||||
null=False,
|
null=False,
|
||||||
validators=[
|
validators=[
|
||||||
MinValueValidator(settings.MIN_BOND_SIZE), # 2 %
|
MinValueValidator(Decimal(settings.MIN_BOND_SIZE)), # 2 %
|
||||||
MaxValueValidator(settings.MAX_BOND_SIZE), # 15 %
|
MaxValueValidator(Decimal(settings.MAX_BOND_SIZE)), # 15 %
|
||||||
],
|
],
|
||||||
blank=False,
|
blank=False,
|
||||||
)
|
)
|
||||||
@ -147,8 +151,8 @@ class Order(models.Model):
|
|||||||
decimal_places=6,
|
decimal_places=6,
|
||||||
null=True,
|
null=True,
|
||||||
validators=[
|
validators=[
|
||||||
MinValueValidator(-90),
|
MinValueValidator(Decimal(-90)),
|
||||||
MaxValueValidator(90),
|
MaxValueValidator(Decimal(90)),
|
||||||
],
|
],
|
||||||
blank=True,
|
blank=True,
|
||||||
)
|
)
|
||||||
@ -157,8 +161,8 @@ class Order(models.Model):
|
|||||||
decimal_places=6,
|
decimal_places=6,
|
||||||
null=True,
|
null=True,
|
||||||
validators=[
|
validators=[
|
||||||
MinValueValidator(-180),
|
MinValueValidator(Decimal(-180)),
|
||||||
MaxValueValidator(180),
|
MaxValueValidator(Decimal(180)),
|
||||||
],
|
],
|
||||||
blank=True,
|
blank=True,
|
||||||
)
|
)
|
||||||
|
Loading…
Reference in New Issue
Block a user