oshipka/vm_gen/templates/model_py

35 lines
1004 B
Plaintext
Raw Normal View History

2020-06-03 18:11:37 +02:00
from oshipka.persistance import db, ModelController
2020-06-03 16:00:51 +02:00
[%- if _choice_types %]
from sqlalchemy_utils import ChoiceType
[%- endif %]
2020-06-03 18:11:37 +02:00
[%- if _secondaries %]
from webapp.models import [% for secondary in _secondaries %][[ secondary ]][%- if not loop.last %], [% endif %][% endfor %]
[%- endif %]
2020-06-03 16:00:51 +02:00
2020-06-03 18:11:37 +02:00
[%- if imports %]
[%- for import in imports %]
[[ import ]]
[%- endfor %]
[%- endif %]
2020-06-03 16:00:51 +02:00
class [[ name ]](db.Model, ModelController):
[%- include "_model_choice_header_py" %]
2020-06-03 18:11:37 +02:00
[%- include "_model_searchable_header_py" %]
2020-06-03 16:00:51 +02:00
[%- for column in columns %]
[%- if column._type == 'relationship' %]
[%- include "_relationship_py" %]
[%- else %]
2020-06-03 18:11:37 +02:00
[[ column.name ]] = db.Column([[ column._type ]],
[%- if column.default %]default="[[ column.default ]]",[%- endif %]
[%- if column.index %]index=True,[%- endif %])
2020-06-03 16:00:51 +02:00
[%- endif %]
[%- endfor %]
2020-06-03 18:11:37 +02:00
[%- if extra_code %]
[[ extra_code ]]
[%- endif %]