Skip to content

Commit

Permalink
feat(bus): option to mark bus as delayed
Browse files Browse the repository at this point in the history
closes tjcsl#1414
  • Loading branch information
alanzhu0 authored and IshanA2007 committed May 14, 2023
1 parent 29899d2 commit ebe30b4
Show file tree
Hide file tree
Showing 2 changed files with 63 additions and 9 deletions.
30 changes: 21 additions & 9 deletions intranet/settings/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,29 +21,41 @@
# July = 7
YEAR_TURNOVER_MONTH = 7

# 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.
# School years span 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.
# For example, for the 2022-2023 school year, start_school_year = 2022 and end_school_year = 2023.
start_school_year = datetime.date.today().year - 1 if datetime.date.today().month < YEAR_TURNOVER_MONTH else datetime.date.today().year
end_school_year = start_school_year + 1


# fmt: off
""" !! -------- UPDATE ANNUALLY -------- !!
Update this section annually after summer school ends and before school starts.
Last updated: 2022-08-30. """
School year last updated: 2022-08-30
Hoco last updated: 2022-08-30
"""

# When school is scheduled to start and end
SCHOOL_START_DATE = datetime.date(start_school_year, 8, 22)
SCHOOL_END_DATE = datetime.date(end_school_year, 6, 16)
SCHOOL_START_DATE = datetime.date(start_school_year,
8, 22 # UPDATE THIS! Value when last updated: August 22, 2022 # noqa: E128
) # noqa: E124
SCHOOL_END_DATE = datetime.date(end_school_year,
6, 16 # UPDATE THIS! Value when last updated: June 16, 2023 # noqa: E128
) # noqa: E124

# Dates when hoco starts and ends
HOCO_START_DATE = datetime.date(start_school_year, 9, 19)
HOCO_END_DATE = datetime.date(start_school_year, 9, 24)
HOCO_START_DATE = datetime.date(start_school_year,
9, 19 # UPDATE THIS! Value when last updated: September 19, 2022 # noqa: E128
) # noqa: E124
HOCO_END_DATE = datetime.date(start_school_year,
9, 24 # UPDATE THIS! Value when last updated: September 24, 2022 # noqa: E128
) # noqa: E124

""" -------- END UPDATE ANNUALLY -------- """
# fmt: on

# Default fallback time for start and end of school if no schedule is available
SCHOOL_START_HOUR = 8 # Not currently used
SCHOOL_START_MINUTE = 40 # Not currently used
SCHOOL_START_HOUR = 8
SCHOOL_START_MINUTE = 40
SCHOOL_END_HOUR = 16
SCHOOL_END_MINUTE = 0

Expand Down
42 changes: 42 additions & 0 deletions intranet/static/js/bus-afternoon.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ $(function() {
.filter(bus => bus.attributes.route_name.includes('JT'))
.map(bus => bus.attributes);
} else if (action === 'Mark a bus as arrived or on time') {
<<<<<<< HEAD
busList = routeList.filter(bus => !bus.attributes.route_name.includes('JT'))
.map(bus => {
if (bus.attributes.status === 'a') {
Expand All @@ -109,6 +110,32 @@ $(function() {
return bus.attributes;
}
});
=======
busList = routeList.map(bus => {
if ((bus.attributes.status === 'a' || bus.attributes.status === 'd') && !bus.attributes.route_name.includes('JT')) {
let attr = JSON.parse(JSON.stringify(bus.attributes));
attr.route_name = `Mark ${bus.attributes.route_name} as on time`;
return attr;
}
else if (bus.attributes.status === 'o') {
let attr = JSON.parse(JSON.stringify(bus.attributes));
let attr2 = JSON.parse(JSON.stringify(bus.attributes));
if (bus.attributes.route_name.includes('JT')) {
attr.route_name = `Mark ${bus.attributes.route_name} as delayed`;
return attr;
}
attr.route_name = `Mark ${bus.attributes.route_name} as delayed`;
attr2.route_name = `Mark ${bus.attributes.route_name} as arrived`;
return [attr, attr2];
} else {
if (!bus.attributes.route_name.includes('JT')) {
return bus.attributes;
}
return null;

}
}).flat().filter((element) => element != null);
>>>>>>> 45142c57 (feat(bus): option to mark bus as delayed)
} else if (action === 'Assign a bus to this space') {
busList = routeList.filter(bus => bus.attributes.status !== 'a')
.map(bus => bus.attributes);
Expand Down Expand Up @@ -166,6 +193,7 @@ $(function() {
} else if (this.action === 'Mark a bus as arrived or on time') {
let route_name = '';
let st = '';
<<<<<<< HEAD
// TODO: this is also super hacky
// Essentially, this checks if the selected route has "Mark"
// at the beginning, implying that it's to be marked on time.
Expand All @@ -174,6 +202,20 @@ $(function() {
st = 'o';
} else {
route_name = e.target.value;
=======
if (e.target.value.includes('on')) {
route_name = e.target.value.split(' ')[1];

st = 'o';
}
else if (e.target.value.includes('delayed')) {
route_name = e.target.value.split(' ')[1];

st = 'd';
}
else {
route_name = e.target.value.split(' ')[1];
>>>>>>> 45142c57 (feat(bus): option to mark bus as delayed)
st = 'a';
}
let route = this.model.findWhere({route_name: route_name}).attributes;
Expand Down

0 comments on commit ebe30b4

Please sign in to comment.