Skip to content

Commit 1be7474

Browse files
authored
Merge pull request #320 from RIT-Software-Engineering/1-8-1-Release-Cleanup
1 8 1 release cleanup
2 parents adbccd8 + 12d43e1 commit 1be7474

File tree

31 files changed

+19736
-19426
lines changed

31 files changed

+19736
-19426
lines changed

README.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,11 @@ _**On first login, new user must change password by using the `passwd` command**
3535
## Install/Develop locally
3636

3737
- ### Using Dev Container
38-
38+
- You *may* need to add the following to your hosts file (`C:\Windows\System32\drivers\etc\hosts`):
39+
```
40+
150.171.69.10 mcr.microsoft.com
41+
150.171.69.10 eastus.data.mcr.microsoft.com
42+
```
3943
- Install [Docker](https://docs.docker.com/get-docker/)
4044
- Install [VSCode](https://code.visualstudio.com/) and the [Dev Containers extension](https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-containers)
4145
- Open the project in VSCode and select "Reopen in Container" from the command palette (Ctrl+Shift+P)

install.ps1

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ cp "$PSScriptRoot/server/server/config/seniorproject-key.pem.sample" "$PSScriptR
1111
npm install -g prettier
1212

1313
if ($CleanInstall) {
14+
git restore . && git clean -fd
1415
Write-Host "🧹 Cleaning up all installed packages..."
1516
Write-Host "This can take a while..."
1617
Remove-Item -Recurse -Force "$PSScriptRoot/server/node_modules" -ErrorAction SilentlyContinue

install.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@ npm install
66
cd server
77
npm install
88
cd ../ui
9-
npm installl --legacy-peer-deps
9+
npm install --legacy-peer-deps

server/db_setup.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ const DBHandler = require("./server/database/db");
1010
let db = new DBHandler();
1111
const Logger = require("./server/logger");
1212

13-
const table_sql_path = "./server/database/table_sql";
14-
const dummy_data_path = "./server/database/test_data";
13+
const table_sql_path = path.join(__dirname, "server", "database", "table_sql");
14+
const dummy_data_path = path.join(__dirname, "server", "database", "test_data");
1515

1616
// Define dummy files that should be preserved during reset
1717
const PRESERVE_FILES = [

server/main.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,9 @@ app.use(
6161
// Fix for the Content Editor on local development TODO/Important check if there is a better fix and if it breaks in live live
6262
app.use("/resource", express.static(path.join(__dirname, "resource")));
6363

64+
// Serve static files from doc directory TODO/check if this is needed
65+
app.use("/doc", express.static(path.join(__dirname, "doc")));
66+
6467
// This is down here because saml_routes needs to be initialized after the express.urlencoded() middleware to be able to process Shibboleth logins
6568
const routing = require("./server/routing/index");
6669
// Attach route handlers

server/server/database/test_data/actions_dummy.sql

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -958,17 +958,6 @@ VALUES
958958
"",
959959
""
960960
),
961-
(
962-
2,
963-
"Labor Day",
964-
'',
965-
"Labor Day",
966-
"break_period",
967-
strftime("%Y", DATE("now")) || "-09-01",
968-
strftime("%Y", DATE("now")) || "-09-01",
969-
"",
970-
""
971-
),
972961
(
973962
2,
974963
"Thanksgiving Break",

server/server/database/test_data/page_html_dummy.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ INSERT INTO page_html (name, html) VALUES
2222
<div class="row">
2323
<p>
2424
Please reference the&nbsp
25-
<a href="../doc/ProposalInstructions.pdf" target="_blank">
25+
<a href="__SERVER_BASE_URL__/doc/ProposalInstructions.pdf" target="_blank">
2626
proposal instructions
2727
</a>&nbsp
2828
as you prepare your project proposal.

server/server/database/test_data/project_dummy.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ VALUES
182182
),
183183
(
184184
'6_nextwave',
185-
'sumbitted',
185+
'submitted',
186186
'NextWave AR-Based Shopping Assistant for Retail Innovation',
187187
'WaveTech Innovations',
188188
'John Smith',

server/server/database/test_data/user_dummy.sql

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,20 @@ VALUES
2929
'2025-11-30 09:12:34'
3030
),
3131
(
32+
'myeyes',
33+
'Light',
34+
'Mode',
35+
'lma@admin.edu',
36+
'admin',
37+
NULL,
38+
NULL,
39+
'',
40+
0,
41+
'{"additional_info":"", "dark_mode":false, "gantt_view":true, "milestone_view":true, "calendar_view":true}',
42+
'2025-01-10 14:05:12',
43+
'2025-12-20 16:45:00'
44+
),
45+
(
3246
'cave',
3347
'View Only',
3448
'Admin',

server/server/routing/db_routes.js

Lines changed: 59 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -515,6 +515,38 @@ module.exports = (db) => {
515515
return next(error);
516516
}
517517

518+
// Validate that the work date is not in the future
519+
// This prevents users from logging time for dates that haven't occurred yet
520+
const workDate = new Date(req.body.date);
521+
const currentDate = new Date();
522+
const currentDateOnly = new Date(
523+
currentDate.getFullYear(),
524+
currentDate.getMonth(),
525+
currentDate.getDate(),
526+
);
527+
const workDateOnly = new Date(
528+
workDate.getFullYear(),
529+
workDate.getMonth(),
530+
workDate.getDate(),
531+
);
532+
533+
if (workDateOnly > currentDateOnly) {
534+
const error = new Error("Cannot log time for future dates");
535+
error.statusCode = 400;
536+
return next(error);
537+
}
538+
539+
// Validate that the work date is within the past 14 days (2 weeks)
540+
// This maintains the existing business rule about recent time logging
541+
const twoWeeksAgo = new Date(currentDateOnly);
542+
twoWeeksAgo.setDate(twoWeeksAgo.getDate() - 14);
543+
544+
if (workDateOnly < twoWeeksAgo) {
545+
const error = new Error("Cannot log time for dates older than 14 days");
546+
error.statusCode = 400;
547+
return next(error);
548+
}
549+
518550
let mock_id = req.user.mock ? req.user.mock.system_id : "";
519551

520552
const sql = `INSERT INTO time_log
@@ -2353,7 +2385,7 @@ module.exports = (db) => {
23532385
(req, res, next) => {
23542386
calculateActiveTimelines(req.user)
23552387
.then((timelines) => {
2356-
res.send(timelines);
2388+
res.json(timelines);
23572389
})
23582390
.catch((err) => {
23592391
console.error(err);
@@ -2564,6 +2596,29 @@ module.exports = (db) => {
25642596
}
25652597
db.query(getHtmlQuery, queryParams)
25662598
.then((html) => {
2599+
// Replace placeholder with actual server base URL
2600+
const serverBaseUrl =
2601+
process.env.NODE_ENV === "production"
2602+
? process.env.PRODUCTION_SERVER_URL ||
2603+
process.env.BASE_URL ||
2604+
`${req.protocol}://${req.get("host")}`
2605+
: `${req.protocol}://${req.get("host")}`;
2606+
2607+
// Process HTML to replace placeholders
2608+
if (Array.isArray(html)) {
2609+
html = html.map((item) => {
2610+
if (item.html) {
2611+
item.html = item.html.replace(
2612+
/__SERVER_BASE_URL__/g,
2613+
serverBaseUrl,
2614+
);
2615+
}
2616+
return item;
2617+
});
2618+
} else if (html && html.html) {
2619+
html.html = html.html.replace(/__SERVER_BASE_URL__/g, serverBaseUrl);
2620+
}
2621+
25672622
res.send(html);
25682623
})
25692624
.catch((err) => {
@@ -3081,7 +3136,7 @@ module.exports = (db) => {
30813136
(req, res, next) => {
30823137
let getSponsorNotesQuery = `
30833138
SELECT sponsor_notes.*,
3084-
users.fname, users.lname, users.email,
3139+
users.fname, users.lname, users.email, users.type,
30853140
(SELECT users.fname || ' ' || users.lname FROM users WHERE users.system_id = sponsor_notes.mock_id) AS mock_name
30863141
FROM sponsor_notes
30873142
JOIN users
@@ -4213,8 +4268,9 @@ module.exports = (db) => {
42134268
}
42144269

42154270
let getPeerEvalLogsQuery = `
4216-
SELECT *
4271+
SELECT action_log.*, users.fname, users.lname, users.type
42174272
FROM action_log
4273+
LEFT JOIN users ON action_log.system_id = users.system_id
42184274
WHERE action_template IN (${actionIds.join(",")})
42194275
ORDER BY submission_datetime DESC
42204276
`;

0 commit comments

Comments
 (0)