summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--model.py13
1 files changed, 11 insertions, 2 deletions
diff --git a/model.py b/model.py
index 45e9296..02323b9 100644
--- a/model.py
+++ b/model.py
@@ -1,5 +1,5 @@
import elixir
-from elixir import Field, ManyToOne, ColumnProperty, using_options, using_options_defaults
+from elixir import Field, ManyToOne, OneToMany, OneToOne, ColumnProperty, using_options, using_options_defaults
from sqlalchemy import types as T
from functools import partial
@@ -18,8 +18,14 @@ class Category (Entity):
name = Field(T.String(50), unique = True)
+ parent = ManyToOne('Category')
+ children = OneToMany('Category')
+
def __repr__ (self):
- return '<Category "%s">' % self.name
+ if self.parent:
+ return '<Category "%s" of "%s">' % (self.name, self.parent.name)
+ else:
+ return '<Category "%s">' % self.name
class Expense (Entity):
using_options(abstract = True)
@@ -38,6 +44,9 @@ class ConstExpense (Expense):
monthly = ColumnProperty(lambda c: c.expense / c.months)
+ next = OneToOne('ConstExpense', inverse = 'prev')
+ prev = ManyToOne('ConstExpense')
+
elixir.setup_all()
session = elixir.session
n class='deletions'>-1/+7 This reverts commit 6600ae0674bc685c4756a040b4db47e927f2e15e. 2020-07-24length validators for string fieldsRené 'Necoro' Neumann4-3/+9 2020-07-24Fix handling of prefilling the description field on adding a new expense.René 'Necoro' Neumann1-9/+6 2020-07-24Remove translation hackRené 'Necoro' Neumann1-7/+1 2020-07-24Improved debuggingRené 'Necoro' Neumann2-1/+2 2020-07-23RestructureRené 'Necoro' Neumann51-2/+3 2020-07-22Do not write bytecode for local debug runningRené 'Necoro' Neumann1-1/+4 2020-07-22Remove left over mention of jquery-uiRené 'Necoro' Neumann1-6/+1 2020-07-22Add simplejson as a dependencyRené 'Necoro' Neumann1-0/+1 2020-07-22Settings splittingRené 'Necoro' Neumann2-5/+3 2020-07-22Add flipflopRené 'Necoro' Neumann1-0/+1