Skip to content

Commit

Permalink
badge backend
Browse files Browse the repository at this point in the history
  • Loading branch information
laxyapahuja committed Sep 2, 2020
1 parent 82ea78a commit 245106a
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 17 deletions.
6 changes: 3 additions & 3 deletions models/User.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,16 +47,16 @@ const UserSchema = new mongoose.Schema({
default: Date.now
},
badge: {
type: Boolean,
default: false
type: Array,
required: true
},
premium: {
type: Boolean,
default: false
},
ratingData: {
type: Object,
required: true
default: {}
},
reputation: {
type: Number,
Expand Down
3 changes: 1 addition & 2 deletions public/css/badge.css
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@ div {
border-radius: 10px;
border-style: solid;
border-color: black;
margin-left: 10rem;
padding-left: 30px;
padding-left: 20px;
font-family: 'Lexend Deca';
}

Expand Down
19 changes: 9 additions & 10 deletions routes/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -426,18 +426,17 @@ router.post('/rate-portfolio', ensureAuthenticated, (req, res) => {
})
})

router.get('/badge', (req, res) => {
res.render('badge', {layout: false})
})

router.get('/users/:username', async (req, res) => {
const user = await User.findOne({ 'username': req.params.username});
if (user.badge) {
res.render('badge', {user: user, layout: false})
}
else {
res.sendStatus(404)
}
postId = user.badge[0]
Post.findById(postId, (err, post) => {
if (user.badge[0]) {
res.render('badge', {user: user, layout: false, post: post})
}
else {
res.sendStatus(404)
}
})
})

module.exports = router;
4 changes: 2 additions & 2 deletions views/badge.ejs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Lexend Deca">
<link rel="stylesheet" type="text/css" href="/css/badge.css" />
<div>
<p>Hey! Just wanted to let you <br> know that <span style="color: black">10,000 people</span> have <br> told us that Rachit Gupta <br>deserves <span style="color: black">atleast $26.00/hr</span>.</p>
<p>Hey! Just wanted to let you <br> know that <span style="color: black"><%- post.reviewers %> people</span> have <br> told us that <%- user.name %> <br>deserves <span style="color: black">atleast $<%- post.rating%>/hr</span>.</p>
<img src="https://cdn.discordapp.com/attachments/749131929982599238/750569597912219648/unknown.png"><br>
<p id="small-text">you can check their portfolio at <a style="color: black" href="https://rachitgupta.co">https://rachitgupta.co</a></p>
<p id="small-text">you can check their portfolio at <a style="color: black" href="<%- post.portfolio_link%>"><%- post.portfolio_link%></a></p>
</div>

0 comments on commit 245106a

Please sign in to comment.