retool dashboard

This commit is contained in:
2022-06-13 14:59:36 -05:00
parent b785458f82
commit b03d1cd262
2 changed files with 109 additions and 26 deletions

View File

@@ -2,18 +2,25 @@
{% block title %} {{ title }}{% endblock %}
{% block page_heading %}{% endblock %}
{% block content %}
<h3>Dashboard</h3>
<div class="row">
<div class="col-md pb-2">
<div class="card">
<div class="card-header">
<h4>Upcoming Games</h4>
</div>
<div class="card-body p-0 m-0">
<div class="col">
<h4 class="display-4">Dashboard</h4>
</div>
</div>
{% for event, availability_summary in events_availabilities|slice:":4" %}
<div class="row m-0 p-2 border-bottom">
<div class="row">
<div class="col">
<h4 class="fw-bold">Upcoming Games</h4>
</div>
</div>
<div class="row flex-row overflow-scroll">
<div class="col">
<div class="pb-3 flex-nowrap d-flex">
{% for event, availability_summary in events_availabilities|slice:":5" %}
<div class="card mx-2" style="min-width: 320px;max-width: 375px;">
<div class="row m-0 p-2">
<div class="col p-0 m-auto" style="flex: 0 0 100px;">
<div class="d-inline-flex m-0 p-0">
<div class="chart-container" style="height: 100px;width: 100px;">
@@ -34,7 +41,7 @@
<h6 class="text-muted mb-2">{{ event.data.location_name }}</h6>
</div>
<div class="d-flex">
<a class="btn btn-primary btn-sm mx-1" role="button" href="{% url 'teamsnap_edit_lineup' event_ids=event.data.id team_id=event.data.team_id %}">
<a class="btn btn-primary btn-sm mx-1 text-nowrap" role="button" href="{% url 'teamsnap_edit_lineup' event_ids=event.data.id team_id=event.data.team_id %}">
Go to Lineup
</a>
<a class="btn btn-primary btn-sm mx-1" role="button" href="{% url 'gamecard' event_id=event.data.id team_id=event.data.team_id %}">
@@ -59,20 +66,24 @@
</div>
</div>
</div>
{% endfor %}
</div>
</div>
{% endfor %}
</div>
</div>
<div class="col-md pb-2">
<div class="card">
<div class="card-header">
<h4>Past Games</h4>
</div>
<div class="card-body p-0 m-0">
</div>
{% for event in ts_events_past|slice:":4" %}
<div class="row m-0 p-2 border-bottom">
<div class="row">
<div class="col">
<h4 class="fw-bold">Past Games</h4>
</div>
</div>
<div class="row flex-row overflow-scroll">
<div class="col">
<div class="pb-3 flex-nowrap d-flex">
{% for event in ts_events_past|slice:":4" %}
<div class="card mx-2" style="min-width: 320px;max-width: 375px;">
<div class="row m-0 p-2">
<div class="col p-0 m-auto rounded-circle bg-light" style="flex: 0 0 100px;">
<div class="d-inline-flex m-0 p-0">
<div class="d-flex align-items-center justify-content-center" style="height: 100px;width: 100px;">
@@ -105,12 +116,13 @@
</div>
</div>
</div>
{% endfor %}
</div>
</div>
{% endfor %}
</div>
</div>
</div>
</div>
{% endblock %}
{% block inline_javascript %}
<script>

View File

@@ -1,3 +1,74 @@
# from django.test import TestCase
import vcr
from django.conf import settings
from django.contrib.auth import (
BACKEND_SESSION_KEY,
HASH_SESSION_KEY,
SESSION_KEY,
get_user_model,
)
from django.contrib.sessions.backends.db import SessionStore
from django.contrib.staticfiles.testing import StaticLiveServerTestCase
from selenium import webdriver
# Create your tests here.
def create_session_cookie():
# First, create a new test user
user = get_user_model()
# user.objects.create_user(username=username, password=password)
user = get_user_model().objects.get(pk=2)
# Then create the authenticated session using the new user credentials
session = SessionStore()
session[SESSION_KEY] = user.pk
session[BACKEND_SESSION_KEY] = settings.AUTHENTICATION_BACKENDS[0]
session[HASH_SESSION_KEY] = user.get_session_auth_hash()
session.save()
# Finally, create the cookie dictionary
cookie = {
"name": settings.SESSION_COOKIE_NAME,
"value": session.session_key,
"secure": False,
"path": "/",
}
return cookie
class TeamsnapDashboardTests(StaticLiveServerTestCase):
fixtures = ["benchcoach/fixtures/dump.json"]
@classmethod
def setUpClass(cls):
cls.port = 8000
super().setUpClass()
cls.selenium = webdriver.Chrome("/opt/homebrew/bin/chromedriver")
cls.selenium.implicitly_wait(10)
@classmethod
def tearDownClass(cls):
cls.selenium.quit()
super().tearDownClass()
def setUp(self):
session_cookie = create_session_cookie()
self.selenium.get("{}{}".format(self.live_server_url, "/"))
self.selenium.add_cookie(session_cookie)
self.selenium.refresh()
pass
@vcr.use_cassette(
"teamsnap/dashboard/fixtures/tests.yaml",
ignore_localhost=True,
# record_mode="new_episodes",
decode_compressed_response=True,
allow_playback_repeats=True,
)
def test_dashboard(self):
self.selenium.get(
"{url}/{team_id}/dashboard/".format(
url=self.live_server_url,
team_id=6882652,
)
)
breakpoint()