def test_by_symbol_active(): act = Short.create(symbol="act", target="act", active=True) ina = Short.create(symbol="ina", target="ina", active=False) assert Short.by_symbol_active("lol") is None assert Short.by_symbol_active("act") == act assert Short.by_symbol_active("ina") is None assert Short.by_symbol("ina") == ina
def short(symb): if is_botagent(request.user_agent): abort(403) item = Short.by_symbol_active(symb) if not item: abort(404) item.increase_visit() resp = make_response( render_template( "short.html", title=item.symbol, short=item, )) resp.headers.add("X-Robots-Tag", "noindex, nofollow") return resp