Esempio n. 1
0
def current_list(year=None):

    logger.debug("Current list endpoint called")
    
    bills = Bill.current_bills\
        .order_by(Bill.year.desc(), Bill.number.desc())

    return make_json_response(bills)
Esempio n. 2
0
def current_list(year=None):

    logger.debug("Current list endpoint called")

    bills = Bill.current_bills\
        .order_by(Bill.year.desc(), Bill.number.desc())

    return make_json_response(bills)
Esempio n. 3
0
def autodiscover():
    """
    Provide a landing page that documents the API endpoints that are available, and provides a link
    to the admin interface.
    """

    logger.debug("landing page called")

    return render_template('index.html')
Esempio n. 4
0
def autodiscover():
    """
    Provide a landing page that documents the API endpoints that are available, and provides a link
    to the admin interface.
    """

    logger.debug("landing page called")

    return render_template('index.html')
Esempio n. 5
0
def pmb_list(year=None):

    pmb = Bill.pmb\
        .filter(Bill.is_deleted==False)\
        .order_by(Bill.number.desc())

    logger.debug("PMB list endpoint called")
    if year:
        pmb = pmb.filter(Bill.year == int(year))
    return make_json_response(pmb)
Esempio n. 6
0
def pmb_list(year=None):

    pmb = Bill.pmb\
        .filter(Bill.is_deleted==False)\
        .order_by(Bill.number.desc())

    logger.debug("PMB list endpoint called")
    if year:
        pmb = pmb.filter(Bill.year==int(year))
    return make_json_response(pmb)
Esempio n. 7
0
def bill_list(year=None):

    logger.debug("Bill list endpoint called")
    bills = Bill.regular_bills\
        .filter(Bill.code.isnot(None))\
        .filter(Bill.is_deleted==False)\
        .order_by(Bill.year.desc(), Bill.number.desc())

    if year:
        bills = bills.filter(Bill.year == int(year))
    return make_json_response(bills)
Esempio n. 8
0
def bill_list(year=None):

    logger.debug("Bill list endpoint called")
    bills = Bill.regular_bills\
        .filter(Bill.code.isnot(None))\
        .filter(Bill.is_deleted==False)\
        .order_by(Bill.year.desc(), Bill.number.desc())

    if year:
        bills = bills.filter(Bill.year==int(year))
    return make_json_response(bills)
Esempio n. 9
0
 def default(self, obj):
     if isinstance(obj, (datetime, date)):
         encoded_obj = obj.strftime("%B %d, %Y")
     elif isinstance(obj, db.Model):
         try:
             encoded_obj = json.dumps(obj.to_dict(), cls=CustomEncoder, indent=4)
             logger.debug(encoded_obj)
         except Exception:
             encoded_obj = str(obj)
     else:
         encoded_obj = json.JSONEncoder.default(self, obj)
     return encoded_obj
Esempio n. 10
0
def draft_list(year=None):

    logger.debug("Draft list endpoint called")
    bills = Bill.draft_bills\
        .filter(Bill.is_deleted==False)\
        .order_by(Bill.number.desc())

    if year:
        bills = bills.filter(Bill.year == int(year))
        return make_json_response(bills, include_related=True)
    else:
        return make_json_response(bills)
Esempio n. 11
0
def draft_list(year=None):

    logger.debug("Draft list endpoint called")
    bills = Bill.draft_bills\
        .filter(Bill.is_deleted==False)\
        .order_by(Bill.number.desc())

    if year:
        bills = bills.filter(Bill.year==int(year))
        return make_json_response(bills, include_related=True)
    else:
        return make_json_response(bills)
Esempio n. 12
0
def bill_detail_from_code(bill_prefix, bill_year):

    logger.debug("Bill detail-from-code endpoint called")

    try:
        bill_year = int(bill_year)
        bill_code = bill_prefix.upper() + "-" + str(bill_year)
    except:
        abort(error_bad_request)

    bill = Bill.query.filter(Bill.code == bill_code).first()
    if not bill:
        abort(404)
    return make_json_response(bill, include_related=True)
Esempio n. 13
0
def bill_detail_from_code(bill_prefix, bill_year):

    logger.debug("Bill detail-from-code endpoint called")

    try:
        bill_year = int(bill_year)
        bill_code = bill_prefix.upper() + "-" + str(bill_year)
    except:
        abort(error_bad_request)

    bill = Bill.query.filter(Bill.code==bill_code).first()
    if not bill:
        abort(404)
    return make_json_response(bill, include_related=True)
Esempio n. 14
0
 def default(self, obj):
     if isinstance(obj, (datetime, date)):
         encoded_obj = obj.strftime("%B %d, %Y")
     elif isinstance(obj, db.Model):
         try:
             encoded_obj = json.dumps(obj.to_dict(),
                                      cls=CustomEncoder,
                                      indent=4)
             logger.debug(encoded_obj)
         except Exception:
             encoded_obj = str(obj)
     else:
         encoded_obj = json.JSONEncoder.default(self, obj)
     return encoded_obj
Esempio n. 15
0
def bill_detail(bill_id):

    logger.debug("Bill detail endpoint called")

    bill = Bill.query.get_or_404(bill_id)
    return make_json_response(bill, include_related=True)
Esempio n. 16
0
def bill_detail(bill_id):

    logger.debug("Bill detail endpoint called")

    bill = Bill.query.get_or_404(bill_id)
    return make_json_response(bill, include_related=True)