how to award newly implemented badge to existing users

I have introduced two new badges and I have used the award_badges_signal method in def user_receive_reputation method to trigger these badges. The condition of these badges are very simple when user reach 10 karma points award a badge and when user reach 25 karma points award another badge.

Everything works fine but the problem is that old users who join the the system prior to implementing this button and have satisfy the condition will not get the badge until they get a new karma points. How can I award these badges to existing users who have reach the threshold.

Here is how I am awarding at the moment:

def user_receive_reputation(self, num_points, timestamp=None):
    new_points = self.reputation + num_points
    if new_points > 0:
        self.reputation = new_points
    else:
        self.reputation = const.MIN_REPUTATION
    if timestamp is None:
        timestamp = datetime.datetime.now()
    if self.reputation > 10:        
        award_badges_signal.send(None,
            event = 'reach_10_karma',
            actor = self,
            context_object = self,
            timestamp = timestamp
        )
    if self.reputation > 25:
        award_badges_signal.send(None,
            event = 'reach_25_karma',
            actor = self,
            context_object = self,
            timestamp = timestamp
        )

It would be a great help if someone could provide some help on this.

SocialQA's avatar
265
SocialQA
asked 2014-03-23 15:11:52 -0600
Evgeny's avatar
13.2k
Evgeny
updated 2014-03-24 19:35:05 -0600
edit flag offensive 0 remove flag close merge delete

Comments

1

I think it's better to have signal karma_changed and in the handler specify the points.

Evgeny's avatar Evgeny (2014-03-23 15:14:54 -0600) edit

@Evgeny could you provide an example?

SocialQA's avatar SocialQA (2014-03-23 15:20:14 -0600) edit

I have notice help is really hard to come by from askbot developers. Are we required to pay to get answers for the questions if so how?

SocialQA's avatar SocialQA (2014-03-23 15:32:14 -0600) edit
add a comment see more comments