uncloud-mravi/uncloud_auth/models.py
Nico Schottelius 1e68539ed8 remove uuid primary key
Signed-off-by: Nico Schottelius <nico@nico-notebook.schottelius.org>
2020-06-21 14:35:12 +02:00

25 lines
777 B
Python

from django.contrib.auth.models import AbstractUser
from django.db import models
from django.core.validators import MinValueValidator
from uncloud_pay import AMOUNT_DECIMALS, AMOUNT_MAX_DIGITS
from uncloud_pay.models import get_balance_for_user
class User(AbstractUser):
"""
We use the standard user and add a maximum credit that is allowed
to be accumulated. After that we need to have warnings, cancellation, etc.
"""
maximum_credit = models.DecimalField(
default=0.0,
max_digits=AMOUNT_MAX_DIGITS,
decimal_places=AMOUNT_DECIMALS,
validators=[MinValueValidator(0)])
# @property
# def primary_billing_address(self):
@property
def balance(self):
return get_balance_for_user(self)