Skip to content

Commit

Permalink
Issue #3150 - "Moderation in process" template
Browse files Browse the repository at this point in the history
  • Loading branch information
ksy36 committed Jan 15, 2020
1 parent 588b1d1 commit 80cc015
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 9 deletions.
11 changes: 11 additions & 0 deletions tests/unit/test_issues.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,16 @@

import unittest
import requests
import json

from mock import patch
from mock import ANY
from werkzeug import MultiDict

from webcompat.issues import report_issue
from webcompat.issues import report_private_issue
from webcompat.issues import report_public_issue
from webcompat.issues import moderation_template


class TestIssue(unittest.TestCase):
Expand Down Expand Up @@ -60,3 +64,10 @@ def test_report_private_issue_returns_nothing(self, mockpost):
('username', ''), ])
rv = report_private_issue(form, 'http://public.example.com')
self.assertIsNone(rv)

@patch.object(requests, 'post')
def test_report_public_issue_returns_moderation_template(self, mockpost):
"""Test that we get a moderation template back from a public issue report.""" # noqa
report_public_issue()
data = json.dumps(moderation_template())
mockpost.assert_called_with(ANY, data=data, headers=ANY, params=ANY)
21 changes: 13 additions & 8 deletions webcompat/issues.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,17 @@
PRIVATE_REPO_URI = app.config['PRIVATE_REPO_URI']


def unmoderated_issue():
def moderation_template():
"""Gets the placeholder data to send for unmoderated issues."""
# TODO: Replace this with something meaningful.
# See https://github.com/webcompat/webcompat.com/issues/3137
summary = 'Placeholder in-moderation title.'
body = 'Placeholder in-moderation body.'

summary = 'In the moderation queue.'
body = """<p>This issue has been put in the moderation queue. A human
will review if the message meets our current
<a href="https://www.mozilla.org/en-US/about/legal/acceptable-use/">
acceptable use</a> guidelines.
It will probably take a couple of days depending on the backlog.
Once it has been reviewed, the content will be either made public
or deleted.</p>"""
return {'title': summary, 'body': body}


Expand All @@ -47,13 +52,13 @@ def report_private_issue(form, public_url):
return None


def report_public_issue(form):
def report_public_issue():
"""Report the issue publicly.
Returns a requests.Response object.
"""
path = 'repos/{0}'.format(REPO_URI)
return proxy_request('post', path, data=json.dumps(unmoderated_issue()))
return proxy_request('post', path, data=json.dumps(moderation_template()))


def report_issue(form, proxy=False):
Expand All @@ -62,7 +67,7 @@ def report_issue(form, proxy=False):
path = 'repos/{0}'.format(REPO_URI)
submit_type = form.get('submit_type')
if proxy and submit_type == 'github-proxy-report':
response = report_public_issue(form)
response = report_public_issue()
if (response.status_code == 201):
json_response = response.json()
report_private_issue(form, json_response.get('html_url'))
Expand Down
2 changes: 1 addition & 1 deletion webcompat/static/css/src/issue.css
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@
}

.issue-details {
word-break: break-all;
word-break: break-word;
}

.issue-details-nsfw {
Expand Down

0 comments on commit 80cc015

Please sign in to comment.