Skip to content

Commit

Permalink
Added price in course creation page (#54)
Browse files Browse the repository at this point in the history
  • Loading branch information
Artlfmj authored Oct 16, 2023
2 parents 21835a4 + 2a563fe commit 7d4527a
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
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

0 comments on commit 7d4527a

Please sign in to comment.