Open askvictor opened 11 years ago
Crap; I seem to have stuffed up my PR. The two were different features. The use case for this one is along these lines:
That makes a lot of sense to me.
@lmorchard I haven't reached a good enough understanding of the django-badger architecture to know whether this makes sense or whether there's a better way to implement the use case. Can you take a look at this?
TL;DR: This looks good, but we might not want to merge it because I'd like to simplify the core badge model.
The issue is I could see a prereq feature growing for a lot of cases - eg. all prereqs, 3 of 5 prereqs, 1 required badge and 1 more from a set of choices, complex trees of preteqs, etc.
So, it occurs to me that this would work better in a per-app badges.py
as a signal handler, keeping the core model simpler. That is, remove the current prerequisite checking from the core model altogether. Then, subscribe to badge_was_awarded
in an app's badges.py
and do the prereq work there.
It might also be interesting if we had a place to grow "helpers" for badges.py
that offer common but optional nuggets of badge logic like this.
Perhaps provide two different levels of badges - a simple, stripped down version, and a more fully featured, customisable one? This might allow developers to do less coding in setting up a more complex badging system. Just a though - I guess I'd like to see how the signal/badges.py system would work.
As for more complex prerequisites (e.g. badge Q is prereqs: 1 required badge (badge A) + 1 out of a set of 3 ( badges X,Y,Z) )- this could be implemented without any extra code changes, by creating a tree of badges involving 'meta' badges (meta is probably the wrong term, but I'm basing it off dpkg meta packages), which are awarded but not displayed. So in the above example there'd be a meta badge W which has prereq 1 out of (X,Y,Z). Badge Q has pre-reqs both A and W. Not sure from an end-user perspective if this would be more or less confusing that alternatives.
This work seems to be done in pull #172, too. Are you looking to land both pull requests?