bye REPORT_ABUSE flag, I barely knew you (bug 668346)
This commit is contained in:
Родитель
4cc7d049a0
Коммит
47bafe1e62
|
@ -20,7 +20,7 @@ from pyquery import PyQuery as pq
|
|||
import amo
|
||||
from amo.helpers import absolutify
|
||||
from amo.urlresolvers import reverse
|
||||
from amo.tests.test_helpers import AbuseBase, AbuseDisabledBase
|
||||
from amo.tests.test_helpers import AbuseBase
|
||||
from addons.models import Addon, AddonUser, Charity
|
||||
from files.models import File
|
||||
from paypal.tests import other_error
|
||||
|
@ -1205,7 +1205,6 @@ class TestReportAbuse(AbuseBase, test_utils.TestCase):
|
|||
'base/users']
|
||||
|
||||
def setUp(self):
|
||||
settings.REPORT_ABUSE = True
|
||||
settings.RECAPTCHA_PRIVATE_KEY = 'something'
|
||||
self.full_page = reverse('addons.abuse', args=['a3615'])
|
||||
|
||||
|
@ -1233,26 +1232,6 @@ class TestReportAbuse(AbuseBase, test_utils.TestCase):
|
|||
assert 'spammy' in mail.outbox[0].body
|
||||
|
||||
|
||||
class TestReportAbuseDisabled(AbuseDisabledBase, test_utils.TestCase):
|
||||
fixtures = ['addons/persona',
|
||||
'base/apps',
|
||||
'base/addon_3615',
|
||||
'base/users']
|
||||
|
||||
def setUp(self):
|
||||
settings.REPORT_ABUSE = False
|
||||
self.full_page = reverse('addons.abuse', args=['a3615'])
|
||||
self.inline_page = reverse('addons.detail', args=['a3615'])
|
||||
|
||||
def tearDown(self):
|
||||
settings.REPORT_ABUSE = True
|
||||
|
||||
def test_abuse_persona(self):
|
||||
r = self.client.get(reverse('addons.detail', args=['a15663']))
|
||||
doc = pq(r.content)
|
||||
assert not doc("fieldset.abuse")
|
||||
|
||||
|
||||
class TestMobile(test_utils.TestCase):
|
||||
fixtures = ['addons/featured', 'base/apps', 'base/addon_3615',
|
||||
'base/featured', 'bandwagon/featured_collections']
|
||||
|
|
|
@ -165,9 +165,8 @@ def extension_detail(request, addon):
|
|||
'get_replies': Review.get_replies,
|
||||
|
||||
'collections': collections.order_by('-subscribers')[:3],
|
||||
'abuse_form': AbuseForm(request=request),
|
||||
}
|
||||
if settings.REPORT_ABUSE:
|
||||
data['abuse_form'] = AbuseForm(request=request)
|
||||
|
||||
return jingo.render(request, 'addons/details.html', data)
|
||||
|
||||
|
@ -212,9 +211,8 @@ def impala_extension_detail(request, addon):
|
|||
'reviews': Review.objects.latest().filter(addon=addon),
|
||||
'get_replies': Review.get_replies,
|
||||
'collections': collections.order_by('-subscribers')[:3],
|
||||
'abuse_form': AbuseForm(request=request),
|
||||
}
|
||||
if settings.REPORT_ABUSE:
|
||||
ctx['abuse_form'] = AbuseForm(request=request)
|
||||
|
||||
return jingo.render(request, 'addons/impala/details.html', ctx)
|
||||
|
||||
|
@ -268,10 +266,10 @@ def persona_detail(request, addon, template=None):
|
|||
'review_form': ReviewForm(),
|
||||
'reviews': Review.objects.latest().filter(addon=addon),
|
||||
'get_replies': Review.get_replies,
|
||||
'search_cat': 'personas'
|
||||
'search_cat': 'personas',
|
||||
'abuse_form': AbuseForm(request=request),
|
||||
})
|
||||
if settings.REPORT_ABUSE:
|
||||
data['abuse_form'] = AbuseForm(request=request)
|
||||
|
||||
return jingo.render(request, template, data)
|
||||
|
||||
|
||||
|
@ -431,8 +429,9 @@ def home(request):
|
|||
# Get some featured add-ons with randomness.
|
||||
featured = Addon.featured_random(request.APP, request.LANG)
|
||||
# Get 10 popular add-ons, then pick 3 at random.
|
||||
qs = list(Addon.objects.listed(request.APP).order_by('-average_daily_users')
|
||||
.values_list('id', flat=True)[:10])
|
||||
qs = list(Addon.objects.listed(request.APP)
|
||||
.order_by('-average_daily_users')
|
||||
.values_list('id', flat=True)[:10])
|
||||
popular = rand(qs)
|
||||
# Do one query and split up the add-ons.
|
||||
addons = Addon.objects.filter(id__in=featured + popular)
|
||||
|
@ -752,9 +751,6 @@ def license_redirect(request, version):
|
|||
@session_csrf.anonymous_csrf_exempt
|
||||
@addon_view
|
||||
def report_abuse(request, addon):
|
||||
if not settings.REPORT_ABUSE:
|
||||
raise http.Http404()
|
||||
|
||||
form = AbuseForm(request.POST or None, request=request)
|
||||
if request.method == "POST" and form.is_valid():
|
||||
url = reverse('addons.detail', args=[addon.slug])
|
||||
|
|
|
@ -152,7 +152,7 @@ def test_url(mock_reverse):
|
|||
mock_reverse.assert_called_with('viewname', args=(1,), kwargs={'z': 2},
|
||||
add_prefix=True)
|
||||
|
||||
s = render('{{ url("viewname", 1, z=2, host="myhost") }}')
|
||||
render('{{ url("viewname", 1, z=2, host="myhost") }}')
|
||||
mock_reverse.assert_called_with('viewname', args=(1,), kwargs={'z': 2},
|
||||
add_prefix=True)
|
||||
|
||||
|
@ -323,25 +323,6 @@ class AbuseBase:
|
|||
assert 'spammy' in mail.outbox[0].body
|
||||
|
||||
|
||||
class AbuseDisabledBase:
|
||||
def test_abuse_fails_anonymous(self):
|
||||
r = self.client.get(self.inline_page)
|
||||
doc = PyQuery(r.content)
|
||||
assert not doc("fieldset.abuse")
|
||||
|
||||
res = self.client.post(self.full_page, {'text': 'spammy'})
|
||||
eq_(res.status_code, 404)
|
||||
|
||||
def test_abuse_fails_logged_in(self):
|
||||
self.client.login(username='regular@mozilla.com', password='password')
|
||||
r = self.client.get(self.inline_page)
|
||||
doc = PyQuery(r.content)
|
||||
assert not doc("fieldset.abuse")
|
||||
|
||||
res = self.client.post(self.full_page)
|
||||
eq_(res.status_code, 404)
|
||||
|
||||
|
||||
def get_image_path(name):
|
||||
return os.path.join(settings.ROOT, 'apps', 'amo', 'tests', 'images', name)
|
||||
|
||||
|
|
|
@ -17,7 +17,7 @@ import amo
|
|||
from amo.helpers import urlparams
|
||||
from amo.pyquery_wrapper import PyQuery
|
||||
from amo.urlresolvers import reverse
|
||||
from amo.tests.test_helpers import AbuseBase, AbuseDisabledBase
|
||||
from amo.tests.test_helpers import AbuseBase
|
||||
from users.models import BlacklistedPassword, UserProfile
|
||||
from users.utils import EmailResetCode
|
||||
|
||||
|
@ -374,18 +374,5 @@ class TestReportAbuse(AbuseBase, test_utils.TestCase):
|
|||
fixtures = ['base/users']
|
||||
|
||||
def setUp(self):
|
||||
settings.REPORT_ABUSE = True
|
||||
settings.RECAPTCHA_PRIVATE_KEY = 'something'
|
||||
self.full_page = reverse('users.abuse', args=[10482])
|
||||
|
||||
|
||||
class TestReportAbuseDisabled(AbuseDisabledBase, test_utils.TestCase):
|
||||
fixtures = ['base/users']
|
||||
|
||||
def setUp(self):
|
||||
settings.REPORT_ABUSE = False
|
||||
self.inline_page = reverse('users.profile', args=[10482])
|
||||
self.full_page = reverse('users.abuse', args=[10482])
|
||||
|
||||
def tearDown(self):
|
||||
settings.REPORT_ABUSE = True
|
||||
|
|
|
@ -227,7 +227,7 @@ def _clean_next_url(request):
|
|||
|
||||
gets['to'] = url
|
||||
|
||||
domain = gets.get('domain',None)
|
||||
domain = gets.get('domain', None)
|
||||
if domain in settings.VALID_LOGIN_REDIRECTS.keys():
|
||||
gets['to'] = "%s%s" % (settings.VALID_LOGIN_REDIRECTS[domain], url)
|
||||
|
||||
|
@ -251,8 +251,9 @@ def login(request):
|
|||
|
||||
if isinstance(r, http.HttpResponseRedirect):
|
||||
# Django's auth.views.login has security checks to prevent someone from
|
||||
# redirecting to another domain. Since we want to allow this in certain
|
||||
# cases, we have to make a new response object here to replace the above
|
||||
# redirecting to another domain. Since we want to allow this in
|
||||
# certain cases, we have to make a new response object here to replace
|
||||
# the above.
|
||||
if 'domain' in request.GET:
|
||||
request.GET = get_copy
|
||||
request = _clean_next_url(request)
|
||||
|
@ -260,7 +261,7 @@ def login(request):
|
|||
|
||||
# Succsesful log in according to django. Now we do our checks. I do
|
||||
# the checks here instead of the form's clean() because I want to use
|
||||
# the messages framework and it's not available in the request there
|
||||
# the messages framework and it's not available in the request there.
|
||||
user = request.user.get_profile()
|
||||
|
||||
if user.deleted:
|
||||
|
@ -362,10 +363,8 @@ def profile(request, user_id):
|
|||
|
||||
data = {'profile': user, 'own_coll': own_coll, 'reviews': reviews,
|
||||
'fav_coll': fav_coll, 'edit_any_user': edit_any_user,
|
||||
'addons': addons, 'own_profile': own_profile}
|
||||
|
||||
if settings.REPORT_ABUSE:
|
||||
data['abuse_form'] = AbuseForm(request=request)
|
||||
'addons': addons, 'own_profile': own_profile,
|
||||
'abuse_form': AbuseForm(request=request)}
|
||||
|
||||
return jingo.render(request, 'users/profile.html', data)
|
||||
|
||||
|
@ -423,9 +422,6 @@ def register(request):
|
|||
|
||||
@anonymous_csrf_exempt
|
||||
def report_abuse(request, user_id):
|
||||
if not settings.REPORT_ABUSE:
|
||||
raise http.Http404()
|
||||
|
||||
user = get_object_or_404(UserProfile, pk=user_id)
|
||||
form = AbuseForm(request.POST or None, request=request)
|
||||
if request.method == "POST" and form.is_valid():
|
||||
|
|
|
@ -919,9 +919,6 @@ PERFORMANCE_NOTES = False
|
|||
|
||||
PERF_THRESHOLD = 25
|
||||
|
||||
# flag to turn on or off Abuse reports
|
||||
REPORT_ABUSE = True
|
||||
|
||||
REDIS_BACKENDS = {'master': 'redis://localhost:6379?socket_timeout=0.5'}
|
||||
|
||||
# Directory of JavaScript test files for django_qunit to run
|
||||
|
|
Загрузка…
Ссылка в новой задаче