Commits

Paul McLanahan committed b9aa6e8

Moved register to top of module to avoid any confusion.

  • Participants
  • Parent commits a25b767

Comments (0)

Files changed (1)

File badges/utils.py

 
 registered_badges = {}
 
+def register(badge):
+    if badge.id not in registered_badges:
+        registered_badges[badge.id] = badge()
+    return badge
+
 
 class MetaBadgeMeta(type):
     
         new_badge = super(MetaBadgeMeta, cls).__new__(cls, name, bases, attrs)
         parents = [b for b in bases if isinstance(b, MetaBadgeMeta)]
         if not parents:
+            # If this isn't a subclass of MetaBadge, don't do anything special.
             return new_badge
         return register(new_badge)
 
         if self._test_conditions(instance):
             user = self.get_user(instance)
             self.badge.award_to(user)
-
-def register(badge):
-    if badge.id not in registered_badges:
-        registered_badges[badge.id] = badge()
-    return badge