Skip to content

Commit

Permalink
fixed review comments and add UserGuide
Browse files Browse the repository at this point in the history
  • Loading branch information
arjuanwall committed Feb 28, 2025
1 parent 24b5651 commit edc248f
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 1 deletion.
9 changes: 9 additions & 0 deletions UserGuide.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
UserGuide.md:

In test/goodQuestion.js, you are able to run a test that checks that, when clicking the Green Check-Mark next to the upvote
button on any particular post, it is marked as a "Good Question" by NodeBB. This test is sufficient for covering the change I made
as this is the only feature implemented; I did not work on "un-voting" or any other feature.

![Post](/img1.png)

![Voting](/img2.png)
Binary file added img1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 0 additions & 1 deletion nodebb-theme-harmony/scss/topic.scss
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ body.template-topic {
[component="post/upvote"],
[component="post/downvote"],
[component="post/goodquestion"] {

&.upvoted,
&.downvoted,
&.goodquestioned {
Expand Down
1 change: 1 addition & 0 deletions public/language/en-GB/admin/manage/privileges.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
"view-deleted": "View Deleted Posts",
"upvote-posts": "Upvote Posts",
"downvote-posts": "Downvote Posts",
"goodquestion-posts": "Mark as Good Question",
"delete-topics": "Delete Topics",
"purge": "Purge",
"moderate": "Moderate",
Expand Down
2 changes: 2 additions & 0 deletions src/posts/votes.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ module.exports = function (Posts) {
}
}

// Marks the specified post as a good question if the user has the required privileges and isn't already marking it.
Posts.goodquestion = async function (pid, uid) {
const canMark = await privileges.posts.can('posts:goodquestion', pid, uid);
if (!canMark) {
Expand All @@ -128,6 +129,7 @@ module.exports = function (Posts) {
return { goodquestion: true };
};

// Checks if a user has already marked the specified post as a good question by verifying their membership in a corresponding database set.

Check failure on line 132 in src/posts/votes.js

View workflow job for this annotation

GitHub Actions / test

This line has a length of 141. Maximum allowed is 120
Posts.hasMarkedGood = async function (pid, uid) {
if (parseInt(uid, 10) <= 0) {
return { goodquestion: false };
Expand Down

0 comments on commit edc248f

Please sign in to comment.