fixed applet seeding in 0005 migration; many FTs & ITs now require authentication before they pass; New List & My Lists converted to dash applets; home.html offloaded and _applets.html onboarded w. these applets
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
This commit is contained in:
@@ -4,6 +4,8 @@ from django.db import migrations
|
|||||||
def set_grid_defaults(apps, schema_editor):
|
def set_grid_defaults(apps, schema_editor):
|
||||||
Applet = apps.get_model("dashboard", "Applet")
|
Applet = apps.get_model("dashboard", "Applet")
|
||||||
Applet.objects.filter(slug__in=["username", "palette"]).update(grid_cols=6, grid_rows=3)
|
Applet.objects.filter(slug__in=["username", "palette"]).update(grid_cols=6, grid_rows=3)
|
||||||
|
Applet.objects.get_or_create(slug="new-list", defaults={"name": "New List", "grid_cols": 9, "grid_rows": 3})
|
||||||
|
Applet.objects.get_or_create(slug="my-lists", defaults={"name": "My Lists", "grid_cols": 3, "grid_rows": 3})
|
||||||
|
|
||||||
class Migration(migrations.Migration):
|
class Migration(migrations.Migration):
|
||||||
dependencies = [
|
dependencies = [
|
||||||
|
|||||||
@@ -14,6 +14,11 @@ from apps.lyric.models import User
|
|||||||
|
|
||||||
|
|
||||||
class HomePageTest(TestCase):
|
class HomePageTest(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="new-list", defaults={"name": "New List"})
|
||||||
|
|
||||||
def test_uses_home_template(self):
|
def test_uses_home_template(self):
|
||||||
response = self.client.get('/')
|
response = self.client.get('/')
|
||||||
self.assertTemplateUsed(response, 'apps/dashboard/home.html')
|
self.assertTemplateUsed(response, 'apps/dashboard/home.html')
|
||||||
@@ -28,8 +33,12 @@ class HomePageTest(TestCase):
|
|||||||
self.assertIn("text", [input.get("name") for input in inputs])
|
self.assertIn("text", [input.get("name") for input in inputs])
|
||||||
|
|
||||||
class NewListTest(TestCase):
|
class NewListTest(TestCase):
|
||||||
|
def setUp(self):
|
||||||
|
user = User.objects.create(email="disco@test.io")
|
||||||
|
self.client.force_login(user)
|
||||||
|
|
||||||
def test_can_save_a_POST_request(self):
|
def test_can_save_a_POST_request(self):
|
||||||
self. client.post("/dashboard/new_list", data={"text": "A new list item"})
|
self.client.post("/dashboard/new_list", data={"text": "A new list item"})
|
||||||
self.assertEqual(Item.objects.count(), 1)
|
self.assertEqual(Item.objects.count(), 1)
|
||||||
new_item = Item.objects.get()
|
new_item = Item.objects.get()
|
||||||
self.assertEqual(new_item.text, "A new list item")
|
self.assertEqual(new_item.text, "A new list item")
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ from apps.dashboard.models import Applet, Item, List, UserApplet
|
|||||||
from apps.lyric.models import User
|
from apps.lyric.models import User
|
||||||
|
|
||||||
|
|
||||||
|
APPLET_ORDER = ["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},
|
||||||
@@ -18,9 +19,11 @@ PALETTES = [
|
|||||||
|
|
||||||
def _applet_context(user):
|
def _applet_context(user):
|
||||||
ua_map = {ua.applet_id: ua.visible for ua in user.user_applets.all()}
|
ua_map = {ua.applet_id: ua.visible for ua in user.user_applets.all()}
|
||||||
|
applets = {a.slug: a for a in Applet.objects.all()}
|
||||||
return [
|
return [
|
||||||
{"applet": applet, "visible": ua_map.get(applet.pk, applet.default_visible)}
|
{"applet": applets[slug], "visible": ua_map.get(applets[slug].pk, applets[slug].default_visible)}
|
||||||
for applet in Applet.objects.all()
|
for slug in APPLET_ORDER
|
||||||
|
if slug in applets
|
||||||
]
|
]
|
||||||
|
|
||||||
def home_page(request):
|
def home_page(request):
|
||||||
@@ -39,7 +42,10 @@ def new_list(request):
|
|||||||
form.save(for_list=nulist)
|
form.save(for_list=nulist)
|
||||||
return redirect(nulist)
|
return redirect(nulist)
|
||||||
else:
|
else:
|
||||||
return render(request, "apps/dashboard/home.html", {"form": form})
|
context = {"form": form, "palettes": PALETTES, "page_class": "page-dashboard"}
|
||||||
|
if request.user.is_authenticated:
|
||||||
|
context["applets"] = _applet_context(request.user)
|
||||||
|
return render(request, "apps/dashboard/home.html", context)
|
||||||
|
|
||||||
def view_list(request, list_id):
|
def view_list(request, list_id):
|
||||||
our_list = List.objects.get(id=list_id)
|
our_list = List.objects.get(id=list_id)
|
||||||
@@ -109,5 +115,6 @@ def toggle_applets(request):
|
|||||||
return render(request, "apps/dashboard/_partials/_applets.html", {
|
return render(request, "apps/dashboard/_partials/_applets.html", {
|
||||||
"applets": _applet_context(request.user),
|
"applets": _applet_context(request.user),
|
||||||
"palettes": PALETTES,
|
"palettes": PALETTES,
|
||||||
|
"form": ItemForm(),
|
||||||
})
|
})
|
||||||
return redirect("home")
|
return redirect("home")
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ from selenium.webdriver.common.keys import Keys
|
|||||||
|
|
||||||
from .container_commands import create_session_on_server, reset_database
|
from .container_commands import create_session_on_server, reset_database
|
||||||
from .management.commands.create_session import create_pre_authenticated_session
|
from .management.commands.create_session import create_pre_authenticated_session
|
||||||
|
from apps.dashboard.models import Applet
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -44,6 +45,7 @@ class FunctionalTest(StaticLiveServerTestCase):
|
|||||||
if self.test_server:
|
if self.test_server:
|
||||||
self.live_server_url = 'http://' + self.test_server
|
self.live_server_url = 'http://' + self.test_server
|
||||||
reset_database(self.test_server)
|
reset_database(self.test_server)
|
||||||
|
Applet.objects.get_or_create(slug="new-list", defaults={"name": "New List"})
|
||||||
|
|
||||||
def tearDown(self):
|
def tearDown(self):
|
||||||
if self._test_has_failed():
|
if self._test_has_failed():
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ from .list_page import ListPage
|
|||||||
|
|
||||||
class LayoutAndStylingTest(FunctionalTest):
|
class LayoutAndStylingTest(FunctionalTest):
|
||||||
def test_layout_and_styling(self):
|
def test_layout_and_styling(self):
|
||||||
|
self.create_pre_authenticated_session("disco@test.io")
|
||||||
self.browser.get(self.live_server_url)
|
self.browser.get(self.live_server_url)
|
||||||
list_page = ListPage(self)
|
list_page = ListPage(self)
|
||||||
|
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ class ItemValidationTest(FunctionalTest):
|
|||||||
|
|
||||||
# Test methods
|
# Test methods
|
||||||
def test_cannot_add_empty_list_items(self):
|
def test_cannot_add_empty_list_items(self):
|
||||||
|
self.create_pre_authenticated_session("disco@test.io")
|
||||||
self.browser.get(self.live_server_url)
|
self.browser.get(self.live_server_url)
|
||||||
list_page = ListPage(self)
|
list_page = ListPage(self)
|
||||||
list_page.get_item_input_box().send_keys(Keys.ENTER)
|
list_page.get_item_input_box().send_keys(Keys.ENTER)
|
||||||
@@ -46,6 +47,7 @@ class ItemValidationTest(FunctionalTest):
|
|||||||
list_page.wait_for_row_in_list_table("Make tea", 2)
|
list_page.wait_for_row_in_list_table("Make tea", 2)
|
||||||
|
|
||||||
def test_cannot_add_duplicate_items(self):
|
def test_cannot_add_duplicate_items(self):
|
||||||
|
self.create_pre_authenticated_session("disco@test.io")
|
||||||
self.browser.get(self.live_server_url)
|
self.browser.get(self.live_server_url)
|
||||||
list_page = ListPage(self)
|
list_page = ListPage(self)
|
||||||
list_page.add_list_item("Witness divinity")
|
list_page.add_list_item("Witness divinity")
|
||||||
@@ -61,6 +63,7 @@ class ItemValidationTest(FunctionalTest):
|
|||||||
)
|
)
|
||||||
|
|
||||||
def test_error_messages_are_cleared_on_input(self):
|
def test_error_messages_are_cleared_on_input(self):
|
||||||
|
self.create_pre_authenticated_session("disco@test.io")
|
||||||
self.browser.get(self.live_server_url)
|
self.browser.get(self.live_server_url)
|
||||||
list_page = ListPage(self)
|
list_page = ListPage(self)
|
||||||
list_page.add_list_item("Gobbledygook")
|
list_page.add_list_item("Gobbledygook")
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ from .list_page import ListPage
|
|||||||
class NewVisitorTest(FunctionalTest):
|
class NewVisitorTest(FunctionalTest):
|
||||||
# Test methods
|
# Test methods
|
||||||
def test_can_start_a_todo_list(self):
|
def test_can_start_a_todo_list(self):
|
||||||
|
self.create_pre_authenticated_session("alice@test.io")
|
||||||
self.browser.get(self.live_server_url)
|
self.browser.get(self.live_server_url)
|
||||||
list_page = ListPage(self)
|
list_page = ListPage(self)
|
||||||
|
|
||||||
@@ -29,6 +30,7 @@ class NewVisitorTest(FunctionalTest):
|
|||||||
list_page.wait_for_row_in_list_table("Buy peacock feathers", 1)
|
list_page.wait_for_row_in_list_table("Buy peacock feathers", 1)
|
||||||
|
|
||||||
def test_multiple_users_can_start_lists_at_different_urls(self):
|
def test_multiple_users_can_start_lists_at_different_urls(self):
|
||||||
|
self.create_pre_authenticated_session("alice@test.io")
|
||||||
self.browser.get(self.live_server_url)
|
self.browser.get(self.live_server_url)
|
||||||
list_page = ListPage(self)
|
list_page = ListPage(self)
|
||||||
list_page.add_list_item("Buy peacock feathers")
|
list_page.add_list_item("Buy peacock feathers")
|
||||||
@@ -41,6 +43,7 @@ class NewVisitorTest(FunctionalTest):
|
|||||||
|
|
||||||
self.browser.delete_all_cookies()
|
self.browser.delete_all_cookies()
|
||||||
|
|
||||||
|
self.create_pre_authenticated_session("disco@test.io")
|
||||||
self.browser.get(self.live_server_url)
|
self.browser.get(self.live_server_url)
|
||||||
list_page = ListPage(self)
|
list_page = ListPage(self)
|
||||||
page_text = self.browser.find_element(By.TAG_NAME, 'body').text
|
page_text = self.browser.find_element(By.TAG_NAME, 'body').text
|
||||||
|
|||||||
@@ -24,7 +24,32 @@
|
|||||||
|
|
||||||
{% for entry in applets %}
|
{% for entry in applets %}
|
||||||
{% if entry.visible %}
|
{% if entry.visible %}
|
||||||
{% if entry.applet.slug == "username" %}
|
{% if entry.applet.slug == "new-list" %}
|
||||||
|
<section
|
||||||
|
id="id_applet_new_list"
|
||||||
|
style="--applet-cols: {{ entry.applet.grid_cols }}; --applet-rows: {{ entry.applet.grid_rows }};"
|
||||||
|
>
|
||||||
|
<h2>Start a new to-do list</h2>
|
||||||
|
{% url "new_list" as form_action %}
|
||||||
|
{% include "apps/dashboard/_partials/_form.html" with form=form form_action=form_action %}
|
||||||
|
</section>
|
||||||
|
{% elif entry.applet.slug == "my-lists" %}
|
||||||
|
<section
|
||||||
|
id="id_applet_my_lists"
|
||||||
|
style="--applet-cols: {{ entry.applet.grid_cols }}; --applet-rows: {{ entry.applet.grid_rows }};"
|
||||||
|
>
|
||||||
|
{% 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" %}
|
||||||
<section
|
<section
|
||||||
id="id_applet_username"
|
id="id_applet_username"
|
||||||
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 }};"
|
||||||
|
|||||||
@@ -1,13 +1,8 @@
|
|||||||
{% extends "core/base.html" %}
|
{% extends "core/base.html" %}
|
||||||
{% load lyric_extras %}
|
{% load lyric_extras %}
|
||||||
|
|
||||||
{% block title_text %}Start a new to-do list{% endblock title_text %}
|
{% block title_text %}Dashboard{% endblock title_text %}
|
||||||
{% block header_text %}Start a new to-do list{% endblock header_text %}
|
{% block header_text %}Dashboard{% endblock header_text %}
|
||||||
|
|
||||||
{% block extra_header %}
|
|
||||||
{% url "new_list" as form_action %}
|
|
||||||
{% include "apps/dashboard/_partials/_form.html" with form=form form_action=form_action %}
|
|
||||||
{% endblock extra_header %}
|
|
||||||
|
|
||||||
{% block scripts %}
|
{% block scripts %}
|
||||||
{% include "apps/dashboard/_partials/_scripts.html" %}
|
{% include "apps/dashboard/_partials/_scripts.html" %}
|
||||||
|
|||||||
Reference in New Issue
Block a user