new migration to add wallet applet to dash db table; new views & html to accomodate

This commit is contained in:
Disco DeDisco
2026-03-08 15:27:24 -04:00
parent 076d75effe
commit ad0caa7c17
4 changed files with 43 additions and 2 deletions

View File

@@ -0,0 +1,18 @@
from django.db import migrations
def seed_wallet_applet(apps, schema_editor):
Applet = apps.get_model("dashboard", "Applet")
Applet.objects.get_or_create(
slug="wallet",
defaults={"name": "Wallet", "grid_cols": 12, "grid_rows": 3},
)
class Migration(migrations.Migration):
dependencies = [
("dashboard", "0006_rename_theme_switcher"),
]
operations = [
migrations.RunPython(seed_wallet_applet, migrations.RunPython.noop),
]

View File

@@ -439,3 +439,18 @@ class FooterNavTest(TestCase):
[nav] = parsed.cssselect("#id_footer_nav")
links = [a.get("href") for a in nav.cssselect("a")]
self.assertIn("/gameboard/", links)
class WalletAppletTest(TestCase):
def setUp(self):
self.user = User.objects.create(email="disco@test.io")
self.client.force_login(self.user)
Applet.objects.get_or_create(slug="wallet", defaults={"name": "Wallet"})
response = self.client.get("/")
self.parsed = lxml.html.fromstring(response.content)
def test_wallet_applet_present_on_dash(self):
[_] = self.parsed.cssselect("#id_applet_wallet")
def test_wallet_applet_has_manage_link(self):
[link] = self.parsed.cssselect("#id_applet_wallet a.wallet-manage-link")
self.assertEqual(link.get("href"), "/dashboard/wallet/")

View File

@@ -9,7 +9,7 @@ from apps.dashboard.models import Applet, Item, List, UserApplet
from apps.lyric.models import Token, User, Wallet
APPLET_ORDER = ["new-list", "my-lists", "username", "palette"]
APPLET_ORDER = ["wallet", "new-list", "my-lists", "username", "palette"]
UNLOCKED_PALETTES = frozenset(["palette-default"])
PALETTES = [
{"name": "palette-default", "label": "Earthman", "locked": False},

View File

@@ -27,7 +27,15 @@
{% for entry in applets %}
{% if entry.visible %}
{% if entry.applet.slug == "new-list" %}
{% if entry.applet.slug == "wallet" %}
<section
id="id_applet_wallet"
style="--applet-cols: {{ entry.applet.grid_cols }}; --applet-rows: {{ entry.applet.grid_rows }};"
>
<span>Writs: {{ user.wallet.writs }}</span>
<a href="{% url "wallet" %}" class="wallet-manage-link">Manage Wallet</a>
</section>
{% elif entry.applet.slug == "new-list" %}
<section
id="id_applet_new_list"
style="--applet-cols: {{ entry.applet.grid_cols }}; --applet-rows: {{ entry.applet.grid_rows }};"