Skip to content

Commit 292026d

Browse files
committed
refactor(dark): remove dark mode form and view
1 parent b56d096 commit 292026d

File tree

6 files changed

+3
-31
lines changed

6 files changed

+3
-31
lines changed

celerybeat-schedule-shm

-32 KB
Binary file not shown.

celerybeat-schedule-wal

-153 KB
Binary file not shown.

intranet/apps/context_processors.py

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
from intranet.apps.notifications.models import NotificationConfig
1313
from intranet.apps.oauth.models import CSLApplication
1414

15-
from ..utils.helpers import dark_mode_enabled, get_theme, get_theme_name, get_warning_html
15+
from ..utils.helpers import get_theme, get_theme_name, get_warning_html
1616
from .announcements.models import WarningAnnouncement
1717
from .schedule.models import Day
1818

@@ -178,13 +178,6 @@ def show_bus_button(request):
178178
return {"show_bus_nav": is_bus_admin and settings.ENABLE_BUS_APP}
179179

180180

181-
def enable_dark_mode(request):
182-
"""
183-
Export whether dark mode is enabled.
184-
"""
185-
return {"dark_mode_enabled": dark_mode_enabled(request)}
186-
187-
188181
def user_theme_choice(request):
189182
if request.user.is_authenticated:
190183
choice = request.user.theme_properties.theme_choice

intranet/apps/preferences/forms.py

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -94,14 +94,6 @@ def flag(label, default):
9494
)
9595

9696

97-
class DarkModeForm(forms.Form):
98-
def __init__(self, user, *args, **kwargs):
99-
super().__init__(*args, **kwargs)
100-
self.fields["dark_mode_enabled"] = forms.BooleanField(
101-
initial=user.dark_mode_properties.dark_mode_enabled, label="Enable dark mode?", required=False
102-
)
103-
104-
10597
class ThemeForm(forms.Form):
10698
THEME_CHOICES = [
10799
("light", "Light Theme"),

intranet/apps/preferences/views.py

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@
1010
from ..auth.decorators import eighth_admin_required
1111
from ..bus.models import Route
1212
from ..users.models import Email
13-
from .forms import BusRouteForm, DarkModeForm, EmailFormset, NotificationOptionsForm, PreferredPictureForm, PrivacyOptionsForm, ThemeForm
13+
from .forms import BusRouteForm, EmailFormset, NotificationOptionsForm, PreferredPictureForm, PrivacyOptionsForm, ThemeForm
1414

15-
# from .forms import (BusRouteForm, DarkModeForm, EmailFormset, NotificationOptionsForm, PhoneFormset, PreferredPictureForm, PrivacyOptionsForm,
15+
# from .forms import (BusRouteForm, EmailFormset, NotificationOptionsForm, PhoneFormset, PreferredPictureForm, PrivacyOptionsForm,
1616
# WebsiteFormset)
1717

1818

@@ -278,18 +278,6 @@ def save_gcm_options(request, user):
278278
messages.success(request, "Disabled push notifications")
279279

280280

281-
def save_dark_mode_settings(request, user):
282-
dark_mode_form = DarkModeForm(user, data=request.POST, initial={"dark_mode_enabled": user.dark_mode_properties.dark_mode_enabled})
283-
if dark_mode_form.is_valid():
284-
if dark_mode_form.has_changed():
285-
user.dark_mode_properties.dark_mode_enabled = dark_mode_form.cleaned_data["dark_mode_enabled"]
286-
user.dark_mode_properties.save()
287-
invalidate_obj(request.user.dark_mode_properties)
288-
messages.success(request, ("Dark mode enabled" if user.dark_mode_properties.dark_mode_enabled else "Dark mode disabled"))
289-
290-
return dark_mode_form
291-
292-
293281
def save_theme_settings(request, user):
294282
theme_form = ThemeForm(user, data=request.POST, initial={"theme_choice": user.theme_properties.theme_choice})
295283
if theme_form.is_valid():

intranet/settings/__init__.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -468,7 +468,6 @@
468468
"intranet.apps.context_processors.show_homecoming", # Sitewide custom themes (special events, etc)
469469
"intranet.apps.context_processors.global_custom_theme", # Sitewide custom themes (special events, etc)
470470
"intranet.apps.context_processors.show_bus_button",
471-
"intranet.apps.context_processors.enable_dark_mode",
472471
"intranet.apps.context_processors.user_theme_choice",
473472
"intranet.apps.context_processors.oauth_toolkit", # Django OAuth Toolkit-related middleware
474473
"intranet.apps.context_processors.settings_export", # "Exports" django.conf.settings as DJANGO_SETTINGS

0 commit comments

Comments
 (0)