import wrpylib.wrmwmarkup
import wrpylib.wrmwcache
import wrpylib.mwmarkup
-
-import wradmin.model as model
+from wradmin.app import db
+from wradmin.model import WrInnCache
class GasthausController:
def list(self):
"""Lists all inns"""
- q = model.meta.Session.query(model.WrInnCache)
- q = q.order_by(model.WrInnCache.page_title)
+ q = db.session.query(WrInnCache)
+ q = q.order_by(WrInnCache.page_title)
paginator = paginate.Page(q.all(), page=int(request.args.get('page', 1)),
url_maker=lambda page: url_for('gasthaus_list', page=page),
items_per_page=25)
def view(self, id):
"""Displays an inn"""
- q = model.meta.Session.query(model.WrInnCache)
+ q = db.session.query(WrInnCache)
inn = q.get(id)
if inn is None:
abort(404)
def update(self):
"""Updates the wrinncache table from the wiki"""
- c = model.meta.Session.connection()
+ c = db.session.connection()
try:
wrpylib.wrmwcache.update_wrinncache(c)
- model.meta.Session.commit()
+ db.session.commit()
flash('Die Gasthausliste wurde erfolgreich aktualisiert.', 'info')
except wrpylib.wrmwcache.UpdateCacheError as e:
title = str(e.args[1])