don't show future puzzles on leader board
modified: app.py
This commit is contained in:
parent
025bd0645f
commit
7629e3affd
1 changed files with 19 additions and 7 deletions
26
app.py
26
app.py
|
|
@ -197,12 +197,6 @@ engine = create_engine(DB_URL, echo=False)
|
|||
Session = sessionmaker(bind=engine)
|
||||
Base.metadata.create_all(engine)
|
||||
|
||||
################################################################################
|
||||
# Session Factory
|
||||
################################################################################
|
||||
session_factory = SignedCookieSessionFactory(secret="my_insecure_secret")
|
||||
|
||||
|
||||
################################################################################
|
||||
# Helper Functions
|
||||
################################################################################
|
||||
|
|
@ -1042,7 +1036,13 @@ def record_action_view(request):
|
|||
@view_config(route_name="leaderboard_index", renderer="leaderboard_index.html.j2")
|
||||
def leaderboard_index_view(request):
|
||||
s = request.dbsession
|
||||
puzzles = s.query(Puzzle).order_by(Puzzle.date.desc(), Puzzle.size.asc()).all()
|
||||
today = datetime.date.today()
|
||||
puzzles = (
|
||||
s.query(Puzzle)
|
||||
.filter(Puzzle.date <= today)
|
||||
.order_by(Puzzle.date.desc(), Puzzle.size.asc())
|
||||
.all()
|
||||
)
|
||||
return {"request": request, "puzzles": puzzles}
|
||||
|
||||
|
||||
|
|
@ -1176,6 +1176,18 @@ def king_of_the_mountain_view(request):
|
|||
def main(global_config=None, **settings):
|
||||
from pyramid.decorator import reify
|
||||
|
||||
# Set up the session factory with the specified settings
|
||||
session_factory = SignedCookieSessionFactory(
|
||||
secret="it-is-a-secret-you-must-change",
|
||||
hashalg='sha512',
|
||||
timeout=31104000, # Approx. one year in seconds
|
||||
max_age=31104000, # Set Max-Age attribute on cookie
|
||||
reissue_time=15552000, # Approx. six months
|
||||
samesite=None, # Allows cross-site requests if needed
|
||||
httponly=True, # Helps mitigate XSS attacks
|
||||
secure=False # Set to True if using HTTPS
|
||||
)
|
||||
|
||||
if not settings:
|
||||
settings = {}
|
||||
settings["sqlalchemy.url"] = DB_URL
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue