Exemplo n.º 1
0
        for k in arguments.keys():
            arguments[k] = unicode(arguments[k])
        arguments = json.dumps(arguments)
        cls.objects.filter(game=game,
                           user_from=user_from,
                           user_to=user_to,
                           message_string=message,
                           arguments=arguments).delete()

    def __unicode__(self):
        return u"[%s] %s %s" % (self.game, self.user_from, self.user_to)


def save_activity_handler(sender, **kwargs):
    """ Callback function for addActivity signal """
    a = Activity()
    a.user_from = kwargs['user_from']
    a.user_to = kwargs.get('user_to', a.user_from)
    a.message_string = kwargs.get('message', '')
    a.action = kwargs.get('action', None)
    args = kwargs.get('arguments', {})
    for k in args.keys():
        args[k] = unicode(args[k])
    a.arguments = json.dumps(args)
    a.game = kwargs['game']
    a.public = kwargs.get('public', True)
    a.save()


addActivity.connect(save_activity_handler)
Exemplo n.º 2
0
    def get_private_activity(cls, player):
        return cls.objects.filter(user_from=player, public=False)

    @classmethod
    def delete(cls, game, user_from, user_to, message, arguments):
        """ Note: must be called with the _same_ arguments as the original to work """
        for k in arguments.keys():
            arguments[k] = unicode(arguments[k])
        arguments = json.dumps(arguments)
        cls.objects.filter(game=game, user_from=user_from, user_to=user_to, message_string=message, arguments=arguments).delete()

    def __unicode__(self):
        return u"[%s] %s %s" % (self.game, self.user_from, self.user_to)

def save_activity_handler(sender, **kwargs):
    """ Callback function for addActivity signal """
    a = Activity()
    a.user_from = kwargs['user_from']
    a.user_to = kwargs.get('user_to', a.user_from)
    a.message_string = kwargs.get('message', '')
    a.action = kwargs.get('action', None)
    args = kwargs.get('arguments', {})
    for k in args.keys():
        args[k] = unicode(args[k])
    a.arguments = json.dumps(args)
    a.game = kwargs['game']
    a.public = kwargs.get('public', True)
    a.save()

addActivity.connect(save_activity_handler)
Exemplo n.º 3
0
    @property
    def game_name(self):
        """ Returns the game name """
        return self.game.verbose_name

    @models.permalink
    def get_game_absolute_url(self):
        """ Returns the game url """
        if self.game:
            return (self.game.url, None)
        else:
            return (None, None)

    def __unicode__(self):
        return u"[%s] %s %s" % (self.game, self.user_from, self.user_to)

def addActivity_handler(sender, **kwargs):
    """ Callback function for addActivity signal """
    a = Activity()
    a.user_from = kwargs['user_from']
    a.user_to = kwargs['user_to']
    a.message_string = kwargs['message']
    args = kwargs.get('arguments', {})
    for k in args.keys():
        args[k] = unicode(args[k])
    a.arguments = json.dumps(args)
    a.game = kwargs['game']
    a.save()

addActivity.connect(addActivity_handler)