Skip to content

Commit

Permalink
Feat: Remove user
Browse files Browse the repository at this point in the history
  • Loading branch information
SverreNystad committed Feb 29, 2024
1 parent f0134a0 commit 8a775f6
Show file tree
Hide file tree
Showing 12 changed files with 10 additions and 401 deletions.
6 changes: 3 additions & 3 deletions backend/api/urls.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
from django.urls import path

from users.views import login, register_user
# from users.views import login, register_user
from flashcards.views import create_flashcards, generate_mock_flashcard

urlpatterns = [
path("create-user/", register_user, name="create-user"),
path("login/", login, name="login"),
# path("create-user/", register_user, name="create-user"),
# path("login/", login, name="login"),
path("generate-mock-flashcard/", generate_mock_flashcard, name="generate-mock-flashcards"),
path("create-flashcards/", create_flashcards, name="create-flashcards"),
path("generate-mock-flashcard/", generate_mock_flashcard, name="generate-mock-flashcard"),
Expand Down
4 changes: 1 addition & 3 deletions backend/flashcards/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,7 @@ class Cardset(models.Model):
id = models.AutoField(primary_key=True)
name = models.CharField(max_length=100, help_text="The name of the cardset")
description = models.TextField(help_text="The description of the cardset")
user = models.ForeignKey(
"users.User", on_delete=models.CASCADE, help_text="The user to which the cardset belongs"
)


def __str__(self):
return self.name
22 changes: 2 additions & 20 deletions backend/flashcards/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

import os
from flashcards.models import Cardset, Flashcard
from users.models import User

# Create your tests here.

Expand Down Expand Up @@ -43,29 +42,12 @@ def test_get_flashcards_format(self):
self.assertIn("back", response.json()[0])

class testPersistantFlashcard(TestCase):

def setUp(self):
# This code will run before each test
self.user = User.objects.create_user(username="testuser", password="12345")
self.valid_username = "username"


def tearDown(self):
# This code will run after each test
self.user.delete()

def test_persistant_cardset(self):
self.assertTrue(Cardset.objects.count() == 0)

self.cardset = Cardset.objects.create(name="testcardset", description="testcardset", user=self.user)
self.assertTrue(Cardset.objects.count() == 1)

self.cardset.delete()

def test_persistant_flashcard(self):
self.assertTrue(Flashcard.objects.count() == 0)

self.cardset = Cardset.objects.create(name="testcardset", description="testcardset", user=self.user)
self.cardset = Cardset.objects.create(name="testcardset", description="testcardset")
self.card1 = Flashcard.objects.create(front="testfront", back="testback", cardset=self.cardset)
self.card2 = Flashcard.objects.create(front="testfront2", back="testback2", cardset=self.cardset)
self.assertTrue(Flashcard.objects.count() == 2)
Expand All @@ -75,7 +57,7 @@ def test_persistant_flashcard(self):
self.card2.delete()

def test_get_flashcards_from_cardset(self):
self.cardset = Cardset.objects.create(name="testcardset", description="testcardset", user=self.user)
self.cardset = Cardset.objects.create(name="testcardset", description="testcardset")
self.assertTrue(self.cardset.flashcard_set.all().count() == 0)

self.card1 = Flashcard.objects.create(front="testfront", back="testback", cardset=self.cardset)
Expand Down
9 changes: 4 additions & 5 deletions backend/tutorai/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
"drf_yasg",
# Own applications
"api",
"users",
# "users",
"flashcards",
]

Expand Down Expand Up @@ -100,15 +100,14 @@
}
}

AUTH_USER_MODEL = "users.User"
# AUTH_USER_MODEL = "users.User"

# Password validation
# https://docs.djangoproject.com/en/5.0/ref/settings/#auth-password-validators

AUTH_PASSWORD_VALIDATORS = [
{
"NAME": "django.contrib.auth.password_validation.UserAttributeSimilarityValidator",
},


{
"NAME": "django.contrib.auth.password_validation.MinimumLengthValidator",
},
Expand Down
Empty file removed backend/users/__init__.py
Empty file.
5 changes: 0 additions & 5 deletions backend/users/admin.py

This file was deleted.

6 changes: 0 additions & 6 deletions backend/users/apps.py

This file was deleted.

Empty file.
20 changes: 0 additions & 20 deletions backend/users/models.py

This file was deleted.

29 changes: 0 additions & 29 deletions backend/users/serializers.py

This file was deleted.

213 changes: 0 additions & 213 deletions backend/users/tests.py

This file was deleted.

Loading

0 comments on commit 8a775f6

Please sign in to comment.