Find file
Fetching contributors…
Cannot retrieve contributors at this time
42 lines (34 sloc) 1.44 KB
# -*- coding: utf-8 -*-
# Admin views
from datetime import datetime, timedelta
from flask import abort, Response
from app import app
from search import delete_from_index
from models import db, JobPost, agelimit
from utils import md5sum
# --- Admin command-line utilities -------------------------------------------
def delete_index(key):
if key == app.config['PERIODIC_KEY']:
now = datetime.utcnow()
upper_age_limit = timedelta(days=agelimit.days*2) # Reasonably large window to clear backlog
items = JobPost.query.filter(JobPost.datetime > now - upper_age_limit).filter(JobPost.datetime < now - agelimit).all()
return Response("Removed %d items.\n" % len(items),
content_type='text/plain; charset=utf-8')
def update_md5sum(key):
# This view is a hack. We need proper SQL migrations instead of this
if key == app.config['PERIODIC_KEY']:
for post in JobPost.query.all():
if not post.md5sum:
post.md5sum = md5sum(
return Response("Updated md5sum for all posts.\n",
content_type='text/plain; charset=utf-8')
# --- Admin views ------------------------------------------------------------
# LastUser integration pending