-
Notifications
You must be signed in to change notification settings - Fork 35
Rename Feedback model to CampFeedback and update backoffice feedback handling #2001
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
Merged
Merged
Changes from 12 commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
3d33c81
Change truncateword from 12 to 25
0xUnicorn 6c6a781
Add new state charfield with choices
0xUnicorn e0c27aa
Add state column and refactor processing function in admin panel
0xUnicorn 8dbaf31
Add state column to table
0xUnicorn e735ea9
Add PoC for using a 'state' parameter in forms and urls
0xUnicorn 7b0a161
Change state to use a TextChoices class for choices with a test.
0xUnicorn e358942
Add 'process_feedback' method and implement it in 'ProcessView'.
0xUnicorn 0da1618
Implement invalid state handling by try/except and rename template
0xUnicorn a676961
Template changes
0xUnicorn 009e43a
Rename Feedback model to CampFeedback.
0xUnicorn 97e4fd7
Fix missing linebreaks in confirm page.
0xUnicorn 525e73f
Fix template with wrong name after changing Model name
0xUnicorn a2c9ac8
Apply suggestion from @tykling
tykling 9ad303a
Merge branch 'main' into feature/event-feedback-spam
tykling 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
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
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,79 @@ | ||
|
|
||
| from django.urls import reverse | ||
| from feedback.models import CampFeedback | ||
| from utils.tests import BornhackTestBase | ||
|
|
||
|
|
||
| class TestCampFeedbackProcessView(BornhackTestBase): | ||
| """Test CampFeedbackProcessView.""" | ||
|
|
||
| @classmethod | ||
| def setUpTestData(cls) -> None: | ||
| """Test setup.""" | ||
| super().setUpTestData() | ||
| cls.feedback = CampFeedback.objects.create( | ||
| camp=cls.camp, | ||
| user=cls.users[0], | ||
| feedback="Test Feedback" | ||
| ) | ||
|
|
||
| cls.admin = cls.users["admin"] | ||
| cls.kwargs = { | ||
| "camp_slug": cls.camp.slug, | ||
| "pk": cls.feedback.pk, | ||
| "state": "reviewed" | ||
| } | ||
|
|
||
| def test_admin_processing_feedback_as_reviewed(self) -> None: | ||
| """Test admin user processing feedback as reviewed.""" | ||
| self.client.force_login(self.admin) | ||
| url = reverse("backoffice:feedback_process", kwargs=self.kwargs) | ||
|
|
||
| self.client.post(url) | ||
| self.feedback.refresh_from_db() | ||
|
|
||
| assert self.feedback.state == CampFeedback.StateChoices.REVIEWED | ||
|
|
||
| def test_admin_processing_feedback_as_spam(self) -> None: | ||
| """Test admin user processing feedback as spam.""" | ||
| self.client.force_login(self.admin) | ||
| self.kwargs.update({"state": "spam"}) | ||
| url = reverse("backoffice:feedback_process", kwargs=self.kwargs) | ||
|
|
||
| self.client.post(url) | ||
| self.feedback.refresh_from_db() | ||
|
|
||
| assert self.feedback.state == CampFeedback.StateChoices.SPAM | ||
|
|
||
| def test_admin_resets_feedback_as_unprocessed(self) -> None: | ||
| """Test admin user resets feedback as unprocessed.""" | ||
| self.client.force_login(self.admin) | ||
| self.kwargs.update({"state": "unprocessed"}) | ||
| url = reverse("backoffice:feedback_process", kwargs=self.kwargs) | ||
|
|
||
| self.client.post(url) | ||
| self.feedback.refresh_from_db() | ||
|
|
||
| assert self.feedback.state == CampFeedback.StateChoices.UNPROCESSED | ||
|
|
||
| def test_bad_request_processing_feedback_with_invalid_state(self) -> None: | ||
| """ | ||
| Test processing feedback with invalid state return BadRequest. | ||
| """ | ||
| self.client.force_login(self.admin) | ||
| self.kwargs.update({"state": "unknown"}) | ||
| url = reverse("backoffice:feedback_process", kwargs=self.kwargs) | ||
|
|
||
| response = self.client.post(url) | ||
|
|
||
| assert response.status_code == 400 | ||
|
|
||
| def test_bad_request_requesting_view_with_invalid_state(self) -> None: | ||
| """Test `GET` request to view with invalid state return BadRequest.""" | ||
| self.client.force_login(self.admin) | ||
| self.kwargs.update({"state": "unknown"}) | ||
| url = reverse("backoffice:feedback_process", kwargs=self.kwargs) | ||
|
|
||
| response = self.client.get(url) | ||
|
|
||
| assert response.status_code == 400 |
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
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
Oops, something went wrong.
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.