def get_bill_info(request):
  if request.method == 'POST':
    from annotation_app.controllers import senators_controller,\
      subjects_controller
    import json

    bill = Bill.objects.get(id = request.POST['bill_id'])
    authors = bill.senator_set.all()
    subjects = bill.subject_set.all()

    if len(authors) == 0 or len(subjects) == 0:
      from annotation_app.helpers.bill_scrapers import scrape_bill_history

      bill_data = {}
      bill_data['session'] = bill.session
      bill_data['chamber_origin'] = bill.chamber_origin
      bill_data['number'] = bill.number

      tmi_data = scrape_bill_history(bill_data)

    if len(authors) == 0:
      authors = tmi_data['authors'].split(' | ')

      authors = map(lambda author:
        senators_controller.create(author, bill.id).name, authors)

    else:
      authors = map(lambda author: author.name, authors)

    if len(subjects) == 0:
      subjects = tmi_data['subjects']['subject']

      if type(subjects) != type([]):
        subjects = [subjects]

      subjects = map(lambda subject:
        subjects_controller.create(subject, bill.id).name, subjects)

    else:
      subjects = map(lambda subject: subject.name, subjects)

    data = {}
    data['authors'] = list(authors)
    data['subjects'] = list(subjects)

    return HttpResponse(json.dumps(data))
  else:
    return HttpResponse("{}")