diff --git a/nerdshope/__init__.py b/nerdshope/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/nerdshope/admin.py b/nerdshope/admin.py new file mode 100644 index 0000000..65a3de4 --- /dev/null +++ b/nerdshope/admin.py @@ -0,0 +1,8 @@ +from django.contrib import admin + +# Register your models here. + +from .models import BankAccount,Payment,OffDate +admin.site.register(BankAccount) +admin.site.register(Payment) +admin.site.register(OffDate) \ No newline at end of file diff --git a/nerdshope/apps.py b/nerdshope/apps.py new file mode 100644 index 0000000..57e64ea --- /dev/null +++ b/nerdshope/apps.py @@ -0,0 +1,6 @@ +from django.apps import AppConfig + + +class NerdshopeConfig(AppConfig): + default_auto_field = 'django.db.models.BigAutoField' + name = 'nerdshope' diff --git a/nerdshope/models.py b/nerdshope/models.py new file mode 100644 index 0000000..160dfc3 --- /dev/null +++ b/nerdshope/models.py @@ -0,0 +1,30 @@ +from django.db import models +from django.utils.timezone import now + +# Create your models here. +class BankAccount(models.Model): + name=models.CharField(max_length=100) + physical=models.CharField(max_length=100) + currency=models.CharField(max_length=5) + @property + def balance(self): return sum(map(Payment.objects.filter(account=self))) + + def __str__(self): + return str(self.name)+', '+str(self.balance) + +class Payment(models.Model): + timestamp=models.DateTimeField(default=now) + other_party=models.CharField(max_length=100) + account=models.ForeignKey(BankAccount, on_delete=models.CASCADE) + amount=models.IntegerField(default=0) + reason=models.CharField(max_length=200) + + def __str__(self): + return str(self.timestamp)+', '+str(self.amount)+', '+str(self.reason) + +class OffDate(models.Model): + when=models.DateField(default=now) + reason=models.CharField(max_length=50,default="Hall unavailable") + + def __str__(self): + return str(str.when)+': '+str(self.reason) \ No newline at end of file diff --git a/nerdshope/tests.py b/nerdshope/tests.py new file mode 100644 index 0000000..7ce503c --- /dev/null +++ b/nerdshope/tests.py @@ -0,0 +1,3 @@ +from django.test import TestCase + +# Create your tests here. diff --git a/nerdshope/urls.py b/nerdshope/urls.py new file mode 100644 index 0000000..135980f --- /dev/null +++ b/nerdshope/urls.py @@ -0,0 +1,6 @@ +from django.urls import include, path +from . import views + +urlpatterns = [ + path('',views.nerdshope,name='shop'), +] \ No newline at end of file diff --git a/nerdshope/views.py b/nerdshope/views.py new file mode 100644 index 0000000..da1ba38 --- /dev/null +++ b/nerdshope/views.py @@ -0,0 +1,16 @@ +from django.shortcuts import render +from rakka.utils import rerender +from . import models +from main.models import Update + +@rerender +def nerdshope(): + accounts=models.BankAccount.objects.all() + sums={curr:sum([n.balance for n in filter(lambda x:x.currency==curr,accounts)]) for curr in set(map(lambda x:x.currency,accounts))} + moneyblob='\n