示例#1
0
    @property
    def is_recently_added(self):
        return (self.created > (datetime.now() - timedelta(hours=36)))

    def abbrev_committee_name(self):
        return self.committee.sortname(True)

# feeds

from events.models import Feed, truncate_words
Feed.register_feed(
    "misc:allcommittee",
    title = "Committee Meetings",
    link = "/congress/committees",
    simple = True,
    sort_order = 103,
    category = "federal-committees",
    description = "Get an alert whenever a committee hearing or mark-up session is scheduled.",
    )
Feed.register_feed(
    "committee:",
    title = lambda feed : truncate_words(Committee.from_feed(feed).fullname, 12),
    noun = "committee",
    includes = lambda feed : [Committee.from_feed(feed).get_feed("bills"), Committee.from_feed(feed).get_feed("meetings")],
    link = lambda feed: Committee.from_feed(feed).get_absolute_url(),
    scoped_title = lambda feed : "All Events for This Committee",
    is_valid = lambda feed : Committee.from_feed(feed, test=True),
    category = "federal-committees",
    description = "You will get updates about major activity on bills referred to this commmittee plus notices of scheduled hearings and mark-up sessions.",
    )
示例#2
0
        if self.party == "Republican": return "Democrat"
        return None

    def get_sort_key(self):
        # As it happens, our enums define a good sort order between senators and representatives.
        return (self.role_type, self.senator_rank)

# Feeds

from events.models import Feed
Feed.register_feed(
    "p:",
    title = lambda feed : Person.from_feed(feed).name,
    noun = "person",
    includes = lambda feed : [Person.from_feed(feed).get_feed("pv"), Person.from_feed(feed).get_feed("ps")],
    link = lambda feed: Person.from_feed(feed).get_absolute_url(),
    scoped_title = lambda feed : "All Events for " + Person.from_feed(feed).lastname,
    category = "federal-other",
    description = "You will get updates about major activity on sponsored bills and how this Member of Congress votes in roll call votes.",
    is_subscribable = lambda feed : Person.from_feed(feed).get_current_role() is not None,
    track_button_noun = lambda feed : Person.from_feed(feed).him_her,
    )
Feed.register_feed(
    "ps:",
    title = lambda feed : Person.from_feed(feed).name + " - Bills Sponsored",
    noun = "person",
    link = lambda feed: Person.from_feed(feed).get_absolute_url(),
    scoped_title = lambda feed : Person.from_feed(feed).lastname + "'s Sponsored Bills",
    category = "federal-bills",
    description = "You will get updates about major activity on bills sponsored by this Member of Congress.",
    )
