Fixed flagging reviews on marketplace (bugs 755919, 767128)

This commit is contained in:
Matt Basta 2012-07-12 16:03:09 -07:00
Родитель d3c99336d6
Коммит addc69ef11
3 изменённых файлов: 25 добавлений и 11 удалений

Просмотреть файл

@ -8,7 +8,7 @@ from addons.models import Addon
import amo
from amo.helpers import numberfmt
import amo.tests
from reviews.models import Review
from reviews.models import Review, ReviewFlag
from users.models import UserProfile
from mkt.developers.models import ActivityLog
@ -308,3 +308,25 @@ class TestListing(ReviewTest):
eq_(self.get_flags(reviews.find('#review-218468 .actions')),
['delete', 'edit'])
class TestFlag(ReviewTest):
def setUp(self):
super(TestFlag, self).setUp()
self.user = UserProfile.objects.get(email='root_x@ukr.net')
assert self.client.login(username=self.user.email, password='password')
self.flag = self.webapp.get_ratings_url('flag', [218468])
def test_no_login(self):
self.client.logout()
response = self.client.post(self.flag)
eq_(response.status_code, 401)
def test_new_flag(self):
response = self.client.post(self.flag, {'flag': ReviewFlag.SPAM})
eq_(response.status_code, 200)
eq_(response.content, '{"msg": "Thanks; this review has been '
'flagged for editor approval."}')
eq_(ReviewFlag.objects.filter(flag=ReviewFlag.SPAM).count(), 1)
eq_(Review.objects.filter(editorreview=True).count(), 1)

Просмотреть файл

@ -1,6 +1,6 @@
from django.conf.urls.defaults import patterns, url, include
from reviews.views import delete as amo_delete
from reviews.views import delete as amo_delete, flag as amo_flag
from reviews.feeds import ReviewsRss
from . import views
@ -9,7 +9,7 @@ from . import views
# These all start with /apps/<app_slug>/reviews/<review_id>/.
detail_patterns = patterns('',
url('^$', views.review_list, name='ratings.detail'),
url('^flag$', views.flag, name='ratings.flag'),
url('^flag$', amo_flag, name='ratings.flag'),
url('^delete$', amo_delete, name='ratings.delete'),
url('^edit$', views.edit, name='ratings.edit'),
url('^reply$', views.reply, name='ratings.reply'),

Просмотреть файл

@ -70,14 +70,6 @@ def review_list(request, addon, review_id=None, user_id=None, rating=None):
return jingo.render(request, 'ratings/listing.html', ctx)
@addon_view
@post_required
@login_required(redirect=False)
@json_view
def flag(request, addon, review_id):
return http.HttpResponse()
@addon_view
@json_view
@login_required(redirect=False)