Permalink
Browse files

Killed an internal only class that wasn't serving much purpose.

  • Loading branch information...
alex committed Jun 4, 2010
1 parent f83932c commit 36c03cb40be243af3dd73fbff5bfda29a426468f
Showing with 28 additions and 35 deletions.
  1. +0 −29 brabeion/internals.py
  2. +21 −2 brabeion/models.py
  3. +7 −4 docs/models.txt
View
@@ -30,33 +30,4 @@ def possibly_award_badge(self, event, **state):
badge.possibly_award(**state)
-class AwardedBadge(object):
- def __init__(self, slug, level, user_id):
- self.slug = slug
- self.level = level
- self._user_id = user_id
- self._badge = badges._registry[slug]
-
- def __getattr__(self, attr):
- return getattr(self._badge, attr)
-
- @property
- def user(self):
- if not hasattr(self, "_user"):
- self._user = User.objects.get(pk=self._user_id)
- return self._user
-
- @property
- def name(self):
- return self._badge.levels[self.level].name
-
- @property
- def description(self):
- return self._badge.levels[self.level].description
-
- @property
- def progress(self):
- return self._badge.progress(self.user, self.level)
-
-
badges = BadgeCache()
View
@@ -12,7 +12,26 @@ class BadgeAward(models.Model):
slug = models.CharField(max_length=255)
level = models.IntegerField()
+ def __getattr__(self, attr):
+ return getattr(self._badge, attr)
+
@property
def badge(self):
- from brabeion.internals import AwardedBadge
- return AwardedBadge(self.slug, self.level, self.user_id)
+ return self
+
+ @property
+ def _badge(self):
+ from brabeion import badges
+ return badges._registry[self.slug]
+
+ @property
+ def name(self):
+ return self._badge.levels[self.level].name
+
+ @property
+ def description(self):
+ return self._badge.levels[self.level].description
+
+ @property
+ def progress(self):
+ return self._badge.progress(self.user, self.level)
View
@@ -17,8 +17,11 @@ Models in ``brabeion``
The slug for the ``Badge`` this refers to.
- .. attribute:: badge
+ .. attribute:: name
- An ``AwardedBadge`` object, which has the ``level``, ``name``, and
- ``description`` properties for the level of the ``Badge`` that it
- corropsonds to.
+ The name for the ``Badge`` this refers to, for the approrpiate level.
+
+ .. attribute:: description
+
+ The description for the ``Badge`` this refers to, for the approrpiate
+ level.

0 comments on commit 36c03cb

Please sign in to comment.