-
Notifications
You must be signed in to change notification settings - Fork 427
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Send flag notification emails to moderators
Send flag notification emails to all of a group's moderators rather than just to the group's creator. Also allow all moderators to moderate (hide) flagged annotations, not just the creator.
- Loading branch information
Showing
10 changed files
with
237 additions
and
138 deletions.
There are no files selected for viewing
This file contains 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 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 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 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 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 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 |
---|---|---|
@@ -1,44 +1,23 @@ | ||
import pytest | ||
from h.models import GroupMembership, GroupMembershipRoles | ||
|
||
|
||
class TestModeration: | ||
def test_moderator_flag_listing( | ||
self, app, flagged_annotation, moderator_with_token | ||
): | ||
_, token = moderator_with_token | ||
|
||
headers = {"Authorization": f"Bearer {token.value}"} | ||
annotation_url = f"/api/annotations/{flagged_annotation.id}" | ||
res = app.get(annotation_url, headers=headers) | ||
|
||
assert "moderation" in res.json | ||
assert res.json["moderation"]["flagCount"] > 0 | ||
|
||
|
||
@pytest.fixture | ||
def group(db_session, factories, moderator): | ||
group = factories.OpenGroup(creator=moderator) | ||
db_session.commit() | ||
return group | ||
|
||
|
||
@pytest.fixture | ||
def flagged_annotation(group, db_session, factories): | ||
ann = factories.Annotation(groupid=group.pubid, shared=True) | ||
factories.Flag(annotation=ann) | ||
db_session.commit() | ||
return ann | ||
|
||
|
||
@pytest.fixture | ||
def moderator(db_session, factories): | ||
user = factories.User() | ||
db_session.commit() | ||
return user | ||
|
||
|
||
@pytest.fixture | ||
def moderator_with_token(moderator, db_session, factories): | ||
token = factories.DeveloperToken(user=moderator) | ||
db_session.commit() | ||
return (moderator, token) | ||
def test_it(self, app, db_session, factories): | ||
group = factories.OpenGroup() | ||
annotation = factories.Annotation(group=group, shared=True) | ||
factories.Flag(annotation=annotation) | ||
moderator = factories.User( | ||
memberships=[ | ||
GroupMembership(group=group, roles=[GroupMembershipRoles.MODERATOR]) | ||
] | ||
) | ||
token = factories.DeveloperToken(user=moderator) | ||
db_session.commit() | ||
|
||
response = app.get( | ||
f"/api/annotations/{annotation.id}", | ||
headers={"Authorization": f"Bearer {token.value}"}, | ||
) | ||
|
||
assert "moderation" in response.json | ||
assert response.json["moderation"]["flagCount"] > 0 |
This file contains 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 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 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.