diff options
Diffstat (limited to '')
-rw-r--r-- | model.py | 14 |
1 files changed, 5 insertions, 9 deletions
@@ -1,5 +1,6 @@ import elixir from elixir import has_field, belongs_to, has_many, using_options, using_options_defaults +from elixir import Field, ManyToOne from sqlalchemy import types as T from functools import partial @@ -22,21 +23,16 @@ class Category (Entity): return '<Category "%s">' % self.name class Expense (Entity): - using_options(inheritance='multi') - - has_field('description', T.String(50)) - has_req_field('expense', T.Numeric(scale = 2)) + using_options(abstract = True) - belongs_to('category', of_kind = 'Category', required = True) + description = Field(T.String(50)) + expense = Field(T.Numeric(scale = 2), required = True) + category = ManyToOne('Category', required = True, innerjoin = True, lazy = False) class SingleExpense (Expense): - using_options(inheritance='multi') - has_req_field('date', T.Date) class ConstExpense (Expense): - using_options(inheritance='multi') - has_req_field('months', T.Integer) has_req_field('start', T.Date) has_req_field('end', T.Date) |