I can't just call badge.award_to(user) because I need to wait for the check logic to verify if the user should receive a badge or not.
My workaround is that I created a new table that inserts badge and user foreign keys and before the view is rendered I will check this table for any entries for that user. If there are, I will copy the data to a message and delete the object from the database again.
It's rather ugly due to the many database hits which I would like to avoid but I can't think of anything else at the moment. Apparently (using google) there is no way to get hold of the request in a post_save() signal - which I need to check all achievements.
The only real solution would be to not use this post_save() signal but manually do the checking for achievements before my view is rendered, which would require some work on the original source code. I will look into it though next week.
-- My workaround is that I created a new table that inserts badge and user foreign keys and before the view is rendered I will check this table for any entries for that user. If there are, I will copy the data to a message and delete the object from the database again.
It's rather ugly due to the many database hits which I would like to avoid but I can't think of anything else at the moment. Apparently (using google) there is no way to get hold of the request in a post_save() signal - which I need to check all achievements.
The only real solution would be to not use this post_save() signal but manually do the checking for achievements before my view is rendered, which would require some work on the original source code. I will look into it though next week.
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/ee9653c8-2c8e-479e-871b-34774862888b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
No comments:
Post a Comment