mobile dash layout provided; other styling inconsistencies corrected across views, scss & _applets.html template partial
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful

This commit is contained in:
Disco DeDisco
2026-03-07 00:05:32 -05:00
parent b5d6912b26
commit 13940ca834
7 changed files with 52 additions and 17 deletions

View File

@@ -1,5 +1,6 @@
from django.contrib import messages
from django.contrib.auth.decorators import login_required
from django.db.models import Max, Q
from django.http import HttpResponse, HttpResponseForbidden
from django.shortcuts import redirect, render
@@ -17,6 +18,16 @@ PALETTES = [
]
def _recent_lists(user, limit=3):
return (
List
.objects
.filter(Q(owner=user) | Q(shared_with=user))
.annotate(last_item=Max('item__id'))
.order_by('-last_item')
.distinct()[:limit]
)
def _applet_context(user):
ua_map = {ua.applet_id: ua.visible for ua in user.user_applets.all()}
applets = {a.slug: a for a in Applet.objects.all()}
@@ -26,10 +37,16 @@ def _applet_context(user):
if slug in applets
]
def home_page(request):
context = {"form": ItemForm(), "palettes": PALETTES, "page_class": "page-dashboard"}
context = {
"form": ItemForm(),
"palettes": PALETTES,
"page_class": "page-dashboard",
}
if request.user.is_authenticated:
context["applets"] = _applet_context(request.user)
context["recent_lists"] = _recent_lists(request.user)
return render(request, "apps/dashboard/home.html", context)
def new_list(request):
@@ -42,9 +59,14 @@ def new_list(request):
form.save(for_list=nulist)
return redirect(nulist)
else:
context = {"form": form, "palettes": PALETTES, "page_class": "page-dashboard"}
context = {
"form": form,
"palettes": PALETTES,
"page_class": "page-dashboard",
}
if request.user.is_authenticated:
context["applets"] = _applet_context(request.user)
context["recent_lists"] = _recent_lists(request.user)
return render(request, "apps/dashboard/home.html", context)
def view_list(request, list_id):
@@ -116,5 +138,6 @@ def toggle_applets(request):
"applets": _applet_context(request.user),
"palettes": PALETTES,
"form": ItemForm(),
"recent_lists": _recent_lists(request.user),
})
return redirect("home")

View File

@@ -1,5 +1,7 @@
from selenium.webdriver.common.by import By
from apps.lyric.models import User
class MyListsPage:
def __init__(self, test):
@@ -7,7 +9,10 @@ class MyListsPage:
def go_to_my_lists_page(self, email):
self.test.browser.get(self.test.live_server_url)
self.test.browser.find_element(By.LINK_TEXT, "My lists").click()
user = User.objects.get(email=email)
self.test.browser.get(
self.test.live_server_url + f'/dashboard/users/{user.id}/'
)
self.test.wait_for(
lambda: self.test.assertIn(
email,

View File

@@ -3,6 +3,7 @@ from selenium.webdriver.common.by import By
from .base import FunctionalTest
from .list_page import ListPage
from .my_lists_page import MyListsPage
from apps.lyric.models import User
class MyListsTest(FunctionalTest):
@@ -30,11 +31,10 @@ class MyListsTest(FunctionalTest):
list_page.add_list_item("Ribbon of death")
second_list_url = self.browser.current_url
self.browser.find_element(By.LINK_TEXT, "My lists").click()
MyListsPage(self).go_to_my_lists_page("disco@test.io")
self.wait_for(
lambda: self.browser.find_element(By.LINK_TEXT, "Ribbon of death")
)
MyListsPage(self).go_to_my_lists_page("disco@test.io")
self.browser.find_element(By.CSS_SELECTOR, "#id_logout").click()
self.wait_for(

View File

@@ -119,6 +119,12 @@ body.page-dashboard {
}
}
@container (max-width: 480px) {
section {
grid-column: span 12;
}
}
}
@media (max-height: 500px) {

View File

@@ -25,10 +25,10 @@
border-radius: 0.5rem;
background: linear-gradient(
to bottom,
rgba(var(--priUser), 1) 0%,
rgba(var(--priUser), 1) 33%,
rgba(var(--terUser), 1) 0%,
rgba(var(--terUser), 1) 33%,
rgba(var(--terUser), 1) 66%,
rgba(var(--priUser), 1) 33%,
rgba(var(--priUser), 1) 66%,
rgba(var(--quiUser), 1) 66%,
rgba(var(--quiUser), 1) 100%
);

View File

@@ -38,15 +38,17 @@
id="id_applet_my_lists"
style="--applet-cols: {{ entry.applet.grid_cols }}; --applet-rows: {{ entry.applet.grid_rows }};"
>
<a href="{% url 'my_lists' user.id %}">My lists:</a>
<ul>
{% for list in recent_lists %}
<li>
<a href="{{ list.get_absolute_url }}">{{ list.name }}</a>
</li>
{% empty %}
<li>No lists yet.</li>
{% endfor %}
</ul>
{% for list in user.lists.all %}
<li>
<a href="{{ list.get_absolute_url }}">{{ list.name }}</a>
</li>
{% endfor %}
{% for list in user.shared_lists.all %}
<li>
<a href="{{ list.get_absolute_url }}">{{ list.name }}</a>
</li>
{% endfor %}
</section>
{% elif entry.applet.slug == "username" %}

View File

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