@register.inclusion_tag('laws/bill_inabox.html')
def bill_inabox(bill):
    """ TODO: firstX and not first3"""
    proposals = list(bill.proposals.all())

    proposers = bill.proposers.all()
    bill_inabox_dict = {
        'bill': bill,
        'billurl': 'http://oknesset.org%s' % bill.get_absolute_url(),
        'proposers_first3': proposers[:3],
        'proposers_count_minus3': len(proposers) - 3,
        'explanation': get_explanation(bill, proposals),
    }

    #proposal
    if proposals:
        proposal = proposals[-1]
        bill_inabox_dict['proposal'] = dict({'day' : proposal.date.day,
                           'month' : proposal.date.month,
                           'year' : proposal.date.year})


    #pre vote
    pre_votes = list(bill.pre_votes.all())
    pre_vote = None
    if pre_votes:
        pre_vote = pre_votes[-1]
        bill_inabox_dict['pre_vote'] = create_vote_dict(pre_vote)

    #first_committee_meetings
    cms = list(bill.first_committee_meetings.all())
    if cms:
        first_committee_meetings = cms[-1]
        bill_inabox_dict['first_committee_meetings'] = dict({'day' : first_committee_meetings.date.day,
                           'month' : first_committee_meetings.date.month,
                           'year' : first_committee_meetings.date.year,
                           'url' : first_committee_meetings.get_absolute_url()})

    #first vote
    fv = bill.first_vote
    if fv:
        bill_inabox_dict['first_vote'] = create_vote_dict(fv)

    #second_committee_meetings
    cms = list(bill.second_committee_meetings.all())
    if cms:
        second_committee_meetings = cms[-1]
        bill_inabox_dict['second_committee_meetings'] = dict({'day' : second_committee_meetings.date.day,
                           'month' : second_committee_meetings.date.month,
                           'year' : second_committee_meetings.date.year,
                           'url' : second_committee_meetings.get_absolute_url()})


    #second+third vote (approval_vote)
    av = bill.approval_vote
    if av:
        bill_inabox_dict['approval_vote'] = create_vote_dict(av)

    return bill_inabox_dict
dataset/ETHPy150Open ofri/Open-Knesset/laws/templatetags/bills_tags.py/bill_inabox/original