예제 #1
0
 def thing_attr(self, thing, attr):
     if attr == "_fullname":
         return "LiveUpdateEvent_" + thing._id
     elif attr == "viewer_count":
         if thing.state == "live":
             return thing.active_visitors
         else:
             return None
     elif attr == "viewer_count_fuzzed":
         if thing.state == "live":
             return thing.active_visitors_fuzzed
         else:
             return None
     elif attr == "description_html":
         return filters.spaceCompress(
             filters.safemarkdown(thing.description, nofollow=True) or "")
     elif attr == "resources_html":
         return filters.spaceCompress(
             filters.safemarkdown(thing.resources, nofollow=True) or "")
     elif attr == "websocket_url":
         if thing.state == "live":
             return websockets.make_url(
                 "/live/" + thing._id, max_age=24 * 60 * 60)
         else:
             return None
     else:
         return ThingJsonTemplate.thing_attr(self, thing, attr)
예제 #2
0
 def thing_attr(self, thing, attr):
     if attr == "_fullname":
         return "LiveUpdateEvent_" + thing._id
     elif attr == "viewer_count":
         if thing.state == "live":
             return thing.active_visitors
         else:
             return None
     elif attr == "viewer_count_fuzzed":
         if thing.state == "live":
             return thing.active_visitors_fuzzed
         else:
             return None
     elif attr == "total_views":
         # this requires an extra query, so we'll only show it in places
         # where we're just getting one event.
         if not hasattr(thing, "total_views"):
             return None
         return thing.total_views
     elif attr == "description_html":
         return filters.spaceCompress(
             filters.safemarkdown(thing.description, nofollow=True) or "")
     elif attr == "resources_html":
         return filters.spaceCompress(
             filters.safemarkdown(thing.resources, nofollow=True) or "")
     elif attr == "websocket_url":
         if thing.state == "live":
             return websockets.make_url(
                 "/live/" + thing._id, max_age=24 * 60 * 60)
         else:
             return None
     else:
         return ThingJsonTemplate.thing_attr(self, thing, attr)
예제 #3
0
 def thing_attr(self, thing, attr):
     if attr == "_fullname":
         return "LiveUpdateEvent_" + thing._id
     elif attr == "viewer_count":
         if thing.state == "live":
             return thing.active_visitors
         else:
             return None
     elif attr == "viewer_count_fuzzed":
         if thing.state == "live":
             return thing.active_visitors_fuzzed
         else:
             return None
     elif attr == "description_html":
         return filters.spaceCompress(
             filters.safemarkdown(thing.description, nofollow=True) or "")
     elif attr == "resources_html":
         return filters.spaceCompress(
             filters.safemarkdown(thing.resources, nofollow=True) or "")
     elif attr == "websocket_url":
         if thing.state == "live":
             return websockets.make_url(
                 "/live/" + c.liveupdate_event._id, max_age=24 * 60 * 60)
         else:
             return None
     else:
         return ThingJsonTemplate.thing_attr(self, thing, attr)
예제 #4
0
 def thing_attr(self, thing, attr):
     if attr == "_fullname":
         return "LiveUpdateEvent_" + thing._id
     elif attr == "viewer_count":
         if thing.state == "live":
             return thing.active_visitors
         else:
             return None
     elif attr == "viewer_count_fuzzed":
         if thing.state == "live":
             return thing.active_visitors_fuzzed
         else:
             return None
     elif attr == "total_views":
         # this requires an extra query, so we'll only show it in places
         # where we're just getting one event.
         if not hasattr(thing, "total_views"):
             return None
         return thing.total_views
     elif attr == "description_html":
         return filters.spaceCompress(
             filters.safemarkdown(thing.description, nofollow=True) or "")
     elif attr == "resources_html":
         return filters.spaceCompress(
             filters.safemarkdown(thing.resources, nofollow=True) or "")
     elif attr == "websocket_url":
         if thing.state == "live":
             return websockets.make_url("/live/" + thing._id,
                                        max_age=24 * 60 * 60)
         else:
             return None
     else:
         return ThingJsonTemplate.thing_attr(self, thing, attr)
예제 #5
0
파일: pages.py 프로젝트: sol2tice/peachtree
 def thing_attr(self, thing, attr):
     if attr == "_fullname":
         return "LiveUpdateEvent_" + thing._id
     elif attr == "viewer_count":
         return thing.active_visitors
     elif attr == "viewer_count_fuzzed":
         return thing.active_visitors_fuzzed
     elif attr == "description_html":
         return filters.spaceCompress(
             filters.safemarkdown(thing.description) or "")
     else:
         return ThingJsonTemplate.thing_attr(self, thing, attr)
예제 #6
0
 def thing_attr(self, thing, attr):
     if attr == "_id":
         return str(thing._id)
     elif attr == "body_html":
         return filters.spaceCompress(filters.safemarkdown(thing.body, nofollow=True))
     elif attr == "author":
         if not thing.author.deleted:
             return thing.author.name
         else:
             return None
     elif attr == "stricken":
         return bool(thing.stricken)
     return ThingJsonTemplate.thing_attr(self, thing, attr)
예제 #7
0
 def thing_attr(self, thing, attr):
     if attr == "_id":
         return str(thing._id)
     elif attr == "body_html":
         return filters.spaceCompress(filters.safemarkdown(thing.body, nofollow=True))
     elif attr == "author":
         if not thing.author.deleted:
             return thing.author.name
         else:
             return None
     elif attr == "stricken":
         return bool(thing.stricken)
     return ThingJsonTemplate.thing_attr(self, thing, attr)
예제 #8
0
 def thing_attr(self, thing, attr):
     if attr == "_id":
         return str(thing._id)
     return ThingJsonTemplate.thing_attr(self, thing, attr)
예제 #9
0
 def thing_attr(self, thing, attr):
     if attr == "_id":
         return str(thing._id)
     elif attr == "body_html":
         return filters.spaceCompress(filters.safemarkdown(thing.body))
     return ThingJsonTemplate.thing_attr(self, thing, attr)