コード例 #1
0
ファイル: views.py プロジェクト: thekalinga/govtrack.us-web
 def build_info():
     feeds = [f for f in Feed.get_simple_feeds() if f.category == "federal-bills"]
     
     groups = [
         (   g[0], # title
             g[1], # text 1
             g[2], # text 2
             "/congress/bills/browse?status=" + ",".join(str(s) for s in g[4]), # link
            load_bill_status_qs(g[4]).count(), # count in category
            load_bill_status_qs(g[4]).order_by('-current_status_date')[0:6], # top 6 in this category
             )
         for g in bill_status_groups ]
         
     dhg_bills = Bill.objects.filter(congress=CURRENT_CONGRESS, docs_house_gov_postdate__gt=datetime.datetime.now() - datetime.timedelta(days=10)).filter(docs_house_gov_postdate__gt=F('current_status_date'))
     sfs_bills = Bill.objects.filter(congress=CURRENT_CONGRESS, senate_floor_schedule_postdate__gt=datetime.datetime.now() - datetime.timedelta(days=5)).filter(senate_floor_schedule_postdate__gt=F('current_status_date'))
     coming_up = list(dhg_bills | sfs_bills)
     coming_up.sort(key = lambda b : b.docs_house_gov_postdate if (b.docs_house_gov_postdate and (not b.senate_floor_schedule_postdate or b.senate_floor_schedule_postdate < b.docs_house_gov_postdate)) else b.senate_floor_schedule_postdate, reverse=True)
     
     start, end = get_congress_dates(CURRENT_CONGRESS)
     end_year = end.year if end.month > 1 else end.year-1 # count January finishes as the prev year
     current_congress_years = '%d-%d' % (start.year, end.year)
     current_congress = ordinal(CURRENT_CONGRESS)
     
     return {
         "feeds": feeds,
         
         "total": Bill.objects.filter(congress=CURRENT_CONGRESS).count(),
         "current_congress_years": current_congress_years,
         "current_congress": current_congress,
         "groups": groups,
         "coming_up": coming_up,
         "subjects": subject_choices(),
         "BILL_STATUS_INTRO": (BillStatus.introduced, BillStatus.referred, BillStatus.reported),
     }
コード例 #2
0
    def build_info():
        feeds = [f for f in Feed.get_simple_feeds() if f.category == "federal-bills"]

        groups = [
            (   g[0], # title
                g[1], # text 1
                g[2], # text 2
                "/congress/bills/browse?status=" + ",".join(str(s) for s in g[4]), # link
               load_bill_status_qs(g[4]).count(), # count in category
               load_bill_status_qs(g[4]).order_by('-current_status_date')[0:6], # top 6 in this category
                )
            for g in bill_status_groups ]

        dhg_bills = Bill.objects.filter(congress=CURRENT_CONGRESS, docs_house_gov_postdate__gt=datetime.datetime.now() - datetime.timedelta(days=10)).filter(docs_house_gov_postdate__gt=F('current_status_date'))
        sfs_bills = Bill.objects.filter(congress=CURRENT_CONGRESS, senate_floor_schedule_postdate__gt=datetime.datetime.now() - datetime.timedelta(days=5)).filter(senate_floor_schedule_postdate__gt=F('current_status_date'))
        coming_up = list(dhg_bills | sfs_bills)
        coming_up.sort(key = lambda b : b.docs_house_gov_postdate if (b.docs_house_gov_postdate and (not b.senate_floor_schedule_postdate or b.senate_floor_schedule_postdate < b.docs_house_gov_postdate)) else b.senate_floor_schedule_postdate, reverse=True)

        start, end = get_congress_dates(CURRENT_CONGRESS)
        end_year = end.year if end.month > 1 else end.year-1 # count January finishes as the prev year
        current_congress_years = '%d-%d' % (start.year, end.year)
        current_congress = ordinal(CURRENT_CONGRESS)

        return {
            "feeds": feeds,

            "total": Bill.objects.filter(congress=CURRENT_CONGRESS).count(),
            "current_congress_years": current_congress_years,
            "current_congress": current_congress,
            "groups": groups,
            "coming_up": coming_up,
            "subjects": subject_choices(),
            "BILL_STATUS_INTRO": (BillStatus.introduced, BillStatus.referred, BillStatus.reported),
        }
