ulule / django-badgify

A reusable application to create your own badge engine using Django
MIT License
83 stars 15 forks source link

user_ids documentation is too vague #3

Closed bufke closed 9 years ago

bufke commented 9 years ago

Currently it says "QuerySet returning User IDs likely to be awarded."

"likely to be awarded" is vague and gives no indication of what this actually does. Perhaps something like

"Optional. If set, this QuerySet will be awarded the badge when the badgify_sync awards command is run"

It might be good to provide some ideas on how Awards are given - as I can tell manually or with badgify_sync awards.

bufke commented 9 years ago

Happy to make a pull request - I could use some guidance on confirming I understand things correctly. I am using a combination of user_ids and manual badge assignment like this

class MyRecipe(BaseRecipe):
    def __award_to(self, user):
        return Award.objects.get_or_create(user=user, badge=self.badge)[1]

    def award_to(self, user):
        """ Awards a badge to a user.
        Returns True if this is a new award creation """
        try:
            return self.__award_to(user)
        except ValueError:  # Just in case badge doesn't exist yet
            self.create_badge()
            return self.__award_to(user)

Might even make sense to commit award_to upstream here.

thoas commented 9 years ago

I'm not understanding your point, the documentation is clear enough in my side (you can correct me if I'm wrong).

You only have to define a user_ids method which returns a flat list of user ids and I will attach you badge automatically

thoas commented 9 years ago

see here