Ejemplo n.º 1
0
 def data(self, karmas):
     from r2.lib.template_helpers import (display_comment_karma,
                                          display_link_karma)
     karmas = [{
         'sr': sr,
         'link_karma': display_link_karma(link_karma),
         'comment_karma': display_comment_karma(comment_karma),
     } for sr, (link_karma, comment_karma) in karmas.iteritems()]
     return karmas
Ejemplo n.º 2
0
 def data(self, karmas):
     from r2.lib.template_helpers import (
         display_comment_karma, display_link_karma)
     karmas = [{
         'sr': sr,
         'link_karma': display_link_karma(link_karma),
         'comment_karma': display_comment_karma(comment_karma),
     } for sr, (link_karma, comment_karma) in karmas.iteritems()]
     return karmas
Ejemplo n.º 3
0
    def data(self, karmas):
        from r2.lib.template_helpers import display_comment_karma, display_link_karma

        karmas = [
            {
                "sr": sr,
                "link_karma": display_link_karma(link_karma),
                "comment_karma": display_comment_karma(comment_karma),
            }
            for sr, (link_karma, comment_karma) in karmas.iteritems()
        ]
        return karmas
Ejemplo n.º 4
0
    def thing_attr(self, thing, attr):
        from r2.lib.template_helpers import display_comment_karma, display_link_karma

        if attr == "is_mod":
            t = thing.lookups[0] if isinstance(thing, Wrapped) else thing
            return t.is_moderator_somewhere
        elif attr == "has_mail":
            return bool(c.have_messages)
        elif attr == "has_mod_mail":
            return bool(c.have_mod_messages)
        elif attr == "comment_karma":
            return display_comment_karma(thing.comment_karma)
        elif attr == "link_karma":
            return display_link_karma(thing.link_karma)

        return ThingJsonTemplate.thing_attr(self, thing, attr)
Ejemplo n.º 5
0
    def thing_attr(self, thing, attr):
        from r2.lib.template_helpers import (display_comment_karma,
                                             display_link_karma)
        if attr == "is_mod":
            t = thing.lookups[0] if isinstance(thing, Wrapped) else thing
            return t.is_moderator_somewhere
        elif attr == "has_mail":
            return bool(c.have_messages)
        elif attr == "has_mod_mail":
            return bool(c.have_mod_messages)
        elif attr == "comment_karma":
            return display_comment_karma(thing.comment_karma)
        elif attr == "link_karma":
            return display_link_karma(thing.link_karma)

        return ThingJsonTemplate.thing_attr(self, thing, attr)
Ejemplo n.º 6
0
 def thing_attr(self, thing, attr):
     from r2.lib.template_helpers import (display_comment_karma,
                                          display_link_karma)
     if attr == "is_mod":
         t = thing.lookups[0] if isinstance(thing, Wrapped) else thing
         return t.is_moderator_somewhere
     elif attr == "has_mail":
         return bool(c.have_messages)
     elif attr == "has_mod_mail":
         return bool(c.have_mod_messages)
     elif attr == "comment_karma":
         return display_comment_karma(thing.comment_karma)
     elif attr == "link_karma":
         return display_link_karma(thing.link_karma)
     elif attr == "gold_expiration":
         if not thing.gold:
             return None
         return calendar.timegm(thing.gold_expiration.utctimetuple())
     return ThingJsonTemplate.thing_attr(self, thing, attr)
Ejemplo n.º 7
0
 def thing_attr(self, thing, attr):
     from r2.lib.template_helpers import (
         display_comment_karma, display_link_karma)
     if attr == "is_mod":
         t = thing.lookups[0] if isinstance(thing, Wrapped) else thing
         return t.is_moderator_somewhere
     elif attr == "has_mail":
         return bool(c.have_messages)
     elif attr == "has_mod_mail":
         return bool(c.have_mod_messages)
     elif attr == "comment_karma":
         return display_comment_karma(thing.comment_karma)
     elif attr == "link_karma":
         return display_link_karma(thing.link_karma)
     elif attr == "gold_expiration":
         if not thing.gold:
             return None
         return calendar.timegm(thing.gold_expiration.utctimetuple())
     return ThingJsonTemplate.thing_attr(self, thing, attr)