コード例 #3
0
    def build_info():
        # feeds about all legislation that we offer the user to subscribe to
        feeds = [
            f for f in Feed.get_simple_feeds() if f.category == "federal-bills"
        ]

        # info about bills by status
        groups = [
            (
                g[0],  # title
                g[1],  # text 1
                g[2],  # text 2
                "/congress/bills/browse?status=" +
                ",".join(str(s)
                         for s in g[4]) + "&sort=-current_status_date",  # link
                load_bill_status_qs(g[4]).count(),  # count in category
                load_bill_status_qs(g[4]).order_by(
                    '-current_status_date')[0:6],  # top 6 in this category
            ) for g in bill_status_groups
        ]

        # legislation coming up
        dhg_bills = Bill.objects.filter(
            congress=CURRENT_CONGRESS,
            docs_house_gov_postdate__gt=datetime.datetime.now() -
            datetime.timedelta(days=10)).filter(
                docs_house_gov_postdate__gt=F('current_status_date'))
        sfs_bills = Bill.objects.filter(
            congress=CURRENT_CONGRESS,
            senate_floor_schedule_postdate__gt=datetime.datetime.now() -
            datetime.timedelta(days=5)).filter(
                senate_floor_schedule_postdate__gt=F('current_status_date'))
        coming_up = list(
            (dhg_bills | sfs_bills).order_by('scheduled_consideration_date'))

        # top tracked bills
        top_bills = Feed.objects\
            .filter(feedname__startswith='bill:')\
            .filter(feedname__regex='^bill:[hs][jcr]?%d-' % CURRENT_CONGRESS)
        top_bills = top_bills\
            .annotate(count=Count('tracked_in_lists'))\
            .order_by('-count')\
            .values('feedname', 'count')\
            [0:25]
        top_bills = [(Bill.from_feed(Feed.from_name(bf["feedname"])),
                      bf["count"]) for bf in top_bills]

        return {
            "feeds": feeds,
            "total": Bill.objects.filter(congress=CURRENT_CONGRESS).count(),
            "current_congress": CURRENT_CONGRESS,
            "current_congress_dates": get_congress_dates(CURRENT_CONGRESS),
            "groups": groups,
            "coming_up": coming_up,
            "top_tracked_bills": top_bills,
            "subjects": subject_choices(),
            "BILL_STATUS_INTRO": (BillStatus.introduced, BillStatus.reported),
        }
コード例 #4
0
ファイル: views.py プロジェクト: marcelor/govtrack.us-web
    def build_info():
        # feeds about all legislation that we offer the user to subscribe to
        feeds = [f for f in Feed.get_simple_feeds() if f.category == "federal-bills"]

        # info about bills by status
        groups = [
            (   g[0], # title
                g[1], # text 1
                g[2], # text 2
                "/congress/bills/browse?status=" + ",".join(str(s) for s in g[4]) + "&sort=-current_status_date", # link
               load_bill_status_qs(g[4]).count(), # count in category
               load_bill_status_qs(g[4]).order_by('-current_status_date')[0:6], # top 6 in this category
                )
            for g in bill_status_groups ]

        # legislation coming up
        dhg_bills = Bill.objects.filter(congress=CURRENT_CONGRESS, docs_house_gov_postdate__gt=datetime.datetime.now() - datetime.timedelta(days=10)).filter(docs_house_gov_postdate__gt=F('current_status_date'))
        sfs_bills = Bill.objects.filter(congress=CURRENT_CONGRESS, senate_floor_schedule_postdate__gt=datetime.datetime.now() - datetime.timedelta(days=5)).filter(senate_floor_schedule_postdate__gt=F('current_status_date'))
        coming_up = list(dhg_bills | sfs_bills)
        coming_up.sort(key = lambda b : b.docs_house_gov_postdate if (b.docs_house_gov_postdate and (not b.senate_floor_schedule_postdate or b.senate_floor_schedule_postdate < b.docs_house_gov_postdate)) else b.senate_floor_schedule_postdate, reverse=True)

        # top tracked bills
        top_bills = Feed.objects\
            .filter(feedname__startswith='bill:')\
            .filter(feedname__regex='^bill:[hs][jcr]?%d-' % CURRENT_CONGRESS)
        top_bills = top_bills\
            .annotate(count=Count('tracked_in_lists'))\
            .order_by('-count')\
            .values('feedname', 'count')\
            [0:25]
        top_bills = [(Bill.from_feed(Feed.from_name(bf["feedname"])), bf["count"]) for bf in top_bills]

        # current congrss years
        start, end = get_congress_dates(CURRENT_CONGRESS)
        end_year = end.year if end.month > 1 else end.year-1 # count January finishes as the prev year
        current_congress_years = '%d-%d' % (start.year, end.year)
        current_congress = ordinal(CURRENT_CONGRESS)

        return {
            "feeds": feeds,

            "total": Bill.objects.filter(congress=CURRENT_CONGRESS).count(),
            "current_congress_years": current_congress_years,
            "current_congress": current_congress,

            "groups": groups,
            "coming_up": coming_up,
            "top_tracked_bills": top_bills,

            "subjects": subject_choices(),
            "BILL_STATUS_INTRO": (BillStatus.introduced, BillStatus.referred, BillStatus.reported),
        }
