Skip to content

Commit 905aedd

Browse files
committed
Single tenant bank application
With Bank related models
1 parent fb11598 commit 905aedd

File tree

13 files changed

+87
-2
lines changed

13 files changed

+87
-2
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ python-makemigrations-merge:
7474
merge: python-makemigrations-merge
7575

7676
python-migrate:
77-
docker-compose -f local.yml run --rm django python manage.py migrate_schemas --executor=standard_soft_delete
77+
docker-compose -f local.yml run --rm django python manage.py migrate
7878
m: python-migrate
7979

8080

config/settings/base.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@
8686
LOCAL_APPS = [
8787
"pi23_gswdt.users",
8888
# Your stuff: custom apps go here
89+
"pi23_gswdt.bank",
8990
]
9091
# https://docs.djangoproject.com/en/dev/ref/settings/#installed-apps
9192
INSTALLED_APPS = DJANGO_APPS + THIRD_PARTY_APPS + LOCAL_APPS

config/settings/test.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,6 @@
3232
# MEDIA
3333
# ------------------------------------------------------------------------------
3434
# https://docs.djangoproject.com/en/dev/ref/settings/#media-url
35-
MEDIA_URL = 'http://media.testserver'
35+
MEDIA_URL = "http://media.testserver"
3636
# Your stuff...
3737
# ------------------------------------------------------------------------------

config/urls.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
path("users/", include("pi23_gswdt.users.urls", namespace="users")),
1818
path("accounts/", include("allauth.urls")),
1919
# Your stuff: custom urls includes go here
20+
path("bank/", include("pi23_gswdt.bank.urls")),
2021
] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
2122
if settings.DEBUG:
2223
# Static file serving when using Gunicorn + Uvicorn for local web socket development

pi23_gswdt/bank/__init__.py

Whitespace-only changes.

pi23_gswdt/bank/admin.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
from django.contrib import admin
2+
3+
from .models import Account, AccountType, Customer
4+
5+
6+
@admin.register(Customer)
7+
class CustomerAdmin(admin.ModelAdmin):
8+
pass
9+
10+
11+
@admin.register(AccountType)
12+
class AccountTypeAdmin(admin.ModelAdmin):
13+
pass
14+
15+
16+
@admin.register(Account)
17+
class AccountAdmin(admin.ModelAdmin):
18+
pass

pi23_gswdt/bank/apps.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
from django.apps import AppConfig
2+
3+
4+
class BankConfig(AppConfig):
5+
default_auto_field = "django.db.models.BigAutoField"
6+
name = "pi23_gswdt.bank"

pi23_gswdt/bank/constants.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
from django.db import models
2+
3+
4+
class AccountTypeChoices(models.TextChoices):
5+
SAVINGS = "savings"
6+
CURRENT = "current"
7+
LOAN = "loan"
8+
OTHER = "other"

pi23_gswdt/bank/migrations/__init__.py

Whitespace-only changes.

pi23_gswdt/bank/models.py

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
from django.core.validators import MaxValueValidator, MinValueValidator
2+
from django.db import models
3+
from django.utils.translation import gettext_lazy as _
4+
from model_utils.models import TimeStampedModel, UUIDModel
5+
6+
from .constants import AccountTypeChoices
7+
8+
9+
class Customer(UUIDModel, TimeStampedModel):
10+
cust_id = models.PositiveIntegerField(_("9 Digit customer ID"))
11+
name = models.CharField(_("Customer Name"), max_length=50)
12+
email = models.EmailField(unique=True)
13+
14+
def __str__(self):
15+
return f"Customer: [{self.name} - {self.cust_id} - {self.email}]"
16+
17+
18+
class AccountType(UUIDModel, TimeStampedModel):
19+
account_type = models.CharField(_("Type of Account"), unique=True, choices=AccountTypeChoices.choices)
20+
description = models.TextField(blank=True)
21+
22+
def __str__(self):
23+
return f"Account Type: [{self.account_type}]"
24+
25+
26+
class Account(UUIDModel, TimeStampedModel):
27+
customer = models.ForeignKey(Customer, on_delete=models.PROTECT)
28+
account_type = models.ForeignKey(AccountType, on_delete=models.PROTECT)
29+
account_number = models.PositiveBigIntegerField(_("16 digit account number"))
30+
balance = models.DecimalField(max_digits=12, decimal_places=2)
31+
32+
def __str__(self):
33+
return (
34+
f"{self.customer.name}({self.customer.cust_id}) - {self.account_type.account_type} "
35+
f"Account: [{self.account_number}]"
36+
)

0 commit comments

Comments
 (0)