From a2f35f361280cb36d8c39100a77fc2dfd85c4426 Mon Sep 17 00:00:00 2001 From: JasonGrace2282 Date: Sat, 5 Oct 2024 14:34:25 -0400 Subject: [PATCH] chore: resolve some linting errors --- intranet/apps/announcements/forms.py | 10 ++- intranet/apps/eighth/forms/activities.py | 2 - intranet/apps/eighth/views/activities.py | 2 - intranet/static/css/dark/dashboard.scss | 3 +- intranet/static/css/dashboard.scss | 3 + intranet/static/js/announcement.form.js | 80 +++++++++---------- intranet/static/js/dashboard/announcements.js | 3 +- intranet/templates/dashboard/dashboard.html | 3 - 8 files changed, 55 insertions(+), 51 deletions(-) diff --git a/intranet/apps/announcements/forms.py b/intranet/apps/announcements/forms.py index 67460d82ec..43684b8b1f 100644 --- a/intranet/apps/announcements/forms.py +++ b/intranet/apps/announcements/forms.py @@ -24,8 +24,14 @@ class Meta: help_texts = { "expiration_date": "By default, announcements expire after two weeks. Choose the shortest time necessary.", "notify_post": "If this box is checked, students who have signed up for notifications will receive an email.", - "notify_email_all": "This will send an email notification to all of the users who can see this post. This option does NOT take users' email notification preferences into account, so please use with care.", - "update_added_date": "If this announcement has already been added, update the added date to now so that the announcement is pushed to the top. If this option is not selected, the announcement will stay in its current position.", + "notify_email_all": ( + "This will send an email notification to all of the users who can see this post. " + "This option does NOT take users' email notification preferences into account, so please use with care." + ), + "update_added_date": ( + "If this announcement has already been added, update the added date to now so that the announcement is pushed to the top. " + "If this option is not selected, the announcement will stay in its current position." + ), } diff --git a/intranet/apps/eighth/forms/activities.py b/intranet/apps/eighth/forms/activities.py index b4fcf39698..9a9be1aeb9 100644 --- a/intranet/apps/eighth/forms/activities.py +++ b/intranet/apps/eighth/forms/activities.py @@ -1,5 +1,3 @@ -from typing import List # noqa - from django import forms from django.contrib.auth import get_user_model diff --git a/intranet/apps/eighth/views/activities.py b/intranet/apps/eighth/views/activities.py index 697ce36c35..32017a3d84 100644 --- a/intranet/apps/eighth/views/activities.py +++ b/intranet/apps/eighth/views/activities.py @@ -59,8 +59,6 @@ def settings_view(request, activity_id=None): if not (EighthSponsor.objects.filter(user=request.user).exists() or request.user in activity.club_sponsors.all()): raise Http404 - print(activity.sponsors.all()) - if request.method == "POST": form = ActivitySettingsForm(request.POST, instance=activity, sponsors=activity.sponsors.all()) if form.is_valid(): diff --git a/intranet/static/css/dark/dashboard.scss b/intranet/static/css/dark/dashboard.scss index c6d01947b4..f63c2dd648 100644 --- a/intranet/static/css/dark/dashboard.scss +++ b/intranet/static/css/dark/dashboard.scss @@ -54,8 +54,9 @@ a.club-announcement-meta-link:hover { .announcements { .announcement-banner { - background-color: #000000; + background-color: #000; } + .announcement-link { color: #a3a3a3; } diff --git a/intranet/static/css/dashboard.scss b/intranet/static/css/dashboard.scss index 089eec6917..0a0c7a98a0 100644 --- a/intranet/static/css/dashboard.scss +++ b/intranet/static/css/dashboard.scss @@ -73,12 +73,15 @@ &::-webkit-scrollbar { width: 7px; } + &::-webkit-scrollbar-track { background: #d6d6d6; } + &::-webkit-scrollbar-thumb { background: #888; } + &::-webkit-scrollbar-thumb:hover { background: #555; } diff --git a/intranet/static/js/announcement.form.js b/intranet/static/js/announcement.form.js index 98c90f7968..0003dbb1ee 100644 --- a/intranet/static/js/announcement.form.js +++ b/intranet/static/js/announcement.form.js @@ -1,3 +1,24 @@ +function zero(v) { + return v < 10 ? "0" + v : v; +} + +function dateFormat(date) { + return (date.getFullYear() + "-" + + zero(date.getMonth() + 1) + "-" + + zero(date.getDate()) + " 23:59:59"); +} + +function dateReset(exp) { + var date = new Date(); + date.setDate(date.getDate() + 14); + exp.val(dateFormat(date)); +} + +function date3000(exp) { + var date = new Date("3000-01-01 00:00:00"); + exp.val(dateFormat(date)); +} + /* global $ */ $(function() { $("select#id_groups").selectize({ @@ -51,15 +72,15 @@ $(function() { var text = editor.getData(); dates = chrono.parse(text) .sort(function (a, b) { - var a_date = a.end ? a.end.date() : a.start.date(); - var b_date = b.end ? b.end.date() : b.start.date(); - return b_date.getTime() - a_date.getTime(); + var aDate = a.end ? a.end.date() : a.start.date(); + var bDate = b.end ? b.end.date() : b.start.date(); + return bDate.getTime() - aDate.getTime(); }) .filter(function (val, ind, ary) { if (ind) { - var a_date = val.end ? val.end.date() : val.start.date(); - var b_date = ary[ind - 1].end ? ary[ind - 1].end.date() : ary[ind - 1].start.date(); - return !ind || a_date.getTime() != b_date.getTime(); + var aDate = val.end ? val.end.date() : val.start.date(); + var bDate = ary[ind - 1].end ? ary[ind - 1].end.date() : ary[ind - 1].start.date(); + return !ind || aDate.getTime() != bDate.getTime(); } else { return true; } @@ -70,9 +91,9 @@ $(function() { else $(".exp-header").css("display", "none"); for (var i = 0; i < dates.length; i++) { - var use_date = dates[i].end ? dates[i].end.date() : dates[i].start.date(); - var display_date = use_date.toDateString(); - $(".exp-list").append(`
  • "${dates[i].text}" - ${display_date}
  • `); + var useDate = dates[i].end ? dates[i].end.date() : dates[i].start.date(); + var displayDate = useDate.toDateString(); + $(".exp-list").append(`
  • "${dates[i].text}" - ${displayDate}
  • `); } }); @@ -81,15 +102,15 @@ $(function() { var text = editor.getData(); dates = chrono.parse(text) .sort(function (a, b) { - var a_date = a.end ? a.end.date() : a.start.date(); - var b_date = b.end ? b.end.date() : b.start.date(); - return b_date.getTime() - a_date.getTime(); + var aDate = a.end ? a.end.date() : a.start.date(); + var bDate = b.end ? b.end.date() : b.start.date(); + return bDate.getTime() - aDate.getTime(); }) .filter(function (val, ind, ary) { if (ind) { - var a_date = val.end ? val.end.date() : val.start.date(); - var b_date = ary[ind - 1].end ? ary[ind - 1].end.date() : ary[ind - 1].start.date(); - return !ind || a_date.getTime() != b_date.getTime(); + var aDate = val.end ? val.end.date() : val.start.date(); + var bDate = ary[ind - 1].end ? ary[ind - 1].end.date() : ary[ind - 1].start.date(); + return !ind || aDate.getTime() != bDate.getTime(); } else { return true; } @@ -100,9 +121,9 @@ $(function() { else $(".exp-header").css("display", "none"); for (var i = 0; i < dates.length; i++) { - var use_date = dates[i].end ? dates[i].end.date() : dates[i].start.date(); - var display_date = use_date.toDateString(); - $(".exp-list").append(`
  • "${dates[i].text}" - ${display_date}
  • `); + var useDate = dates[i].end ? dates[i].end.date() : dates[i].start.date(); + var displayDate = useDate.toDateString(); + $(".exp-list").append(`
  • "${dates[i].text}" - ${displayDate}
  • `); } }); @@ -120,7 +141,7 @@ $(function() { $(".exp-list").on("click", "a", function () { exp.val(dateFormat(new Date($(this).data("date")))); - }) + }); $("#date-reset-btn").click(function () { dateReset(exp); @@ -130,24 +151,3 @@ $(function() { date3000(exp); }); }); - -function dateReset(exp) { - var date = new Date(); - date.setDate(date.getDate() + 14); - exp.val(dateFormat(date)); -} - -function date3000(exp) { - var date = new Date("3000-01-01 00:00:00"); - exp.val(dateFormat(date)); -} - -function dateFormat(date) { - return (date.getFullYear() + "-" + - zero(date.getMonth() + 1) + "-" + - zero(date.getDate()) + " 23:59:59"); -} - -function zero(v) { - return v < 10 ? "0" + v : v; -} \ No newline at end of file diff --git a/intranet/static/js/dashboard/announcements.js b/intranet/static/js/dashboard/announcements.js index 27f31fe56a..854a309268 100644 --- a/intranet/static/js/dashboard/announcements.js +++ b/intranet/static/js/dashboard/announcements.js @@ -62,7 +62,8 @@ $(document).ready(function() { filterClubAnnouncements(); }); - if (flipToUnsubscribed) { + const params = new URLSearchParams(window.location.search); + if (params.get("flip_to") == "unsubscribed") { $(".unsubscribed-filter").click(); } }); diff --git a/intranet/templates/dashboard/dashboard.html b/intranet/templates/dashboard/dashboard.html index 446ac8c477..5f34b45b4a 100644 --- a/intranet/templates/dashboard/dashboard.html +++ b/intranet/templates/dashboard/dashboard.html @@ -30,9 +30,6 @@ {% block js %} {{ block.super }} -