Skip to content

Commit 21021eb

Browse files
authored
Merge pull request #510 from ComputerScienceHouse/mp-form-fixes
Mp form fixes
2 parents 165e656 + 7cc4f84 commit 21021eb

File tree

4 files changed

+41
-11
lines changed

4 files changed

+41
-11
lines changed

conditional/blueprints/major_project_submission.py

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -165,12 +165,16 @@ def submit_major_project(user_dict=None):
165165

166166

167167
# Send the slack ping only after we know that the data was properly saved to the DB
168-
send_slack_ping(
169-
{
170-
"text": f"<!subteam^S5XENJJAH> *{get_member_name(user_id)}* ({user_id})"
171-
f" submitted their major project, *{name}*!"
172-
}
173-
)
168+
if app.config['DEV_DISABLE_SLACK_PING']:
169+
log.info("Slack ping skipped due to environment override")
170+
else:
171+
send_slack_ping(
172+
{
173+
"text": f"<!subteam^S5XENJJAH> *{get_member_name(user_id)}* ({user_id})"
174+
f" submitted their major project, *{name}*!"
175+
}
176+
)
177+
174178

175179
return jsonify({"success": True}), 200
176180

config.env.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
IP = env.get("CONDITIONAL_IP", "0.0.0.0")
1616
PORT = env.get("CONDITIONAL_PORT", 6969)
1717
WEBHOOK_URL = env.get("CONDITIONAL_WEBHOOK_URL", "INSERT URL HERE")
18+
DEV_DISABLE_SLACK_PING = env.get("DEV_DISABLE_SLACK_PING", "false") == "true"
1819
PROFILING = env.get("CONDITIONAL_PROFILING", "false").lower() == "true"
1920

2021
# DB Info

frontend/javascript/modules/majorProjectForm.js

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -57,15 +57,33 @@ export default class MajorProjectForm {
5757
skills.push(tag.textContent);
5858
}
5959

60+
let projectName = this.form.querySelector('input[name=name]').value;
61+
let projectTldr = this.form.querySelector('input[name=tldr]').value;
62+
let projectTimeSpent = this.form.querySelector('textarea[name=time-commitment]').value;
63+
let projectDescription = this.form.querySelector('textarea[name=description]').value;
64+
let projectLinks = this.form.querySelector('textarea[name=links]').value;
65+
66+
// For each field, if it is not empty, trim it.
67+
if (projectName !== "") projectName = projectName.trim();
68+
if (projectTldr !== "") projectTldr = projectTldr.trim();
69+
if (projectTimeSpent !== "") projectTimeSpent = projectTimeSpent.trim();
70+
if (projectDescription !== "") projectDescription = projectDescription.trim();
71+
72+
if (!projectName || !projectTldr || !projectTimeSpent || !projectDescription || skills.length === 0) {
73+
alert("Error: At least one required field is empty. \n\nProject Name, TLDR, Time Commitment, Description, and at least one skill are required.");
74+
return;
75+
}
76+
6077
let payload = {
61-
projectName: this.form.querySelector('input[name=name]').value,
62-
projectTldr: this.form.querySelector('input[name=tldr]').value,
63-
projectTimeSpent: this.form.querySelector('textarea[name=time-commitment]').value,
78+
projectName: projectName,
79+
projectTldr: projectTldr,
80+
projectTimeSpent: projectTimeSpent,
6481
projectSkills: skills,
65-
projectDescription: this.form.querySelector('textarea[name=description]').value,
66-
projectLinks: this.form.querySelector('textarea[name=links]').value
82+
projectDescription: projectDescription,
83+
projectLinks: projectLinks
6784
};
6885

86+
6987
console.log(payload)
7088

7189
FetchUtil.postWithWarning(this.endpoint, payload, {

frontend/stylesheets/pages/_major-project.scss

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,4 +132,11 @@
132132

133133
.no-imgs {
134134
margin-left: 0.2em;
135+
}
136+
137+
label:has(+ input:required):after,
138+
label:has(+ textarea:required):after,
139+
label:has(+ div input[name="skill"]:required)::after {
140+
content: ' *';
141+
color: red;
135142
}

0 commit comments

Comments
 (0)