2016-01-13 11:04:13 +00:00
|
|
|
from app import db
|
|
|
|
|
from app.models import (Template, Service)
|
2016-02-22 09:46:16 +00:00
|
|
|
from sqlalchemy import asc
|
2016-01-13 11:04:13 +00:00
|
|
|
|
|
|
|
|
|
2016-02-22 09:46:16 +00:00
|
|
|
def dao_create_template(template):
|
|
|
|
|
db.session.add(template)
|
|
|
|
|
db.session.commit()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def dao_update_template(template):
|
|
|
|
|
db.session.add(template)
|
|
|
|
|
db.session.commit()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def dao_get_template_by_id_and_service_id(template_id, service_id):
|
2016-03-11 12:39:55 +00:00
|
|
|
return Template.query.filter_by(id=template_id, service_id=service_id).one()
|
2016-02-22 09:46:16 +00:00
|
|
|
|
|
|
|
|
|
2016-02-24 11:51:02 +00:00
|
|
|
def dao_get_template_by_id(template_id):
|
2016-03-11 15:34:20 +00:00
|
|
|
return Template.query.filter_by(id=template_id).one()
|
2016-02-24 11:51:02 +00:00
|
|
|
|
|
|
|
|
|
2016-02-22 09:46:16 +00:00
|
|
|
def dao_get_all_templates_for_service(service_id):
|
2016-04-11 17:39:49 +01:00
|
|
|
return Template.query.filter_by(
|
|
|
|
|
service=Service.query.get(service_id)
|
|
|
|
|
).order_by(
|
|
|
|
|
asc(Template.updated_at), asc(Template.created_at)
|
|
|
|
|
).all()
|