-
Notifications
You must be signed in to change notification settings - Fork 6
[FEATURE] Mark as Solution #271
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
Open
mystique09
wants to merge
20
commits into
main
Choose a base branch
from
feat/mark-as-solution
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
2b55169
feat: add context menu for accepting solutions in forum threads
mystique09 ab09bcd
feat: add migration for enabling solution acceptance in forum threads
mystique09 ab34231
feat: update migration to add enable_accept_solutions column and enha…
mystique09 c1f2752
feat: implement acceptance solution functionality in forum posts
mystique09 7edc4a1
feat: add MarkAsSolution view and integrate acceptance feature in pos…
mystique09 22942b7
feat: enhance accept solution functionality in forum threads with con…
mystique09 d813c11
feat: add update_user_mark_as_solution method to mark posts as soluti…
mystique09 3c6ef90
feat: add confirmation message for solution acceptance in MarkAsSolut…
mystique09 42c3b88
feat: enhance solution marking functionality with thread author check…
mystique09 5df2d8b
refactor: mark as solution now uses the pinned messages to check if t…
mystique09 df72e5e
chore: updated deps
mystique09 8221b15
add: ignore test files
mystique09 794970e
feature: combine /dev-help and /forum-assist
mystique09 065ce0a
add: sample test for prefix and slash command
mystique09 94c0ff2
fix: remove set_config, non-existent method
mystique09 025a2c0
chore: remove configure command
mystique09 ea8563c
chore: update message
mystique09 c88943d
fix: config file
mystique09 19b570f
feat: add enable_mark_as_solved functionality and database support
mystique09 82318ff
fix: mark as solved and accept solution
mystique09 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
-- depends: 18_post_assist | ||
ALTER TABLE pph_post_assist_config | ||
ADD COLUMN IF NOT EXISTS enable_accept_solutions BOOLEAN DEFAULT FALSE; | ||
|
||
CREATE TABLE | ||
IF NOT EXISTS pph_post_assist_config_accept_solutions ( | ||
id SERIAL PRIMARY KEY, | ||
thread_id BIGINT NOT NULL, | ||
post_assist_config_id SERIAL NOT NULL, | ||
user_id BIGINT NOT NULL, | ||
message_id BIGINT NOT NULL, | ||
FOREIGN KEY (post_assist_config_id) REFERENCES pph_post_assist_config (id) ON DELETE CASCADE | ||
); | ||
|
||
ALTER TABLE pph_post_assist_config_accept_solutions | ||
ADD COLUMN IF NOT EXISTS message_id BIGINT NOT NULL; | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
-- depends: 21_add_enable_accept_solutions | ||
DROP TABLE IF EXISTS pph_post_assist_config_accept_solutions; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
-- depends: 18_post_assist | ||
ALTER TABLE pph_post_assist_config | ||
ADD COLUMN IF NOT EXISTS enable_mark_as_solved BOOLEAN DEFAULT FALSE; |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"venvPath": ".", | ||
"venv": "C:/Users/benji/AppData/Local/pypoetry/Cache/virtualenvs/progphilbot-QxuRZnFx-py3.12" | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
import unittest | ||
from unittest.async_case import IsolatedAsyncioTestCase | ||
from unittest.mock import AsyncMock, MagicMock, patch | ||
|
||
from discord import Interaction | ||
from discord.app_commands import Choice | ||
|
||
from src.cogs.admin.announcements import Announcements | ||
from src.ui.modals.announcement import Announcement | ||
|
||
|
||
class TestAnnouncements(IsolatedAsyncioTestCase): | ||
@patch("src.cogs.admin.announcements.Announcement.wait", new_callable=AsyncMock) | ||
async def test_announce_command(self, mock_wait): | ||
mock_bot = MagicMock() | ||
mock_interaction = AsyncMock(specs=Interaction) | ||
mock_interaction.response = AsyncMock() | ||
mock_interaction.response.send_modal = AsyncMock() | ||
mock_interaction.user = MagicMock() | ||
mock_interaction.user.name = "test_user" | ||
|
||
mock_channel = MagicMock() | ||
mock_channel.name = "test_channel" | ||
mock_channel.send = MagicMock() | ||
|
||
mock_photo = MagicMock() | ||
mock_photo.filename = "image.jpg" | ||
# mock_photo.filename.value = "image.jpg" | ||
|
||
cog = Announcements(mock_bot) | ||
mock_logger = MagicMock() | ||
mock_logger.info = MagicMock() | ||
cog.logger = mock_logger | ||
|
||
mock_mention = MagicMock() | ||
mock_mention.mention = "<@1234567890>" | ||
mock_mention.value = "1234567890" | ||
|
||
mock_submission_type = MagicMock() | ||
mock_submission_type.value = "regular" | ||
|
||
await cog.announce.callback(cog,interaction=mock_interaction, submission_type=mock_submission_type, channel=mock_channel, photo=mock_photo, mention=mock_mention) | ||
|
||
mock_interaction.response.send_modal.assert_awaited_once() | ||
|
||
cog.logger.info.assert_called_once_with(f"A announcement was made by {mock_interaction.user} in {mock_channel.name}") | ||
sent_modal = mock_interaction.response.send_modal.call_args[0][0] | ||
|
||
self.assertIsInstance(sent_modal, Announcement) | ||
mock_wait.assert_awaited_once() | ||
|
||
if __name__ == "__main__": | ||
unittest.main() |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.