From 0fd5ac18cdd3435898ba9bd58e2e65e448bb703f Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Sun, 6 Dec 2020 11:53:37 +0100 Subject: [PATCH] do not import pay->auth Try to keep common things in the "uncloud" module --- uncloud/__init__.py | 7 +++++++ uncloud_auth/models.py | 10 +--------- uncloud_pay/__init__.py | 7 ------- 3 files changed, 8 insertions(+), 16 deletions(-) diff --git a/uncloud/__init__.py b/uncloud/__init__.py index 2676f97..4bda45f 100644 --- a/uncloud/__init__.py +++ b/uncloud/__init__.py @@ -1,4 +1,11 @@ from django.utils.translation import gettext_lazy as _ +import decimal + +# Define DecimalField properties, used to represent amounts of money. +AMOUNT_MAX_DIGITS=10 +AMOUNT_DECIMALS=2 + +decimal.getcontext().prec = AMOUNT_DECIMALS # http://xml.coverpages.org/country3166.html COUNTRIES = ( diff --git a/uncloud_auth/models.py b/uncloud_auth/models.py index 9132f96..90463e1 100644 --- a/uncloud_auth/models.py +++ b/uncloud_auth/models.py @@ -2,8 +2,7 @@ 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 +from uncloud import AMOUNT_DECIMALS, AMOUNT_MAX_DIGITS class User(AbstractUser): """ @@ -16,10 +15,3 @@ class User(AbstractUser): 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) diff --git a/uncloud_pay/__init__.py b/uncloud_pay/__init__.py index 810fd3e..8b13789 100644 --- a/uncloud_pay/__init__.py +++ b/uncloud_pay/__init__.py @@ -1,8 +1 @@ -import decimal - -# Define DecimalField properties, used to represent amounts of money. -AMOUNT_MAX_DIGITS=10 -AMOUNT_DECIMALS=2 - -decimal.getcontext().prec = AMOUNT_DECIMALS