当前位置: 首页>>代码示例>>Python>>正文


Python Feed.register_feed方法代码示例

本文整理汇总了Python中events.models.Feed.register_feed方法的典型用法代码示例。如果您正苦于以下问题:Python Feed.register_feed方法的具体用法?Python Feed.register_feed怎么用?Python Feed.register_feed使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在events.models.Feed的用法示例。


在下文中一共展示了Feed.register_feed方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: bill_search_feed_title

# 需要导入模块: from events.models import Feed [as 别名]
# 或者: from events.models.Feed import register_feed [as 别名]
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)
        
开发者ID:coderich,项目名称:govtrack.us-web,代码行数:32,代码来源:models.py

示例2: is_recently_added

# 需要导入模块: from events.models import Feed [as 别名]
# 或者: from events.models.Feed import register_feed [as 别名]
    @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.",
    )
开发者ID:marcelor,项目名称:govtrack.us-web,代码行数:32,代码来源:models.py

示例3: VoteSummary

# 需要导入模块: from events.models import Feed [as 别名]
# 或者: from events.models.Feed import register_feed [as 别名]
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.",
    )
开发者ID:mleonhart,项目名称:govtrack.us-web,代码行数:32,代码来源:models.py

示例4: unicode

# 需要导入模块: from events.models import Feed [as 别名]
# 或者: from events.models.Feed import register_feed [as 别名]
	    # 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])),
开发者ID:thekalinga,项目名称:govtrack.us-web,代码行数:34,代码来源:models.py

示例5: create_events

# 需要导入模块: from events.models import Feed [as 别名]
# 或者: from events.models.Feed import register_feed [as 别名]
        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.",
    )
开发者ID:amitmse,项目名称:govtrack.us-web,代码行数:32,代码来源:models.py

示例6: summary_as_html

# 需要导入模块: from events.models import Feed [as 别名]
# 或者: from events.models.Feed import register_feed [as 别名]
    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.",
    )
开发者ID:govtrack,项目名称:govtrack.us-web,代码行数:32,代码来源:models.py


注:本文中的events.models.Feed.register_feed方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。