35 lines
1004 B
Plaintext
35 lines
1004 B
Plaintext
from oshipka.persistance import db, ModelController
|
|
|
|
[%- if _choice_types %]
|
|
from sqlalchemy_utils import ChoiceType
|
|
[%- endif %]
|
|
|
|
[%- if _secondaries %]
|
|
from webapp.models import [% for secondary in _secondaries %][[ secondary ]][%- if not loop.last %], [% endif %][% endfor %]
|
|
[%- endif %]
|
|
|
|
[%- if imports %]
|
|
[%- for import in imports %]
|
|
[[ import ]]
|
|
[%- endfor %]
|
|
[%- endif %]
|
|
|
|
class [[ name ]](db.Model, ModelController):
|
|
[%- include "_model_choice_header_py" %]
|
|
[%- include "_model_searchable_header_py" %]
|
|
|
|
[%- for column in columns %]
|
|
[%- if column._type == 'relationship' %]
|
|
[%- include "_relationship_py" %]
|
|
[%- else %]
|
|
[[ column.name ]] = db.Column([[ column._type ]],
|
|
[%- if column.default %]default="[[ column.default ]]",[%- endif %]
|
|
[%- if column.index %]index=True,[%- endif %])
|
|
[%- endif %]
|
|
[%- endfor %]
|
|
|
|
[%- if extra_code %]
|
|
|
|
[[ extra_code ]]
|
|
[%- endif %]
|