latest changes, like logging neck + headache
This commit is contained in:
@@ -147,3 +147,176 @@ h2 { font-family: Fraunces, Georgia, serif; letter-spacing: -.03em; }
|
|||||||
|
|
||||||
.onboarding-tour { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 9px 24px; max-width: 760px; margin: 0 auto 26px; padding: 21px 23px; border: 1px solid #b8d6c1; border-radius: 17px; color: $ink; background: linear-gradient(135deg, #f3fbf5, $surface); box-shadow: $shadow; }.onboarding-tour .eyebrow { grid-column: 1 / -1; margin: 0; color: $forest; }.onboarding-tour h2 { margin: 0; font-size: 1.3rem; }.onboarding-tour > p:not(.eyebrow) { grid-column: 1 / -1; margin: 0; color: $muted; }.onboarding-tour__actions { display: flex; align-items: center; gap: 16px; }.onboarding-tour__actions form { margin: 0; }.onboarding-tour__actions .text-link { padding: 0; border: 0; background: transparent; }.onboarding-highlight { position: relative; z-index: 2; outline: 3px solid rgba($forest, .52); outline-offset: 4px; border-radius: 12px; box-shadow: 0 0 0 8px rgba($mint, .75), $shadow; }.primary-nav .onboarding-highlight { outline-offset: 3px; border-radius: 5px; }
|
.onboarding-tour { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 9px 24px; max-width: 760px; margin: 0 auto 26px; padding: 21px 23px; border: 1px solid #b8d6c1; border-radius: 17px; color: $ink; background: linear-gradient(135deg, #f3fbf5, $surface); box-shadow: $shadow; }.onboarding-tour .eyebrow { grid-column: 1 / -1; margin: 0; color: $forest; }.onboarding-tour h2 { margin: 0; font-size: 1.3rem; }.onboarding-tour > p:not(.eyebrow) { grid-column: 1 / -1; margin: 0; color: $muted; }.onboarding-tour__actions { display: flex; align-items: center; gap: 16px; }.onboarding-tour__actions form { margin: 0; }.onboarding-tour__actions .text-link { padding: 0; border: 0; background: transparent; }.onboarding-highlight { position: relative; z-index: 2; outline: 3px solid rgba($forest, .52); outline-offset: 4px; border-radius: 12px; box-shadow: 0 0 0 8px rgba($mint, .75), $shadow; }.primary-nav .onboarding-highlight { outline-offset: 3px; border-radius: 5px; }
|
||||||
@media (max-width: 560px) { .onboarding-tour { display: block; padding: 19px; }.onboarding-tour > p:not(.eyebrow) { margin-top: 7px; }.onboarding-tour__actions { margin-top: 15px; } }
|
@media (max-width: 560px) { .onboarding-tour { display: block; padding: 19px; }.onboarding-tour > p:not(.eyebrow) { margin-top: 7px; }.onboarding-tour__actions { margin-top: 15px; } }
|
||||||
|
|
||||||
|
|
||||||
|
/* Per-user dark appearance ------------------------------------------------ */
|
||||||
|
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
|
||||||
|
.theme-toggle { margin: 0; }
|
||||||
|
.theme-toggle button { display: grid; place-items: center; width: 34px; height: 34px; padding: 0; border: 1px solid $line; border-radius: 50%; color: $muted; background: $surface; font-size: 1.1rem; line-height: 1; }
|
||||||
|
.theme-toggle button:hover { color: $forest; border-color: rgba($forest, .35); background: $mint; }
|
||||||
|
.theme-toggle button:focus-visible { outline: 3px solid rgba($forest, .35); outline-offset: 3px; }
|
||||||
|
|
||||||
|
body[data-theme="dark"] {
|
||||||
|
color-scheme: dark;
|
||||||
|
color: #e8eee9;
|
||||||
|
background: #151b18;
|
||||||
|
}
|
||||||
|
html:has(body[data-theme="dark"]) { background: #151b18; }
|
||||||
|
body[data-theme="dark"] .site-header { border-color: #354039; background: rgba(24, 31, 27, .92); }
|
||||||
|
body[data-theme="dark"] .brand { color: #f3f7f3; }
|
||||||
|
body[data-theme="dark"] .primary-nav > a:not(.button),
|
||||||
|
body[data-theme="dark"] .nav-logout button { color: #bac5bd; }
|
||||||
|
body[data-theme="dark"] .primary-nav > a:not(.button):hover,
|
||||||
|
body[data-theme="dark"] .nav-logout button:hover { color: #a9ddba; }
|
||||||
|
body[data-theme="dark"] .theme-toggle button { border-color: #46544b; color: #e8eee9; background: #27312b; }
|
||||||
|
body[data-theme="dark"] .theme-toggle button:hover { color: #e8eee9; background: #355a45; }
|
||||||
|
body[data-theme="dark"] .hero__copy,
|
||||||
|
body[data-theme="dark"] .muted,
|
||||||
|
body[data-theme="dark"] .task-card__description,
|
||||||
|
body[data-theme="dark"] .task-card__meta,
|
||||||
|
body[data-theme="dark"] .budget-note,
|
||||||
|
body[data-theme="dark"] .recommendation-card__main > p,
|
||||||
|
body[data-theme="dark"] .form-layout__intro p:last-child,
|
||||||
|
body[data-theme="dark"] .settings-card > p,
|
||||||
|
body[data-theme="dark"] .fasting-widget__copy,
|
||||||
|
body[data-theme="dark"] .fasting-widget__cycle-copy,
|
||||||
|
body[data-theme="dark"] .fasting-history li,
|
||||||
|
body[data-theme="dark"] .checkin-calendar__legend,
|
||||||
|
body[data-theme="dark"] .sleep-trend header p,
|
||||||
|
body[data-theme="dark"] .sleep-trend__empty,
|
||||||
|
body[data-theme="dark"] .onboarding-tour > p:not(.eyebrow) { color: #b8c3bb; }
|
||||||
|
body[data-theme="dark"] .eyebrow,
|
||||||
|
body[data-theme="dark"] .text-link,
|
||||||
|
body[data-theme="dark"] .back-link a,
|
||||||
|
body[data-theme="dark"] .task-facts a,
|
||||||
|
body[data-theme="dark"] .checkin-tabs__tab.is-active { color: #9bd5ae; }
|
||||||
|
body[data-theme="dark"] .checkin-tabs,
|
||||||
|
body[data-theme="dark"] .checkin-tabs__tab.is-active { border-color: #41614b; }
|
||||||
|
body[data-theme="dark"] .checkin-tabs__tab { color: #b8c3bb; }
|
||||||
|
body[data-theme="dark"] .checkin-tabs__tab:hover { color: #b9edc8; }
|
||||||
|
body[data-theme="dark"] .fasting-widget,
|
||||||
|
body[data-theme="dark"] .recommendations-panel,
|
||||||
|
body[data-theme="dark"] .planner-controls,
|
||||||
|
body[data-theme="dark"] .task-card,
|
||||||
|
body[data-theme="dark"] .auth-panel,
|
||||||
|
body[data-theme="dark"] .settings-card,
|
||||||
|
body[data-theme="dark"] .weather-widget { border-color: #38443d; background: #202923; box-shadow: 0 18px 45px rgba(0, 0, 0, .22); }
|
||||||
|
body[data-theme="dark"] .weather-widget { background: linear-gradient(145deg, #26352d, #202923); }
|
||||||
|
body[data-theme="dark"] .task-card--inactive { background: #1c241f; }
|
||||||
|
body[data-theme="dark"] .task-card--completed { background: #23342a; }
|
||||||
|
body[data-theme="dark"] .task-filters,
|
||||||
|
body[data-theme="dark"] .recommendations-panel__header { border-color: #38443d; background: #1b231e; }
|
||||||
|
body[data-theme="dark"] .task-card__meta span { background: #303b33; }
|
||||||
|
body[data-theme="dark"] .recommendation-card,
|
||||||
|
body[data-theme="dark"] .task-facts > div,
|
||||||
|
body[data-theme="dark"] .subtasks-list,
|
||||||
|
body[data-theme="dark"] .subtasks-list li,
|
||||||
|
body[data-theme="dark"] .sleep-trend,
|
||||||
|
body[data-theme="dark"] .sleep-trend th,
|
||||||
|
body[data-theme="dark"] .sleep-trend td,
|
||||||
|
body[data-theme="dark"] .fasting-widget__schedule,
|
||||||
|
body[data-theme="dark"] .checkin-form { border-color: #3b473f; }
|
||||||
|
body[data-theme="dark"] .recommendation-card__subtasks,
|
||||||
|
body[data-theme="dark"] .fasting-widget__windows { background: #29342d; }
|
||||||
|
body[data-theme="dark"] .recommendation-card__subtasks a,
|
||||||
|
body[data-theme="dark"] .subtasks-list a,
|
||||||
|
body[data-theme="dark"] .fasting-widget__cycle-copy time,
|
||||||
|
body[data-theme="dark"] .fasting-history time { color: #edf5ef; }
|
||||||
|
body[data-theme="dark"] .prose { color: #d5dfd7; }
|
||||||
|
body[data-theme="dark"] .field label:not(.checkbox-field),
|
||||||
|
body[data-theme="dark"] .form-field label,
|
||||||
|
body[data-theme="dark"] .checkbox-field,
|
||||||
|
body[data-theme="dark"] .fasting-form .field label:not(.checkbox-field),
|
||||||
|
body[data-theme="dark"] .checkin-form .field label:not(.checkbox-field) { color: #d5dfd7; }
|
||||||
|
body[data-theme="dark"] .field input:not([type="checkbox"]),
|
||||||
|
body[data-theme="dark"] .field select,
|
||||||
|
body[data-theme="dark"] .field textarea,
|
||||||
|
body[data-theme="dark"] .form-field input,
|
||||||
|
body[data-theme="dark"] .form-field select,
|
||||||
|
body[data-theme="dark"] .planner-controls input,
|
||||||
|
body[data-theme="dark"] .planner-controls select,
|
||||||
|
body[data-theme="dark"] .task-filters select,
|
||||||
|
body[data-theme="dark"] .fasting-form .field input:not([type="checkbox"]),
|
||||||
|
body[data-theme="dark"] .checkin-form .field input:not([type="checkbox"]) { border-color: #536159; color: #edf5ef; background: #161d19; }
|
||||||
|
body[data-theme="dark"] .field input:not([type="checkbox"]):focus,
|
||||||
|
body[data-theme="dark"] .field select:focus,
|
||||||
|
body[data-theme="dark"] .field textarea:focus { border-color: #79bd8f; box-shadow: 0 0 0 3px rgba(121, 189, 143, .24); }
|
||||||
|
body[data-theme="dark"] .field small,
|
||||||
|
body[data-theme="dark"] .form-field small,
|
||||||
|
body[data-theme="dark"] .fasting-form .field small,
|
||||||
|
body[data-theme="dark"] .checkin-form .field small,
|
||||||
|
body[data-theme="dark"] .sleep-trend thead th,
|
||||||
|
body[data-theme="dark"] .checkin-calendar__weekdays { color: #aebbb2; }
|
||||||
|
body[data-theme="dark"] .flash-message { color: #c7f0d2; background: #244832; }
|
||||||
|
body[data-theme="dark"] .task-weather-forecast { color: #c3e8cf; background: #244532; }
|
||||||
|
body[data-theme="dark"] .category-picker__clear:hover { color: #edf5ef; background: #354039; }
|
||||||
|
body[data-theme="dark"] .category-picker__suggestions { border-color: #536159; background: #202923; box-shadow: 0 18px 45px rgba(0, 0, 0, .32); }
|
||||||
|
body[data-theme="dark"] .category-picker__suggestions [role="option"][aria-selected="true"],
|
||||||
|
body[data-theme="dark"] .category-picker__suggestions [role="option"]:hover { color: #d4f2dc; background: #31523d; }
|
||||||
|
body[data-theme="dark"] .fasting-timer__track { stroke: #3b473f; }
|
||||||
|
body[data-theme="dark"] .fasting-state--fasting { color: #c4f0d1; background: #254f37; }
|
||||||
|
body[data-theme="dark"] .fasting-state--eating { color: #ffe3a0; background: #5b4722; }
|
||||||
|
body[data-theme="dark"] .checkin-day { color: #e8eee9; background: #303a33; }
|
||||||
|
body[data-theme="dark"] .checkin-day--unrecorded { color: #aab5ad; background: #242d27; border-color: #58645c; }
|
||||||
|
body[data-theme="dark"] .checkin-day--zero { color: #c8f3d2; background: #28533a; }
|
||||||
|
body[data-theme="dark"] .checkin-day--low { color: #eef2b8; background: #536036; }
|
||||||
|
body[data-theme="dark"] .checkin-day--moderate { color: #ffe5a8; background: #71521c; }
|
||||||
|
body[data-theme="dark"] .checkin-day--high { color: #ffd0c5; background: #733b31; }
|
||||||
|
body[data-theme="dark"] .checkin-day--severe { color: #fff; background: #a8463b; }
|
||||||
|
body[data-theme="dark"] .checkin-day--today { border-color: #8fd2a3; }
|
||||||
|
body[data-theme="dark"] .checkin-day--selected { box-shadow: inset 0 0 0 2px #e8eee9; }
|
||||||
|
body[data-theme="dark"] .checkin-legend--unrecorded { border-color: #7a887e; background: #242d27; }
|
||||||
|
body[data-theme="dark"] .checkin-legend--zero { background: #28533a; }
|
||||||
|
body[data-theme="dark"] .onboarding-tour { border-color: #497257; color: #e8eee9; background: linear-gradient(135deg, #244631, #202923); box-shadow: 0 18px 45px rgba(0, 0, 0, .25); }
|
||||||
|
body[data-theme="dark"] .onboarding-highlight { outline-color: rgba(145, 215, 165, .7); box-shadow: 0 0 0 8px rgba(45, 90, 61, .75), 0 18px 45px rgba(0, 0, 0, .25); }
|
||||||
|
|
||||||
|
|
||||||
|
/* Complete the dark surface hierarchy for the dashboard panels. */
|
||||||
|
body[data-theme="dark"] .task-panel,
|
||||||
|
body[data-theme="dark"] .workout-panel,
|
||||||
|
body[data-theme="dark"] .checkin-panel,
|
||||||
|
body[data-theme="dark"] .detail-card,
|
||||||
|
body[data-theme="dark"] .task-form,
|
||||||
|
body[data-theme="dark"] .confirmation-card { border-color: #38443d; background: #202923; box-shadow: 0 18px 45px rgba(0, 0, 0, .22); }
|
||||||
|
body[data-theme="dark"] .task-filters { border-color: #38443d; background: #1b231e; }
|
||||||
|
body[data-theme="dark"] .task-card__footer,
|
||||||
|
body[data-theme="dark"] .workout-list { border-color: #3b473f; }
|
||||||
|
body[data-theme="dark"] .task-filters label,
|
||||||
|
body[data-theme="dark"] .loading-indicator,
|
||||||
|
body[data-theme="dark"] .subtask-count,
|
||||||
|
body[data-theme="dark"] .status-button,
|
||||||
|
body[data-theme="dark"] .workout-panel__header p:last-child,
|
||||||
|
body[data-theme="dark"] .workout-panel__summary span,
|
||||||
|
body[data-theme="dark"] .workout-panel__note,
|
||||||
|
body[data-theme="dark"] .workout-entry p,
|
||||||
|
body[data-theme="dark"] .workout-empty,
|
||||||
|
body[data-theme="dark"] .checkin-panel__header > div > p:last-child,
|
||||||
|
body[data-theme="dark"] .checkin-streaks dt,
|
||||||
|
body[data-theme="dark"] .checkin-streaks__note dd,
|
||||||
|
body[data-theme="dark"] .checkin-physio-total,
|
||||||
|
body[data-theme="dark"] .fasting-widget__schedule dt,
|
||||||
|
body[data-theme="dark"] .fasting-history h3 { color: #b8c3bb; }
|
||||||
|
body[data-theme="dark"] .workout-panel__summary strong,
|
||||||
|
body[data-theme="dark"] .checkin-streaks dd,
|
||||||
|
body[data-theme="dark"] .checkin-physio-total strong,
|
||||||
|
body[data-theme="dark"] .budget-note strong { color: #9bd5ae; }
|
||||||
|
body[data-theme="dark"] .status-button__dot,
|
||||||
|
body[data-theme="dark"] .task-card--completed .task-completion-button .status-button__dot { background: #8fd2a3; }
|
||||||
|
body[data-theme="dark"] .priority--low { color: #bde7cd; background: #254f37; }
|
||||||
|
body[data-theme="dark"] .priority--medium { color: #ffe3a0; background: #5b4722; }
|
||||||
|
body[data-theme="dark"] .priority--high { color: #ffd0c5; background: #6d3931; }
|
||||||
|
|
||||||
|
|
||||||
|
/* Secondary controls and compact widgets need their own dark contrast. */
|
||||||
|
body[data-theme="dark"] .button--secondary { color: #b9edc8; border-color: #568466; background: #263c2e; }
|
||||||
|
body[data-theme="dark"] .button--secondary:hover { color: #f4fbf6; border-color: #78bc8d; background: #356448; }
|
||||||
|
body[data-theme="dark"] .button--secondary:focus-visible { outline-color: rgba(153, 213, 174, .65); }
|
||||||
|
body[data-theme="dark"] .detail-card__header .button--secondary { color: #fff; border-color: rgba(255, 255, 255, .58); background: transparent; }
|
||||||
|
body[data-theme="dark"] .detail-card__header .button--secondary:hover { color: #1f4e39; background: #fff; }
|
||||||
|
body[data-theme="dark"] .weather-widget__reading { color: #edf5ef; }
|
||||||
|
body[data-theme="dark"] .weather-widget__detail { color: #b8c3bb; }
|
||||||
|
body[data-theme="dark"] .weather-widget__icon { color: #e4f5e8; }
|
||||||
|
body[data-theme="dark"] .checkin-tooltip { color: #d9f5e0; background: #315b41; box-shadow: inset 0 0 0 1px #598b69; }
|
||||||
|
body[data-theme="dark"] .checkin-tooltip:hover { background: #3b704e; }
|
||||||
|
body[data-theme="dark"] .checkin-tooltip:focus-visible { outline-color: #a9ddba; }
|
||||||
|
body[data-theme="dark"] .checkin-tooltip__content { color: #edf5ef; background: #101713; box-shadow: 0 8px 20px rgba(0, 0, 0, .38); }
|
||||||
|
|||||||
@@ -0,0 +1,14 @@
|
|||||||
|
"""Template context shared by Tasknest pages."""
|
||||||
|
|
||||||
|
from .models import UserSettings
|
||||||
|
|
||||||
|
|
||||||
|
def appearance(request):
|
||||||
|
"""Expose the signed-in user’s saved colour preference without creating settings."""
|
||||||
|
user = getattr(request, "user", None)
|
||||||
|
if user is not None and user.is_authenticated:
|
||||||
|
saved_appearance = (
|
||||||
|
UserSettings.objects.filter(user=user).values_list("appearance", flat=True).first()
|
||||||
|
)
|
||||||
|
return {"user_appearance": saved_appearance or UserSettings.Appearance.LIGHT}
|
||||||
|
return {"user_appearance": UserSettings.Appearance.LIGHT}
|
||||||
@@ -41,6 +41,7 @@ class Command(BaseCommand):
|
|||||||
|
|
||||||
profile, _ = UserSettings.objects.get_or_create(user=user)
|
profile, _ = UserSettings.objects.get_or_create(user=user)
|
||||||
profile.time_zone = DEFAULT_TIME_ZONE
|
profile.time_zone = DEFAULT_TIME_ZONE
|
||||||
|
profile.appearance = UserSettings.Appearance.LIGHT
|
||||||
profile.latitude = '52.367600'
|
profile.latitude = '52.367600'
|
||||||
profile.longitude = '4.904100'
|
profile.longitude = '4.904100'
|
||||||
profile.onboarding_enabled = False
|
profile.onboarding_enabled = False
|
||||||
|
|||||||
@@ -0,0 +1,18 @@
|
|||||||
|
# Generated by Django 6.1.1 on 2026-09-30 16:08
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('planner', '0012_usersettings_onboarding_enabled_and_more'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='usersettings',
|
||||||
|
name='appearance',
|
||||||
|
field=models.CharField(choices=[('light', 'Light'), ('dark', 'Dark')], default='light', max_length=5),
|
||||||
|
),
|
||||||
|
]
|
||||||
@@ -95,6 +95,10 @@ class Task(models.Model):
|
|||||||
class UserSettings(models.Model):
|
class UserSettings(models.Model):
|
||||||
"""Private, per-user preferences that do not belong on Django's User model."""
|
"""Private, per-user preferences that do not belong on Django's User model."""
|
||||||
|
|
||||||
|
class Appearance(models.TextChoices):
|
||||||
|
LIGHT = 'light', 'Light'
|
||||||
|
DARK = 'dark', 'Dark'
|
||||||
|
|
||||||
user = models.OneToOneField(
|
user = models.OneToOneField(
|
||||||
settings.AUTH_USER_MODEL, on_delete=models.CASCADE, related_name='planner_settings'
|
settings.AUTH_USER_MODEL, on_delete=models.CASCADE, related_name='planner_settings'
|
||||||
)
|
)
|
||||||
@@ -107,6 +111,9 @@ class UserSettings(models.Model):
|
|||||||
validators=[MinValueValidator(-180), MaxValueValidator(180)],
|
validators=[MinValueValidator(-180), MaxValueValidator(180)],
|
||||||
)
|
)
|
||||||
time_zone = models.CharField(max_length=64, default='Europe/Amsterdam')
|
time_zone = models.CharField(max_length=64, default='Europe/Amsterdam')
|
||||||
|
appearance = models.CharField(
|
||||||
|
max_length=5, choices=Appearance.choices, default=Appearance.LIGHT,
|
||||||
|
)
|
||||||
onboarding_enabled = models.BooleanField(default=True)
|
onboarding_enabled = models.BooleanField(default=True)
|
||||||
onboarding_step = models.PositiveSmallIntegerField(default=0)
|
onboarding_step = models.PositiveSmallIntegerField(default=0)
|
||||||
created_at = models.DateTimeField(auto_now_add=True)
|
created_at = models.DateTimeField(auto_now_add=True)
|
||||||
|
|||||||
@@ -8,7 +8,7 @@
|
|||||||
<title>{% block title %}Tasknest{% endblock %}</title>
|
<title>{% block title %}Tasknest{% endblock %}</title>
|
||||||
{% vite_asset 'src/main.js' %}
|
{% vite_asset 'src/main.js' %}
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body data-theme="{{ user_appearance }}">
|
||||||
<div class="app-shell">
|
<div class="app-shell">
|
||||||
<header class="site-header">
|
<header class="site-header">
|
||||||
<div class="site-header__inner">
|
<div class="site-header__inner">
|
||||||
@@ -21,6 +21,7 @@
|
|||||||
<a href="{% url 'planner:task-list' %}">My tasks</a>
|
<a href="{% url 'planner:task-list' %}">My tasks</a>
|
||||||
<a id="daily-planner-nav" class="{% if onboarding_tour.target == 'daily-planner' %}onboarding-highlight{% endif %}" href="{% url 'planner:daily-planner' %}">Daily planner</a>
|
<a id="daily-planner-nav" class="{% if onboarding_tour.target == 'daily-planner' %}onboarding-highlight{% endif %}" href="{% url 'planner:daily-planner' %}">Daily planner</a>
|
||||||
<a id="settings-nav" class="{% if onboarding_tour.target == 'settings' %}onboarding-highlight{% endif %}" href="{% url 'planner:user-settings' %}">Settings</a>
|
<a id="settings-nav" class="{% if onboarding_tour.target == 'settings' %}onboarding-highlight{% endif %}" href="{% url 'planner:user-settings' %}">Settings</a>
|
||||||
|
<form method="post" action="{% url 'planner:user-settings' %}" class="theme-toggle">{% csrf_token %}<input type="hidden" name="section" value="appearance"><input type="hidden" name="next" value="{{ request.path }}">{% if user_appearance == 'dark' %}<input type="hidden" name="appearance" value="light"><button type="submit" aria-label="Use light mode" title="Use light mode"><span aria-hidden="true">☀</span><span class="sr-only">Use light mode</span></button>{% else %}<input type="hidden" name="appearance" value="dark"><button type="submit" aria-label="Use dark mode" title="Use dark mode"><span aria-hidden="true">☾</span><span class="sr-only">Use dark mode</span></button>{% endif %}</form>
|
||||||
<form method="post" action="{% url 'planner:logout' %}" class="nav-logout">{% csrf_token %}<button type="submit">Log out</button></form>
|
<form method="post" action="{% url 'planner:logout' %}" class="nav-logout">{% csrf_token %}<button type="submit">Log out</button></form>
|
||||||
{% else %}
|
{% else %}
|
||||||
<a href="{% url 'planner:login' %}">Log in</a>
|
<a href="{% url 'planner:login' %}">Log in</a>
|
||||||
|
|||||||
@@ -941,6 +941,33 @@ class UserSettingsTests(TestCase):
|
|||||||
self.assertEqual(UserSettings.objects.get(user=self.user_a).time_zone, "UTC")
|
self.assertEqual(UserSettings.objects.get(user=self.user_a).time_zone, "UTC")
|
||||||
self.assertFalse(UserSettings.objects.filter(user=self.user_b).exists())
|
self.assertFalse(UserSettings.objects.filter(user=self.user_b).exists())
|
||||||
|
|
||||||
|
def test_appearance_is_saved_per_user_and_applied_to_the_page(self):
|
||||||
|
response = self.client.post(reverse("planner:user-settings"), {
|
||||||
|
"section": "appearance",
|
||||||
|
"appearance": UserSettings.Appearance.DARK,
|
||||||
|
"next": reverse("planner:task-list"),
|
||||||
|
})
|
||||||
|
|
||||||
|
self.assertRedirects(response, reverse("planner:task-list"))
|
||||||
|
self.assertEqual(
|
||||||
|
UserSettings.objects.get(user=self.user_a).appearance, UserSettings.Appearance.DARK
|
||||||
|
)
|
||||||
|
page = self.client.get(reverse("planner:task-list"))
|
||||||
|
self.assertContains(page, "data-theme=\"dark\"")
|
||||||
|
|
||||||
|
self.client.force_login(self.user_b)
|
||||||
|
self.client.post(reverse("planner:user-settings"), {
|
||||||
|
"section": "appearance",
|
||||||
|
"appearance": UserSettings.Appearance.LIGHT,
|
||||||
|
"next": reverse("planner:task-list"),
|
||||||
|
})
|
||||||
|
self.assertEqual(
|
||||||
|
UserSettings.objects.get(user=self.user_a).appearance, UserSettings.Appearance.DARK
|
||||||
|
)
|
||||||
|
self.assertEqual(
|
||||||
|
UserSettings.objects.get(user=self.user_b).appearance, UserSettings.Appearance.LIGHT
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
class OnboardingTests(TestCase):
|
class OnboardingTests(TestCase):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ from django.http import Http404, HttpResponse, JsonResponse
|
|||||||
from django.shortcuts import get_object_or_404, redirect, render
|
from django.shortcuts import get_object_or_404, redirect, render
|
||||||
from django.urls import reverse, reverse_lazy
|
from django.urls import reverse, reverse_lazy
|
||||||
from django.utils import timezone
|
from django.utils import timezone
|
||||||
|
from django.utils.http import url_has_allowed_host_and_scheme
|
||||||
from django.utils.dateparse import parse_date
|
from django.utils.dateparse import parse_date
|
||||||
from django.views.decorators.http import require_http_methods, require_POST
|
from django.views.decorators.http import require_http_methods, require_POST
|
||||||
from django.contrib.auth.mixins import LoginRequiredMixin
|
from django.contrib.auth.mixins import LoginRequiredMixin
|
||||||
@@ -649,6 +650,18 @@ def user_settings(request):
|
|||||||
time_zone_form.save()
|
time_zone_form.save()
|
||||||
messages.success(request, 'Your time zone was saved.')
|
messages.success(request, 'Your time zone was saved.')
|
||||||
return redirect('planner:user-settings')
|
return redirect('planner:user-settings')
|
||||||
|
elif section == 'appearance':
|
||||||
|
appearance = request.POST.get('appearance')
|
||||||
|
if appearance in UserSettings.Appearance.values:
|
||||||
|
profile.appearance = appearance
|
||||||
|
profile.save(update_fields=['appearance', 'updated_at'])
|
||||||
|
messages.success(request, f"{appearance.capitalize()} mode is on.")
|
||||||
|
next_url = request.POST.get('next', '')
|
||||||
|
if url_has_allowed_host_and_scheme(
|
||||||
|
next_url, allowed_hosts={request.get_host()}, require_https=request.is_secure()
|
||||||
|
):
|
||||||
|
return redirect(next_url)
|
||||||
|
return redirect('planner:user-settings')
|
||||||
elif section == 'onboarding':
|
elif section == 'onboarding':
|
||||||
action = request.POST.get('action')
|
action = request.POST.get('action')
|
||||||
if action == 'restart':
|
if action == 'restart':
|
||||||
|
|||||||
@@ -67,6 +67,7 @@ TEMPLATES = [
|
|||||||
'django.template.context_processors.request',
|
'django.template.context_processors.request',
|
||||||
'django.contrib.auth.context_processors.auth',
|
'django.contrib.auth.context_processors.auth',
|
||||||
'django.contrib.messages.context_processors.messages',
|
'django.contrib.messages.context_processors.messages',
|
||||||
|
'planner.context_processors.appearance',
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user