How to use the webargs.fields.Bool function in webargs

To help you get started, we’ve selected a few webargs examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github jacebrowning / memegen / memegen / routes / image.py View on Github external
@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))
github indico / indico / indico / modules / rb_new / controllers / backend.py View on Github external
        '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,
github fedspendingtransparency / data-act-broker-backend / dataactbroker / routes / file_routes.py View on Github external
        '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)
github indico / indico / indico / modules / auth / controllers.py View on Github external
        '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)
github gae-init / gae-init / main / util.py View on Github external
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:
github jacebrowning / memegen / memegen / routes / api_templates.py View on Github external
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'])
github indico / indico / indico / modules / rb_new / controllers / backend / common.py View on Github external
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)
}
github indico / indico / indico / modules / rb / controllers / backend / common.py View on Github external
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)
}
github FreeDiscovery / FreeDiscovery / freediscovery / server / resources.py View on Github external
               '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__))

webargs

Declarative parsing and validation of HTTP request objects, with built-in support for popular web frameworks, including Flask, Django, Bottle, Tornado, Pyramid, Falcon, and aiohttp.

MIT
Latest version published 2 months ago

Package Health Score

94 / 100
Full package analysis

Similar packages