Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def _process(self):
q = (ReservationOccurrence.query
.filter(ReservationOccurrence.start_dt > utc_to_server(now_utc()),
ReservationOccurrence.is_valid,
db.or_(Reservation.booked_for_user == session.user,
Reservation.created_by_user == session.user),
~Room.is_deleted)
.join(Reservation)
.join(Room)
.order_by(ReservationOccurrence.start_dt.asc())
.limit(5))
return jsonify(reservation_occurrences_schema.dump(q))
def generate_schema_graph(uri='sqlite:///test.db', output='test.png'):
graph = create_schema_graph(metadata=db.MetaData(uri),
show_datatypes=False,
show_indexes=False,
rankdir='LR', # or TP
concentrate=False) # no joins of tables together
graph.write_png(output)
## Indico is distributed in the hope that it will be useful, but
## WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
## General Public License for more details.
##
## You should have received a copy of the GNU General Public License
## along with Indico;if not, see .
"""
Sent notifications of a reservation
"""
from indico.core.db import db
class ReservationNotification(db.Model):
__tablename__ = 'reservation_notifications'
reservation_id = db.Column(
db.Integer,
db.ForeignKey('reservations.id'),
nullable=False,
primary_key=True
)
occurrence = db.Column(
db.DateTime,
nullable=False,
primary_key=True
)
is_sent = db.Column(
db.Boolean,
nullable=False,
def _get_next_position(context):
"""Get the next question position for the event."""
survey_id = context.current_parameters['survey_id']
parent_id = context.current_parameters['parent_id']
res = db.session.query(db.func.max(SurveyItem.position)).filter_by(survey_id=survey_id, parent_id=parent_id).one()
return (res[0] or 0) + 1
unique_columns = ('session_id',)
disallowed_protection_modes = frozenset()
allow_emails = True
allow_event_roles = True
@declared_attr
def __table_args__(cls):
return auto_table_args(cls, schema='events')
#: The ID of the acl entry
id = db.Column(
db.Integer,
primary_key=True
)
#: The ID of the associated session
session_id = db.Column(
db.Integer,
db.ForeignKey('events.sessions.id'),
nullable=False,
index=True
)
# relationship backrefs:
# - session (Session.acl_entries)
@return_ascii
def __repr__(self):
return format_repr(self, 'id', 'session_id', 'principal', read_access=False, full_access=False, permissions=[])
def get_protection_cte(cls):
cat_alias = db.aliased(cls)
cte_query = (select([cat_alias.id, cat_alias.protection_mode])
.where(cat_alias.parent_id.is_(None))
.cte(recursive=True))
rec_query = (select([cat_alias.id,
db.case({ProtectionMode.inheriting.value: cte_query.c.protection_mode},
else_=cat_alias.protection_mode, value=cat_alias.protection_mode)])
.where(cat_alias.parent_id == cte_query.c.id))
return cte_query.union_all(rec_query)
__tablename__ = 'css_files'
__table_args__ = {'schema': 'events'}
# CSS files are not version-controlled
version_of = None
#: The ID of the file
id = db.Column(
db.Integer,
primary_key=True
)
#: The event the CSS file belongs to
event_id = db.Column(
db.Integer,
db.ForeignKey('events.events.id'),
unique=True,
nullable=False,
index=True
)
event_new = db.relationship(
'Event',
lazy=False,
backref=db.backref(
'layout_stylesheets',
lazy='dynamic'
)
)
@property
def locator(self):
def get_sessions_for_user(event, user):
return (_query_sessions_for_user(event, user)
.options(joinedload('acl_entries'))
.order_by(db.func.lower(Session.title))
.all())
def _model_to_table(name):
"""Resolve a model name to a full table name (unless it's already one)"""
return getattr(db.m, name).__table__.fullname if name[0].isupper() else name
# This file is part of Indico.
# Copyright (C) 2002 - 2019 CERN
#
# Indico is free software; you can redistribute it and/or
# modify it under the terms of the MIT License; see the
# LICENSE file for more details.
from __future__ import unicode_literals
from indico.core.db import db
from indico.util.string import return_ascii
class LegacyCategoryMapping(db.Model):
"""Legacy category ID mapping
Legacy categories have non-numeric IDs which are not supported by
any new code. This mapping maps them to proper integer IDs to
avoid breaking things.
"""
__tablename__ = 'legacy_id_map'
__table_args__ = {'schema': 'categories'}
legacy_category_id = db.Column(
db.String,
primary_key=True,
index=True
)
category_id = db.Column(