Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

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.

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.