Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
@flaskparser.use_kwargs({'filtered': fields.Bool(missing=True)})
def get_latest(index=1, filtered=True):
cache = cache_filtered if filtered else cache_unfiltered
kwargs = cache.get(index - 1)
if kwargs:
kwargs['preview'] = True
else:
kwargs['key'] = 'custom'
kwargs['path'] = "your_meme/goes_here"
kwargs['alt'] = PLACEHOLDER
return redirect(route('.get', _external=True, **kwargs))
'is_prebooking': fields.Bool(missing=False)
})
def _process(self, args):
room = Room.get_one(args.pop('room_id'))
user_id = args.pop('user_id', None)
booked_for = User.get_one(user_id) if user_id else session.user
is_prebooking = args.pop('is_prebooking')
# Check that the booking is not longer than allowed
booking_limit_days = room.booking_limit_days or rb_settings.get('booking_limit')
if not self._validate_room_booking_limit(args['start_dt'], args['end_dt'], booking_limit_days):
msg = (_('Bookings for the room "{}" may not be longer than {} days')
.format(room.name, booking_limit_days))
return jsonify(success=False, msg=msg)
try:
resv = Reservation.create_from_data(room, dict(args, booked_for_user=booked_for), session.user,
'fabs': webargs_fields.Bool(missing=False),
'filters': webargs_fields.Dict(keys=webargs_fields.String(), missing={})
})
def list_submissions(certified, **kwargs):
""" List submission IDs associated with the current user """
page = kwargs.get('page')
limit = kwargs.get('limit')
sort = kwargs.get('sort')
order = kwargs.get('order')
fabs = kwargs.get('fabs')
filters = kwargs.get('filters')
return list_submissions_handler(page, limit, certified, sort, order, fabs, filters)
'undo': fields.Bool(missing=False),
'user_id': fields.Int(missing=None)
})
def _process_args(self, undo, user_id):
RHAdminBase._process_args(self)
self.user = None if undo else User.get_one(user_id, is_deleted=False)
def switch(case):
return {
int: wf.Int(missing=None),
float: wf.Float(missing=None),
bool: wf.Bool(missing=None),
list: wf.DelimitedList(wf.Str(), delimiter=',', missing=[]),
}.get(case)
if cast is None or cast is ndb.Key:
from flask_api import exceptions
from webargs import fields
from ..domain import Text
from ..extensions import cache
from ._parser import parser
from ._utils import route
blueprint = Blueprint('templates', __name__, url_prefix="/api/templates/")
OPTIONS = {
'top': fields.Str(missing=""),
'bottom': fields.Str(missing=""),
'_redirect': fields.Bool(load_from='redirect', missing=True),
'_masked': fields.Bool(load_from='masked', missing=False),
}
@blueprint.route("")
@cache.cached()
def get():
"""Get a list of all meme templates."""
data = OrderedDict()
for template in sorted(current_app.template_service.all()):
url = route('.create', key=template.key, _external=True)
data[template.name] = url
return data
@blueprint.route("", methods=['POST'])
from marshmallow_enum import EnumField
from webargs import fields
from indico.legacy.common.cache import GenericCache
from indico.modules.rb.models.reservations import RepeatFrequency
_cache = GenericCache('Rooms')
search_room_args = {
'capacity': fields.Int(),
'equipment': fields.List(fields.Str()),
'features': fields.List(fields.Str(), data_key='feature'),
'favorite': fields.Bool(),
'mine': fields.Bool(),
'text': fields.Str(),
'division': fields.Str(),
'start_dt': fields.DateTime(),
'end_dt': fields.DateTime(),
'repeat_frequency': EnumField(RepeatFrequency),
'repeat_interval': fields.Int(missing=0),
'building': fields.Str(),
'sw_lat': fields.Float(validate=lambda x: -90 <= x <= 90),
'sw_lng': fields.Float(validate=lambda x: -180 <= x <= 180),
'ne_lat': fields.Float(validate=lambda x: -90 <= x <= 90),
'ne_lng': fields.Float(validate=lambda x: -180 <= x <= 180)
}
from marshmallow_enum import EnumField
from webargs import fields
from indico.legacy.common.cache import GenericCache
from indico.modules.rb.models.reservations import RepeatFrequency
_cache = GenericCache('Rooms')
search_room_args = {
'capacity': fields.Int(),
'equipment': fields.List(fields.Str()),
'features': fields.List(fields.Str(), data_key='feature'),
'favorite': fields.Bool(),
'mine': fields.Bool(),
'text': fields.Str(),
'division': fields.Str(),
'start_dt': fields.DateTime(),
'end_dt': fields.DateTime(),
'repeat_frequency': EnumField(RepeatFrequency),
'repeat_interval': fields.Int(missing=0),
'building': fields.Str(),
'sw_lat': fields.Float(validate=lambda x: -90 <= x <= 90),
'sw_lng': fields.Float(validate=lambda x: -180 <= x <= 180),
'ne_lat': fields.Float(validate=lambda x: -90 <= x <= 90),
'ne_lng': fields.Float(validate=lambda x: -180 <= x <= 180)
}
'return_optimal_sampling': wfields.Bool(missing=False),
'sampling_min_similarity': wfields.Number(missing=1.0),
'sampling_min_coverage': wfields.Number(missing=0.9)})
@marshal_with(ClusteringSchema())
def get(self, method, mid, **args):
return_optimal_sampling = args.pop('return_optimal_sampling')
sampling_min_coverage = args.pop('sampling_min_coverage')
sampling_min_similarity = args.pop('sampling_min_similarity')
cl = _ClusteringWrapper(cache_dir=self._cache_dir, mid=mid)
km = cl._load_model()
if return_optimal_sampling and not cl._pars['is_hierarchical']:
raise WrongParameter(('Model {} does not support optimal sampling,'
'please use hierarchical Birch clustering '
'(with n_clusters=-1)')
.format(type(km).__name__))