Feed.register_feed(
示例#3
0
def bill_search_feed_title(q):
    from search import bill_search_manager
    return "Bill Search - " + bill_search_manager().describe_qs(q)
def bill_search_feed_execute(q):
    from search import bill_search_manager
    from settings import CURRENT_CONGRESS
    
    bills = bill_search_manager().execute_qs(q, overrides={'congress': CURRENT_CONGRESS}).order_by("-current_status_date")[0:100] # we have to limit to make this reasonably fast
    
    def make_feed_name(bill):
        return "bill:" + BillType.by_value(bill.bill_type).xml_code + str(bill.congress) + "-" + str(bill.number)
    return Feed.objects.filter(feedname__in=[make_feed_name(bill) for bill in bills if bill != None]) # batch load
Feed.register_feed(
    "billsearch:",
    title = lambda feed : bill_search_feed_title(feed.feedname.split(":", 1)[1]),
    link = lambda feed : "/congress/bills/browse?" + feed.feedname.split(":", 1)[1],
    includes = lambda feed : bill_search_feed_execute(feed.feedname.split(":", 1)[1]),
    meta = True,
    )

# Summaries
class BillSummary(models.Model):
    bill = models.OneToOneField(Bill, related_name="oursummary", on_delete=models.PROTECT)
    created = models.DateTimeField(auto_now_add=True)
    modified = models.DateTimeField(auto_now=True)
    content = models.TextField(blank=True)
    
    def plain_text(self):
        import re
        content = re.sub("<br>|<li>", " \n ", self.content, re.I)
        
示例#4
0
	    # in other states too, so this would be incorrect for that. But
	    # we'd still like to know what is the current session.
	    if self.enddate == None:
	        # Not sure.
	        self.current = False
	        self.save()
	        return
	    self.current = not StateSession.objects.filter(state=self.state, startdate__gte=self.enddate).exists()
	    self.save()

from events.models import Feed
Feed.register_feed(
	"states_allbills",
	title = "State Legislation: All Activity",
	slug = "states_bills",
	intro_html = """Use this feed to track all legislative events in all United States state legislatures.""",
	simple = True,
	sort_order = 200,
	category = "state-bills",
	description = "Get an update on major activity on all state legislation.",
	)
for st in us.stateabbrs:
	Feed.register_feed(
		"states_%s_bills" % st,
		title = us.statenames[st] + " Legislation",
		link = "/states/%s" % st.lower(),
		category = "state-bills",
		description = "Get an update on major activity on all bills in this state.",
		)
Feed.register_feed(
	"states_bill:",
	title = lambda feed : unicode(StateBill.objects.get(id=feed.feedname.split(":")[1])),
示例#5
0
class VoteSummary(models.Model):
    vote = models.OneToOneField(Vote, related_name="oursummary", on_delete=models.PROTECT)
    created = models.DateTimeField(auto_now_add=True)
    modified = models.DateTimeField(auto_now=True)
    content = models.TextField(blank=True)

    def __str__(self): return "Summary for " + str(self.vote)
    def get_absolute_url(self): return self.vote.get_absolute_url()

    def as_html(self):
        return markdown2.markdown(self.content)

    def plain_text(self):
        # Kill links.
        import re
        content = re.sub("\[(.*?)\]\(.*?\)", r"\1", self.content)
        return content

# Feeds
from events.models import Feed
Feed.register_feed(
    "misc:allvotes",
    title = "Roll Call Votes",
    link = "/congress/votes",
    simple = True,
    single_event_type = True,
    sort_order = 101,
    category = "federal-votes",
    description = "You will get an alert for every roll call vote in Congress.",
    )
示例#6
0
    content = models.TextField(blank=True)

    def __str__(self):
        return "Summary for " + str(self.vote)

    def get_absolute_url(self):
        return self.vote.get_absolute_url()

    def as_html(self):
        return markdown2.markdown(self.content)

    def plain_text(self):
        # Kill links.
        import re
        content = re.sub("\[(.*?)\]\(.*?\)", r"\1", self.content)
        return content


# Feeds
from events.models import Feed
Feed.register_feed(
    "misc:allvotes",
    title="Roll Call Votes",
    link="/congress/votes",
    simple=True,
    single_event_type=True,
    sort_order=101,
    category="federal-votes",
    description="You will get an alert for every roll call vote in Congress.",
)
示例#7
0
        return None

    def create_events(self):
        from events.models import Feed, Event
        with Event.update(self) as E:
            feeds = [Feed.from_name("misc:govtrackinsider")]
            E.add("post", self.published, feeds)

    def render_event(self, eventid, feeds):
        return {
            "type": "GovTrack Insider",
            "date": self.published,
            "date_has_no_time": False,
            "title": self.title,
            "url": self.get_absolute_url(),
            "body_text_template": """{{snippet|safe}}""",
            "body_html_template": """<p>{{snippet}}</p>""",
            "context": {
                "snippet": self.snippet,
                }
            }

Feed.register_feed(
    "misc:govtrackinsider",
    title = "GovTrack Insider Articles",
    simple = True,
    slug = "govtrack-insider",
    intro_html = """<p>This feed includes posts on <a href="https://medium.com/govtrack-insider">GovTrack Insider</a>.</p>""",
    description = "Get an update whenever we post a new article on GovTrack Insider.",
    )
示例#8
0
        from events.models import Feed, Event
        with Event.update(self) as E:
            feeds = [Feed.from_name("misc:govtrackinsider")]
            E.add("post", self.published, feeds)

    def render_event(self, eventid, feeds):
        return {
            "type": "GovTrack Insider",
            "date": self.published,
            "date_has_no_time": False,
            "title": self.title,
            "url": self.get_absolute_url(),
            "body_text_template": """{{snippet|safe}}""",
            "body_html_template": """<p>{{snippet}}</p>""",
            "context": {
                "snippet": self.snippet,
            }
        }


Feed.register_feed(
    "misc:govtrackinsider",
    title="GovTrack Insider Articles",
    simple=True,
    slug="govtrack-insider",
    intro_html=
    """<p>This feed includes posts on <a href="https://medium.com/govtrack-insider">GovTrack Insider</a>.</p>""",
    description=
    "Get an update whenever we post a new article on GovTrack Insider.",
)
示例#9
0
    def is_recently_added(self):
        return (self.created > (datetime.now() - timedelta(hours=36)))

    def abbrev_committee_name(self):
        return self.committee.sortname(True)


# feeds

from events.models import Feed, truncate_words

Feed.register_feed(
    "misc:allcommittee",
    title="Committee Meetings",
    link="/congress/committees",
    simple=True,
    sort_order=103,
    category="federal-committees",
    description=
    "Get an alert whenever a committee hearing or mark-up session is scheduled.",
)
Feed.register_feed(
    "committee:",
    title=lambda feed: truncate_words(Committee.from_feed(feed).fullname, 12),
    noun="committee",
    includes=lambda feed: [
        Committee.from_feed(feed).get_feed("bills"),
        Committee.from_feed(feed).get_feed("meetings")
    ],
    link=lambda feed: Committee.from_feed(feed).get_absolute_url(),
    scoped_title=lambda feed: "All Events for This Committee",
    is_valid=lambda feed: Committee.from_feed(feed, test=True),
示例#10
0
    def summary_as_html(self):
        return markdown(self.summary)

    def summary_as_plain_text(self):
        # Make links nicer.
        return re.sub("\[(.*?)\]\(.*?\)", r"\1", self.summary)


from events.models import Feed
Feed.register_feed(
    "misc:oversight",
    title="Congressional Oversight & Investigations",
    simple=True,
    slug="oversight",
    intro_html=
    """<p>This feed includes all actions we are tracking on congressional oversight.</p>""",
    category="oversight",
    description=
    "You will get updates when there are major congressional actions related to oversight of the executive branch.",
)
Feed.register_feed(
    "oversight:",
    title=lambda feed: OversightTopic.from_feed(feed).title,
    noun="oversight topic",
    link=lambda feed: OversightTopic.from_feed(feed).get_absolute_url(),
    category="oversight",
    description=
    "You will get updates when there are major congressional actions related to this oversight topic.",
)
示例#11
0
            # Not sure.
            self.current = False
            self.save()
            return
        self.current = not StateSession.objects.filter(
            state=self.state, startdate__gte=self.enddate).exists()
        self.save()


from events.models import Feed
Feed.register_feed(
    "states_allbills",
    title="State Legislation: All Activity",
    slug="states_bills",
    intro_html=
    """Use this feed to track all legislative events in all United States state legislatures.""",
    simple=True,
    sort_order=200,
    category="state-bills",
    description="Get an update on major activity on all state legislation.",
)
for st in us.stateabbrs:
    Feed.register_feed(
        "states_%s_bills" % st,
        title=us.statenames[st] + " Legislation",
        link="/states/%s" % st.lower(),
        category="state-bills",
        description=
        "Get an update on major activity on all bills in this state.",
    )
Feed.register_feed(
示例#12
0
    updated = models.DateTimeField(db_index=True, auto_now=True, help_text="The date the oversight topic's metadata/summary was last updated.")

    class Meta:
        ordering = ["-created"] # controls order on topic pages

    def summary_as_html(self):
        return markdown(self.summary)

    def summary_as_plain_text(self):
        # Make links nicer.
        return re.sub("\[(.*?)\]\(.*?\)", r"\1", self.summary)

from events.models import Feed
Feed.register_feed(
    "misc:oversight",
    title = "Congressional Oversight & Investigations",
    simple = True,
    slug = "oversight",
    intro_html = """<p>This feed includes all actions we are tracking on congressional oversight.</p>""",
    category = "oversight",
    description = "You will get updates when there are major congressional actions related to oversight of the executive branch.",
    )
Feed.register_feed(
    "oversight:",
    title = lambda feed : OversightTopic.from_feed(feed).title,
    noun = "oversight topic",
    link = lambda feed: OversightTopic.from_feed(feed).get_absolute_url(),
    category = "oversight",
    description = "You will get updates when there are major congressional actions related to this oversight topic.",
    )