Skip to content

Commit

Permalink
chore: some linting errors
Browse files Browse the repository at this point in the history
  • Loading branch information
JasonGrace2282 committed Oct 6, 2024
1 parent ba19926 commit 50fbb1b
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 47 deletions.
5 changes: 4 additions & 1 deletion intranet/apps/announcements/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -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."
),
}


Expand Down
2 changes: 0 additions & 2 deletions intranet/apps/eighth/forms/activities.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
from typing import List # noqa

from django import forms
from django.contrib.auth import get_user_model

Expand Down
80 changes: 40 additions & 40 deletions intranet/static/js/announcement.form.js
Original file line number Diff line number Diff line change
@@ -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({
Expand Down Expand Up @@ -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;
}
Expand All @@ -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(`<li><a class='exp-suggest-item' data-date='${use_date}'>"${dates[i].text}" - ${display_date}</a></li>`);
var useDate = dates[i].end ? dates[i].end.date() : dates[i].start.date();
var displayDate = useDate.toDateString();
$(".exp-list").append(`<li><a class='exp-suggest-item' data-date='${useDate}'>"${dates[i].text}" - ${displayDate}</a></li>`);
}
});

Expand All @@ -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;
}
Expand All @@ -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(`<li><a class='exp-suggest-item' data-date='${use_date}'>"${dates[i].text}" - ${display_date}</a></li>`);
var useDate = dates[i].end ? dates[i].end.date() : dates[i].start.date();
var displayDate = useDate.toDateString();
$(".exp-list").append(`<li><a class='exp-suggest-item' data-date='${useDate}'>"${dates[i].text}" - ${displayDate}</a></li>`);
}
});

Expand All @@ -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);
Expand All @@ -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;
}
3 changes: 2 additions & 1 deletion intranet/static/js/dashboard/announcements.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
});
Expand Down
3 changes: 0 additions & 3 deletions intranet/templates/dashboard/dashboard.html
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,6 @@
{% block js %}
{{ block.super }}

<script>
const flipToUnsubscribed = "{{ request.GET.flip_to }}" == "unsubscribed";
</script>
<script src="{% static 'js/dashboard/eighth-widget.js' %}"></script>
<script src="{% static 'js/schedule.js' %}"></script>
<script src="{% static 'js/events.js' %}"></script>
Expand Down

0 comments on commit 50fbb1b

Please sign in to comment.