Skip to content

Commit

Permalink
Needs to support other objects besides django.contrib.auth.models.Use…
Browse files Browse the repository at this point in the history
…r ref pinax#1
  • Loading branch information
bahattincinic committed Jan 2, 2015
1 parent 676c3b0 commit 12f0332
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 3 deletions.
9 changes: 8 additions & 1 deletion brabeion/models.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
from django.contrib.auth.models import User
from django.db import models
from django.utils import timezone

try:
from django.contrib.auth import get_user_model
except ImportError:
# Prior to Django 1.5, the AUTH_USER_MODEL setting does not exist.
from django.contrib.auth.models import User
else:
User = get_user_model()


class BadgeAward(models.Model):
user = models.ForeignKey(User, related_name="badges_earned")
Expand Down
9 changes: 8 additions & 1 deletion brabeion/tests/models.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
from django.contrib.auth.models import User
from django.db import models

try:
from django.contrib.auth import get_user_model
except ImportError:
# Prior to Django 1.5, the AUTH_USER_MODEL setting does not exist.
from django.contrib.auth.models import User
else:
User = get_user_model()


class PlayerStat(models.Model):
user = models.OneToOneField(User, related_name="stats")
Expand Down
9 changes: 8 additions & 1 deletion brabeion/tests/tests.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,19 @@
from django.conf import settings
from django.contrib.auth.models import User
from django.db import connection
from django.test import TestCase

from brabeion import badges
from brabeion.base import Badge, BadgeAwarded
from brabeion.tests.models import PlayerStat

try:
from django.contrib.auth import get_user_model
except ImportError:
# Prior to Django 1.5, the AUTH_USER_MODEL setting does not exist.
from django.contrib.auth.models import User
else:
User = get_user_model()


class PointsBadge(Badge):
slug = "points"
Expand Down

0 comments on commit 12f0332

Please sign in to comment.