diff --git a/intranet/apps/announcements/forms.py b/intranet/apps/announcements/forms.py index 67460d82ec..2aa7b927a3 100644 --- a/intranet/apps/announcements/forms.py +++ b/intranet/apps/announcements/forms.py @@ -25,7 +25,10 @@ class Meta: "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.", + "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/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 }} -