new migration to add wallet applet to dash db table; new views & html to accomodate
This commit is contained in:
18
src/apps/dashboard/migrations/0007_seed_wallet_applet.py
Normal file
18
src/apps/dashboard/migrations/0007_seed_wallet_applet.py
Normal 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),
|
||||||
|
]
|
||||||
@@ -439,3 +439,18 @@ class FooterNavTest(TestCase):
|
|||||||
[nav] = parsed.cssselect("#id_footer_nav")
|
[nav] = parsed.cssselect("#id_footer_nav")
|
||||||
links = [a.get("href") for a in nav.cssselect("a")]
|
links = [a.get("href") for a in nav.cssselect("a")]
|
||||||
self.assertIn("/gameboard/", links)
|
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/")
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ from apps.dashboard.models import Applet, Item, List, UserApplet
|
|||||||
from apps.lyric.models import Token, User, Wallet
|
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"])
|
UNLOCKED_PALETTES = frozenset(["palette-default"])
|
||||||
PALETTES = [
|
PALETTES = [
|
||||||
{"name": "palette-default", "label": "Earthman", "locked": False},
|
{"name": "palette-default", "label": "Earthman", "locked": False},
|
||||||
|
|||||||
@@ -27,7 +27,15 @@
|
|||||||
|
|
||||||
{% for entry in applets %}
|
{% for entry in applets %}
|
||||||
{% if entry.visible %}
|
{% 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
|
<section
|
||||||
id="id_applet_new_list"
|
id="id_applet_new_list"
|
||||||
style="--applet-cols: {{ entry.applet.grid_cols }}; --applet-rows: {{ entry.applet.grid_rows }};"
|
style="--applet-cols: {{ entry.applet.grid_cols }}; --applet-rows: {{ entry.applet.grid_rows }};"
|
||||||
|
|||||||
Reference in New Issue
Block a user