def status(): return jsonify({ 'logged_in': authz.logged_in(), 'api_key': request.account.api_key if authz.logged_in() else None, 'account': request.account, 'base_url': url_for('index', _external=True) })
def status(): return jsonify( { "logged_in": authz.logged_in(), "api_key": request.account.api_key if authz.logged_in() else None, "account": request.account, "base_url": url_for("index", _external=True), } )
def lookup(dataset): dataset = Dataset.find(dataset) readonly = validators.StringBool(if_empty=False, if_missing=False)\ .to_python(request.args.get('readonly')) readonly = readonly if authz.logged_in() else True data = request_content() if response_format() != 'json': return Response("Not implemented!", status=400) try: alias = Alias.lookup(dataset, data, request.account, readonly=readonly) if alias is None: return jsonify({ 'is_matched': False, 'entity': None, 'name': data.get('name'), 'dataset': dataset.name }, status=404) if isinstance(alias, Entity): return jsonify({ 'is_matched': True, 'entity': alias, 'name': data.get('name'), 'dataset': dataset.name }, status=200) db.session.commit() status = 200 if alias.is_matched else 404 status = 418 if alias.is_invalid else status return jsonify(alias, status=status) except Invalid, inv: return handle_invalid(inv, index, data=data, args=[dataset.name])
def lookup(dataset): dataset = Dataset.find(dataset) readonly = validators.StringBool(if_empty=False, if_missing=False)\ .to_python(request.args.get('readonly')) readonly = readonly if authz.logged_in() else True data = request_content() if response_format() != 'json': return Response("Not implemented!", status=400) try: link = Link.lookup(dataset, data, request.account, readonly=readonly) if link is None: return jsonify({ 'is_matched': False, 'value': None, 'key': data.get('key'), 'dataset': dataset.name }, status=404) if isinstance(link, Value): add_candidate_to_cache(dataset, data.get('key'), link.id) return jsonify({ 'is_matched': True, 'value': link, 'key': data.get('key'), 'dataset': dataset.name }, status=200) if link.value: add_candidate_to_cache(dataset, link.key, link.value.id) db.session.commit() status = 200 if link.is_matched else 404 status = 418 if link.is_invalid else status return jsonify(link, status=status) except Invalid, inv: return handle_invalid(inv, index, data=data, args=[dataset.name])
def lookup(dataset): dataset = Dataset.find(dataset) readonly = validators.StringBool(if_empty=False, if_missing=False)\ .to_python(request.args.get('readonly')) readonly = readonly if authz.logged_in() else True data = request_content() if response_format() != 'json': return Response("Not implemented!", status=400) try: alias = Alias.lookup(dataset, data, request.account, readonly=readonly) if alias is None: return jsonify( { 'is_matched': False, 'entity': None, 'name': data.get('name'), 'dataset': dataset.name }, status=404) if isinstance(alias, Entity): return jsonify( { 'is_matched': True, 'entity': alias, 'name': data.get('name'), 'dataset': dataset.name }, status=200) db.session.commit() status = 200 if alias.is_matched else 404 status = 418 if alias.is_invalid else status return jsonify(alias, status=status) except Invalid, inv: return handle_invalid(inv, index, data=data, args=[dataset.name])
def logout(): authz.require(authz.logged_in()) session.clear() #flash("You've been logged out.", "success") return redirect(url_for('index'))
def status(): return jsonify({ 'logged_in': authz.logged_in(), 'api_key': request.account.api_key if authz.logged_in() else None, 'account': request.account })
def logout(): authz.require(authz.logged_in()) session.clear() return redirect('/')
def account(): authz.require(authz.logged_in()) return render_template("account.html", api_key=request.account.api_key)
def logout(): authz.require(authz.logged_in()) session.clear() flash("You've been logged out.", "success") return redirect(url_for('index'))
def account(): authz.require(authz.logged_in()) return render_template('account.html', api_key=request.account.api_key)