Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def latest_entry():
# Cache-busting query based on most recently-visible entry
cb_query = queries.build_query({})
cb_query = cb_query.order_by(orm.desc(model.Entry.utc_date))
latest = cb_query.first()
if latest:
LOGGER.debug("Most recently-scheduled entry: %s", latest)
return latest.id
return None
topics = orm.select(rv for rv in Topic if rv.reply_count == 0).order_by(lambda:
orm.desc(rv.created_at))
else:
NONE = 2 # none of the criteria are present
NOT = 2 # synonym for NONE
# Ordering queries for different sort orders
ORDER_BY = {
'newest': (orm.desc(model.Entry.local_date), orm.desc(model.Entry.id)),
'oldest': (model.Entry.local_date, model.Entry.id),
'title': (model.Entry.sort_title, model.Entry.id)
}
REVERSE_ORDER_BY = {
'newest': (model.Entry.local_date, model.Entry.id),
'oldest': (orm.desc(model.Entry.local_date), orm.desc(model.Entry.id)),
'title': (orm.desc(model.Entry.sort_title), orm.desc(model.Entry.id))
}
def where_entry_visible(query, date=None):
""" Generate a where clause for currently-visible entries
Arguments:
date -- The date to generate it relative to (defaults to right now)
"""
return query.filter(lambda e:
e.status == model.PublishStatus.PUBLISHED.value or (
e.status == model.PublishStatus.SCHEDULED.value and (
e.utc_date <= (date or arrow.utcnow().datetime))
))
from flask import url_for
from flux import app, config, utils
import datetime
import hashlib
import os
import pony.orm as orm
import shutil
import uuid
db = orm.Database(**config.database)
session = orm.db_session
commit = orm.commit
rollback = orm.rollback
select = orm.select
desc = orm.desc
class User(db.Entity):
_table_ = 'users'
id = orm.PrimaryKey(int)
name = orm.Required(str, unique=True)
passhash = orm.Required(str)
can_manage = orm.Required(bool)
can_download_artifacts = orm.Required(bool)
can_view_buildlogs = orm.Required(bool)
login_tokens = orm.Set('LoginToken')
def __init__(self, **kwargs):
if 'id' not in kwargs:
kwargs['id'] = (orm.max(x.id for x in User) or 0) + 1
reply = collipa.models.Reply.select(lambda rv: rv.topic_id == self.id).order_by(lambda:
orm.desc(rv.created_at)).first()
return reply
user_ids = user_ids.order_by(lambda: orm.desc(rv.created_at))
topics = orm.select(rv for rv in Topic).order_by(lambda: orm.desc(rv.last_reply_date))
if isinstance(topics, list):
def index(self):
'''Get all people, ordered by creation date.'''
all_people = orm.select(p for p in Person).order_by(orm.desc(Person.created))[:]
data = PersonSerializer(all_people, exclude=('created',)).data
return jsonify({"people": data})