42 lines
1.2 KiB
Python
42 lines
1.2 KiB
Python
# encoding: utf-8
|
|
|
|
from datetime import datetime
|
|
import random
|
|
|
|
from flask import g, render_template
|
|
|
|
from app import model
|
|
from app.controller.controller import Controller
|
|
from sqlalchemy import desc
|
|
from sqlalchemy.sql.expression import func
|
|
|
|
|
|
class Core(Controller):
|
|
def home(self):
|
|
random.seed(int(datetime.today().timestamp()/100))
|
|
try:
|
|
g.motd = random.choice(model.MatterModel.query.filter_by(
|
|
active=True
|
|
).all())
|
|
except:
|
|
g.motd = None
|
|
try:
|
|
g.rotd = random.choice(model.RepresentativeModel.query.filter_by(
|
|
active=True
|
|
).all())
|
|
except:
|
|
g.rotd = None
|
|
g.last_decisions = model.DecisionModel.query.join(
|
|
model.DecisionModel.recommendation
|
|
).order_by(model.RecommendationModel.date.desc()).limit(10).all()
|
|
g.last_stances = model.StanceModel.query.order_by(
|
|
model.StanceModel.date.desc()
|
|
).limit(10).all()
|
|
return render_template("core/home.html")
|
|
|
|
def about(self):
|
|
return render_template("core/about.html")
|
|
|
|
def who(self):
|
|
return render_template("core/who.html")
|