-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #118 from HE-Arc/mbu-50-edit-routes-to-make-use-of…
…-the-users-account Mbu 50 edit routes to make use of the users account
- Loading branch information
Showing
19 changed files
with
214 additions
and
162 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,6 @@ | ||
from django.contrib import admin | ||
from django.contrib.auth.admin import UserAdmin | ||
from masteriqapp.models import CustomUser | ||
|
||
# Register your models here. | ||
admin.site.register(CustomUser, UserAdmin) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
29 changes: 0 additions & 29 deletions
29
api/masteriqapp/migrations/0006_alter_option_question_alter_option_text_and_more.py
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
from django.contrib.auth.models import AbstractUser | ||
from django.db import models | ||
from django.conf import settings | ||
|
||
|
||
class CustomUser(AbstractUser): | ||
iqs = models.ManyToManyField(settings.AUTH_USER_MODEL, through="IQ") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,3 +2,4 @@ | |
from .IQ import IQ | ||
from .Question import Question | ||
from .Option import Option | ||
from .CustomUser import CustomUser |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,11 @@ | ||
from django.contrib.auth import get_user_model | ||
from django.test import TestCase | ||
import django.apps | ||
|
||
from masteriqapp.models import Category | ||
from masteriqapp.models import IQ | ||
from masteriqapp.models import Question | ||
from masteriqapp.models import Option | ||
from django.contrib.auth.models import User | ||
|
||
|
||
class ModelTestCases(TestCase): | ||
|
@@ -24,20 +24,20 @@ def test_use_model(self): | |
option_1 = Option.objects.create(text="Yes", is_correct=False, question=question_test) | ||
option_2 = Option.objects.create(text="No", is_correct=True, question=question_test) | ||
|
||
user_test = User.objects.create_user("test", "[email protected]", "password") | ||
user_test = get_user_model().objects.create_user("test", "[email protected]", "password") | ||
|
||
iq_test = IQ.objects.create(user=user_test, category=category_test, iq=100) | ||
|
||
assert Category.objects.get(id=category_test.id).name == category_test.name | ||
assert Question.objects.get(id=question_test.id).text == question_test.text | ||
assert Option.objects.get(id=option_1.id).text == option_1.text | ||
assert len(Option.objects.filter(question=question_test)) == 2 | ||
assert User.objects.get(id=user_test.id).username == user_test.username | ||
assert get_user_model().objects.get(id=user_test.id).username == user_test.username | ||
assert len(IQ.objects.filter(user=user_test, category=category_test)) == 1 | ||
|
||
def test_use_manager(self): | ||
category_test = Category.objects.create(name="test_managers") | ||
user_test = User.objects.create_user("test_managers", "[email protected]", "password") | ||
user_test = get_user_model().objects.create_user("test_managers", "[email protected]", "password") | ||
iq_test = IQ.objects.create(user=user_test, category=category_test, iq = 102) | ||
|
||
leaderboard = IQ.objects.get_best_players_of_category(category=category_test) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.