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


Python Person.from_feed方法代码示例

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


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

示例1: render_event

# 需要导入模块: from person.models import Person [as 别名]
# 或者: from person.models.Person import from_feed [as 别名]
    def render_event(self, eventid, feeds):
        if feeds:
            from person.models import Person
            my_reps = set()
            for f in feeds:
                try:
                    my_reps.add(Person.from_feed(f))
                except ValueError:
                    pass # not a person-related feed
            my_reps = sorted(my_reps, key = lambda p : p.sortname)
        else:
            my_reps = []

        # fetch the whole vote and our summary, and keep it cached with this object
        # because in email updates this object is held in memory for the duration of
        # sending out all email updates
        if not hasattr(self, "_cached_event_data"):
            oursummary = self.get_summary()
            all_votes = {
                vv.person: vv.option
                for vv in
                self.voters.select_related('person', 'option')
            }
            self._cached_event_data = [oursummary, all_votes]
        else:
            oursummary, all_votes = self._cached_event_data
        
        return {
            "type": "Vote",
            "date": self.created,
            "title": self.question,
            "url": self.get_absolute_url(),
            "body_text_template":
"""{{summary|safe}}
{% for voter in voters %}{{voter.name|safe}}: {{voter.vote|safe}}
{% endfor %}
{% if oursummary %}{{oursummary.plain_text|truncatewords:120|safe}}{% endif %}""",
            "body_html_template":
"""<p>{{summary}}</p>
{% for voter in voters %}
    <p><a href="{{SITE_ROOT}}{{voter.url}}">{{voter.name}}</a>: {{voter.vote}}</p>
{% endfor %}
{% if oursummary %}{{oursummary.as_html|truncatewords_html:120|safe}}{% endif %}
""",
            "context": {
                "summary": self.summary(),
                "oursummary": oursummary,
                "voters":
                            [
                                { "url": p.get_absolute_url(), "name": p.name_lastonly(), "vote": all_votes[p].value }
                                for p in my_reps if p in all_votes
                            ]
                        if feeds != None else []
                },
			"thumbnail_url": self.get_thumbnail_url(),
            }
开发者ID:govtrack,项目名称:govtrack.us-web,代码行数:58,代码来源:models.py

示例2: render_event

# 需要导入模块: from person.models import Person [as 别名]
# 或者: from person.models.Person import from_feed [as 别名]
    def render_event(self, eventid, feeds):
        if feeds:
            from person.models import Person
            my_reps = set()
            for f in feeds:
                try:
                    my_reps.add(Person.from_feed(f))
                except ValueError:
                    pass # not a person-related feed
            my_reps = sorted(my_reps, key = lambda p : p.sortname)
        else:
            my_reps = []

        oursummary = self.get_summary()

        # fetch the whole vote (don't restrict by my_reps in the hope of
        # making use of the db query cache)
        all_votes = {
            vv.person: vv.option
            for vv in
            self.voters.select_related('person', 'option')
        }
        
        return {
            "type": "Vote",
            "date": self.created,
            "title": self.question,
            "url": self.get_absolute_url(),
            "body_text_template":
"""{{summary|safe}}
{% for voter in voters %}{{voter.name|safe}}: {{voter.vote|safe}}
{% endfor %}
{% if oursummary %}{{oursummary.plain_text|truncatewords:120|safe}}{% endif %}""",
            "body_html_template":
"""<p>{{summary}}</p>
{% for voter in voters %}
    <p><a href="{{SITE_ROOT}}{{voter.url}}">{{voter.name}}</a>: {{voter.vote}}</p>
{% endfor %}
{% if oursummary %}{{oursummary.as_html|truncatewords_html:120|safe}}{% endif %}
""",
            "context": {
                "summary": self.summary(),
                "oursummary": oursummary,
                "voters":
                            [
                                { "url": p.get_absolute_url(), "name": p.name_lastonly(), "vote": all_votes[p].value }
                                for p in my_reps if p in all_votes
                            ]
                        if feeds != None else []
                }
            }
开发者ID:mleonhart,项目名称:govtrack.us-web,代码行数:53,代码来源:models.py

示例3: render_event

# 需要导入模块: from person.models import Person [as 别名]
# 或者: from person.models.Person import from_feed [as 别名]
    def render_event(self, eventid, feeds):
        if feeds:
            from person.models import Person
            my_reps = set()
            for f in feeds:
                try:
                    my_reps.add(Person.from_feed(f))
                except ValueError:
                    pass # not a person-related feed
            my_reps = sorted(my_reps, key = lambda p : p.sortname)
        else:
            my_reps = []

        try:
            oursummary = self.oursummary
        except VoteSummary.DoesNotExist:
            oursummary = None
        
        return {
            "type": "Vote",
            "date": self.created,
            "title": self.question,
            "url": self.get_absolute_url(),
            "body_text_template":
"""{{summary|safe}}
{% for voter in voters %}{{voter.name|safe}}: {{voter.vote|safe}}
{% endfor %}
{% if oursummary %}{{oursummary.plain_text|safe}}{% endif %}""",
            "body_html_template":
"""<p>{{summary}}</p>
{% for voter in voters %}
    <p><a href="{{SITE_ROOT}}{{voter.url}}">{{voter.name}}</a>: {{voter.vote}}</p>
{% endfor %}
{% if oursummary %}{{oursummary.as_html|safe}}{% endif %}
""",
            "context": {
                "summary": self.summary(),
                "oursummary": oursummary,
                "voters":
                            [
                                { "url": p.get_absolute_url(), "name": p.name_lastonly(), "vote": self.voters.get(person=p).option.value }
                                for p in my_reps if self.voters.filter(person=p).exists()
                            ]
                        if feeds != None else []
                }
            }
开发者ID:reidwooten99apps,项目名称:govtrack.us-web,代码行数:48,代码来源:models.py


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