Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added price in course creation page #54

Merged
merged 1 commit into from
Oct 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions src/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ app.get("/create-course", csrfProtection, limiter, isAuthenticated, async functi
app.post("/create-course", limiter, isAuthenticated, csrfProtection, async function (req, res) {
// TODO: Need to implement upload image logic
try {
const { courseName, shortDescription, longDescription, duration, durationType, imageFile, difficulty } = req.body;
const { courseName, shortDescription, longDescription, duration, durationType, imageFile, difficulty, price } = req.body;
const userName = req.user.fullName;
const findExistingCourse = await courseModel.findOne({ title: {'$regex': `^${courseName}$`, $options: 'i'} });
if (!findExistingCourse) {
Expand All @@ -101,7 +101,8 @@ app.post("/create-course", limiter, isAuthenticated, csrfProtection, async funct
durationType: durationType?.toLowerCase(),
difficulty: difficulty,
image: imageFile,
author: userName
author: userName,
price: price
});

await newCourse.save();
Expand Down
3 changes: 3 additions & 0 deletions src/db/courseDB.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ const courseSchema = new mongoose.Schema({
author: {
type: String,
},
price: {
type: Number
}
// Add more fields as needed
});

Expand Down
9 changes: 9 additions & 0 deletions src/views/course-create.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,15 @@
</div>
</div>
</div>
<div class="row">
<div class="col-12">Price</div>
<div class="col-lg-12 col-md-12 col-sm-12">
<div class="form-group">
<input type="number" name="price" step="0.01" class="form-control wizard-required" />
<div class="wizard-form-error"></div>
</div>
</div>
</div>
<div class="form-group clearfix">
<a href="javascript:;" class="form-wizard-previous-btn float-left">Previous</a>
<button type="submit" class="form-wizard-submit float-right">Submit</button>
Expand Down