Skip to content

Commit ebe30b4

Browse files
alanzhu0IshanA2007
authored andcommitted
feat(bus): option to mark bus as delayed
closes #1414
1 parent 29899d2 commit ebe30b4

File tree

2 files changed

+63
-9
lines changed

2 files changed

+63
-9
lines changed

intranet/settings/__init__.py

+21-9
Original file line numberDiff line numberDiff line change
@@ -21,29 +21,41 @@
2121
# July = 7
2222
YEAR_TURNOVER_MONTH = 7
2323

24-
# School years spans 2 calendar years. start_school_year is the year the school year starts in, and end_school_year is the year the school year ends in.
24+
# School years span 2 calendar years.
25+
# start_school_year is the year the school year starts in, and end_school_year is the year the school year ends in.
2526
# For example, for the 2022-2023 school year, start_school_year = 2022 and end_school_year = 2023.
2627
start_school_year = datetime.date.today().year - 1 if datetime.date.today().month < YEAR_TURNOVER_MONTH else datetime.date.today().year
2728
end_school_year = start_school_year + 1
2829

29-
30+
# fmt: off
3031
""" !! -------- UPDATE ANNUALLY -------- !!
3132
Update this section annually after summer school ends and before school starts.
32-
Last updated: 2022-08-30. """
33+
School year last updated: 2022-08-30
34+
Hoco last updated: 2022-08-30
35+
"""
3336

3437
# When school is scheduled to start and end
35-
SCHOOL_START_DATE = datetime.date(start_school_year, 8, 22)
36-
SCHOOL_END_DATE = datetime.date(end_school_year, 6, 16)
38+
SCHOOL_START_DATE = datetime.date(start_school_year,
39+
8, 22 # UPDATE THIS! Value when last updated: August 22, 2022 # noqa: E128
40+
) # noqa: E124
41+
SCHOOL_END_DATE = datetime.date(end_school_year,
42+
6, 16 # UPDATE THIS! Value when last updated: June 16, 2023 # noqa: E128
43+
) # noqa: E124
3744

3845
# Dates when hoco starts and ends
39-
HOCO_START_DATE = datetime.date(start_school_year, 9, 19)
40-
HOCO_END_DATE = datetime.date(start_school_year, 9, 24)
46+
HOCO_START_DATE = datetime.date(start_school_year,
47+
9, 19 # UPDATE THIS! Value when last updated: September 19, 2022 # noqa: E128
48+
) # noqa: E124
49+
HOCO_END_DATE = datetime.date(start_school_year,
50+
9, 24 # UPDATE THIS! Value when last updated: September 24, 2022 # noqa: E128
51+
) # noqa: E124
4152

4253
""" -------- END UPDATE ANNUALLY -------- """
54+
# fmt: on
4355

4456
# Default fallback time for start and end of school if no schedule is available
45-
SCHOOL_START_HOUR = 8 # Not currently used
46-
SCHOOL_START_MINUTE = 40 # Not currently used
57+
SCHOOL_START_HOUR = 8
58+
SCHOOL_START_MINUTE = 40
4759
SCHOOL_END_HOUR = 16
4860
SCHOOL_END_MINUTE = 0
4961

intranet/static/js/bus-afternoon.js

+42
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ $(function() {
9898
.filter(bus => bus.attributes.route_name.includes('JT'))
9999
.map(bus => bus.attributes);
100100
} else if (action === 'Mark a bus as arrived or on time') {
101+
<<<<<<< HEAD
101102
busList = routeList.filter(bus => !bus.attributes.route_name.includes('JT'))
102103
.map(bus => {
103104
if (bus.attributes.status === 'a') {
@@ -109,6 +110,32 @@ $(function() {
109110
return bus.attributes;
110111
}
111112
});
113+
=======
114+
busList = routeList.map(bus => {
115+
if ((bus.attributes.status === 'a' || bus.attributes.status === 'd') && !bus.attributes.route_name.includes('JT')) {
116+
let attr = JSON.parse(JSON.stringify(bus.attributes));
117+
attr.route_name = `Mark ${bus.attributes.route_name} as on time`;
118+
return attr;
119+
}
120+
else if (bus.attributes.status === 'o') {
121+
let attr = JSON.parse(JSON.stringify(bus.attributes));
122+
let attr2 = JSON.parse(JSON.stringify(bus.attributes));
123+
if (bus.attributes.route_name.includes('JT')) {
124+
attr.route_name = `Mark ${bus.attributes.route_name} as delayed`;
125+
return attr;
126+
}
127+
attr.route_name = `Mark ${bus.attributes.route_name} as delayed`;
128+
attr2.route_name = `Mark ${bus.attributes.route_name} as arrived`;
129+
return [attr, attr2];
130+
} else {
131+
if (!bus.attributes.route_name.includes('JT')) {
132+
return bus.attributes;
133+
}
134+
return null;
135+
136+
}
137+
}).flat().filter((element) => element != null);
138+
>>>>>>> 45142c57 (feat(bus): option to mark bus as delayed)
112139
} else if (action === 'Assign a bus to this space') {
113140
busList = routeList.filter(bus => bus.attributes.status !== 'a')
114141
.map(bus => bus.attributes);
@@ -166,6 +193,7 @@ $(function() {
166193
} else if (this.action === 'Mark a bus as arrived or on time') {
167194
let route_name = '';
168195
let st = '';
196+
<<<<<<< HEAD
169197
// TODO: this is also super hacky
170198
// Essentially, this checks if the selected route has "Mark"
171199
// at the beginning, implying that it's to be marked on time.
@@ -174,6 +202,20 @@ $(function() {
174202
st = 'o';
175203
} else {
176204
route_name = e.target.value;
205+
=======
206+
if (e.target.value.includes('on')) {
207+
route_name = e.target.value.split(' ')[1];
208+
209+
st = 'o';
210+
}
211+
else if (e.target.value.includes('delayed')) {
212+
route_name = e.target.value.split(' ')[1];
213+
214+
st = 'd';
215+
}
216+
else {
217+
route_name = e.target.value.split(' ')[1];
218+
>>>>>>> 45142c57 (feat(bus): option to mark bus as delayed)
177219
st = 'a';
178220
}
179221
let route = this.model.findWhere({route_name: route_name}).attributes;

0 commit comments

Comments
 (0)