pre–db-reset commit; attempting to update User model w. uuid pk enumeration

This commit is contained in:
Disco DeDisco
2026-02-07 20:15:27 -05:00
parent 58b526f434
commit 0c413a9cc2
4 changed files with 11 additions and 2 deletions

View File

@@ -1,3 +1,4 @@
import lxml.html
from django.test import TestCase
from django.utils import html
from unittest import skip
@@ -6,7 +7,7 @@ from ..forms import (
EMPTY_ITEM_ERROR,
)
from ..models import Item, List
import lxml.html
from apps.lyric.models import User
class HomePageTest(TestCase):
def test_uses_home_template(self):
@@ -144,3 +145,9 @@ class ListViewTest(TestCase):
self.assertContains(response, expected_error)
self.assertTemplateUsed(response, "apps/dashboard/list.html")
self.assertEqual(Item.objects.all().count(), 1)
class MyListsTest(TestCase):
def test_my_lists_url_renders_my_lists_template(self):
user = User.objects.create(email="a@b.cde")
response = self.client.get(f"/apps/dashboard/users/{user.id}/")
self.assertTemplateUsed(response, "my-lists.html")

View File

@@ -4,4 +4,5 @@ from . import views
urlpatterns = [
path('new_list', views.new_list, name='new_list'),
path('<int:list_id>/', views.view_list, name='view_list'),
path('users/<uuid:user_id>/', views.my_lists, name='my_lists'),
]

View File

@@ -6,7 +6,7 @@ class Token(models.Model):
uid = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False)
class User(models.Model):
id = models.BigAutoField(primary_key=True)
id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False)
email = models.EmailField(unique=True)
REQUIRED_FIELDS = []

View File

@@ -18,6 +18,7 @@
<h1>Welcome, Earthman</h1>
</a>
{% if user.email %}
<a class="navbar-link" href="{% url 'my_lists' user.email %}">My lists</a>
<span class="navbar-text">Logged in as {{ user.email }}</span>
<form method="POST" action="{% url "logout" %}">
{% csrf_token %}