コード例 #5
0
ファイル: views.py プロジェクト: govtrack/govtrack.us-web
    def build_info():
        # feeds about all legislation that we offer the user to subscribe to
        feeds = [f for f in Feed.get_simple_feeds() if f.category == "federal-bills"]

        # info about bills by status
        groups = [
            (   g[0], # title
                g[1], # text 1
                g[2], # text 2
                "/congress/bills/browse?status=" + ",".join(str(s) for s in g[4]) + "&sort=-current_status_date", # link
               load_bill_status_qs(g[4]).count(), # count in category
               load_bill_status_qs(g[4]).order_by('-current_status_date')[0:6], # top 6 in this category
                )
            for g in bill_status_groups ]

        # legislation coming up
        dhg_bills = Bill.objects.filter(congress=CURRENT_CONGRESS, docs_house_gov_postdate__gt=datetime.datetime.now() - datetime.timedelta(days=10)).filter(docs_house_gov_postdate__gt=F('current_status_date'))
        sfs_bills = Bill.objects.filter(congress=CURRENT_CONGRESS, senate_floor_schedule_postdate__gt=datetime.datetime.now() - datetime.timedelta(days=5)).filter(senate_floor_schedule_postdate__gt=F('current_status_date'))
        coming_up = list((dhg_bills | sfs_bills).order_by('scheduled_consideration_date'))

        # top tracked bills
        top_bills = Feed.objects\
            .filter(feedname__startswith='bill:')\
            .filter(feedname__regex='^bill:[hs][jcr]?%d-' % CURRENT_CONGRESS)
        top_bills = top_bills\
            .annotate(count=Count('tracked_in_lists'))\
            .order_by('-count')\
            .values('feedname', 'count')\
            [0:25]
        top_bills = [(Bill.from_feed(Feed.from_name(bf["feedname"])), bf["count"]) for bf in top_bills]

        # trending bills
        trf = Feed.get_trending_feeds()
        trf = [Feed.objects.get(id=f) for f in trf]
        trending_bill_feeds = [f for f in trf if f.feedname.startswith("bill:")]

        return {
            "feeds": feeds,

            "total": Bill.objects.filter(congress=CURRENT_CONGRESS).count(),
            "current_congress": CURRENT_CONGRESS,
            "current_congress_dates": get_congress_dates(CURRENT_CONGRESS),

            "groups": groups,
            "coming_up": coming_up,
            "top_tracked_bills": top_bills,
            "trending_bill_feeds": trending_bill_feeds,

            "subjects": subject_choices(),
            "BILL_STATUS_INTRO": (BillStatus.introduced, BillStatus.reported),
        }
コード例 #6
0
    def build_info():
        # feeds about all legislation that we offer the user to subscribe to
        feeds = [
            f for f in Feed.get_simple_feeds() if f.category == "federal-bills"
        ]

        # info about bills by status
        groups = [
            (
                g[0],  # title
                g[1],  # text 1
                g[2],  # text 2
                "/congress/bills/browse?status=" +
                ",".join(str(s)
                         for s in g[4]) + "&sort=-current_status_date",  # link
                load_bill_status_qs(g[4]).count(),  # count in category
                load_bill_status_qs(g[4]).order_by(
                    '-current_status_date')[0:6],  # top 6 in this category
            ) for g in bill_status_groups
        ]

        # legislation coming up
        dhg_bills = Bill.objects.filter(
            congress=CURRENT_CONGRESS,
            docs_house_gov_postdate__gt=datetime.datetime.now() -
            datetime.timedelta(days=10)).filter(
                docs_house_gov_postdate__gt=F('current_status_date'))
        sfs_bills = Bill.objects.filter(
            congress=CURRENT_CONGRESS,
            senate_floor_schedule_postdate__gt=datetime.datetime.now() -
            datetime.timedelta(days=5)).filter(
                senate_floor_schedule_postdate__gt=F('current_status_date'))
        coming_up = list(dhg_bills | sfs_bills)
        coming_up.sort(
            key=lambda b: b.docs_house_gov_postdate
            if (b.docs_house_gov_postdate and
                (not b.senate_floor_schedule_postdate or b.
                 senate_floor_schedule_postdate < b.docs_house_gov_postdate))
            else b.senate_floor_schedule_postdate,
            reverse=True)

        # top tracked bills
        top_bills = Feed.objects\
            .filter(feedname__startswith='bill:')\
            .filter(feedname__regex='^bill:[hs][jcr]?%d-' % CURRENT_CONGRESS)
        top_bills = top_bills\
            .annotate(count=Count('tracked_in_lists'))\
            .order_by('-count')\
            .values('feedname', 'count')\
            [0:25]
        top_bills = [(Bill.from_feed(Feed.from_name(bf["feedname"])),
                      bf["count"]) for bf in top_bills]

        # current congrss years
        start, end = get_congress_dates(CURRENT_CONGRESS)
        end_year = end.year if end.month > 1 else end.year - 1  # count January finishes as the prev year
        current_congress_years = '%d-%d' % (start.year, end.year)
        current_congress = ordinal(CURRENT_CONGRESS)

        return {
            "feeds":
            feeds,
            "total":
            Bill.objects.filter(congress=CURRENT_CONGRESS).count(),
            "current_congress_years":
            current_congress_years,
            "current_congress":
            current_congress,
            "groups":
            groups,
            "coming_up":
            coming_up,
            "top_tracked_bills":
            top_bills,
            "subjects":
            subject_choices(),
            "BILL_STATUS_INTRO":
            (BillStatus.introduced, BillStatus.referred, BillStatus.reported),
        }