Skip to content
This repository has been archived by the owner on Mar 15, 2018. It is now read-only.

Commit

Permalink
force apps to get ratings before resubmission (bug 971049)
Browse files Browse the repository at this point in the history
  • Loading branch information
ngokevin committed Apr 1, 2014
1 parent b804a67 commit f636a63
Show file tree
Hide file tree
Showing 7 changed files with 60 additions and 8 deletions.
4 changes: 4 additions & 0 deletions apps/addons/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -380,6 +380,10 @@ class Addon(amo.models.OnChangeMixin, amo.models.ModelBase):

enable_new_regions = models.BooleanField(default=False, db_index=True)

# Annotates disabled apps from the Great IARC purge for auto-reapprove.
# Note: for currently PUBLIC apps only.
iarc_purged = models.BooleanField(default=False)

objects = AddonManager()
with_deleted = AddonManager(include_deleted=True)

Expand Down
2 changes: 2 additions & 0 deletions migrations/765-iarc-purge-flag.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
ALTER TABLE addons
ADD COLUMN `iarc_purged` bool NOT NULL DEFAULT false;
23 changes: 18 additions & 5 deletions mkt/developers/templates/developers/apps/status.html
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,18 @@ <h2>{{ _('Current Status') }}</h2>
</p>
{% elif addon.status == amo.STATUS_DISABLED %}
{{ status(_('This app has been <b>disabled by Mozilla</b>.')) }}
{% trans email=emaillink(settings.MKT_REVIEWERS_EMAIL) %}
Your app was disabled by a site administrator. If you have any
questions, please email {{ email }}.
{% endtrans %}
{% if addon.iarc_purged %}
{% trans ratings_url=addon.get_dev_url('ratings') %}
Your app was disabled because it is missing content ratings. It will
automatically be re-enabled after
<a href="{{ ratings_url }}">obtaining content ratings</a>.
{% endtrans %}
{% else %}
{% trans email=emaillink(settings.MKT_REVIEWERS_EMAIL) %}
Your app was disabled by a site administrator. If you have any
questions, please email {{ email }}.
{% endtrans %}
{% endif %}
{% elif addon.status == amo.STATUS_BLOCKED %}
{{ status(_('Your app has been <b>blocked by Mozilla</b>.')) }}
{% trans email=emaillink(settings.MKT_REVIEWERS_EMAIL) %}
Expand Down Expand Up @@ -99,12 +107,17 @@ <h3>
{% endif %}
</p>
{% endif %}
{% if not addon.is_packaged %}
{% if not addon.is_packaged and addon.is_rated() or not waffle.switch('iarc') %}
<form method="post">
{{ csrf() }}
{{ form_field(form.notes, opt=True) }}
<p><button type="submit" name="resubmit-app">{{ _('Resubmit App') }}</button></p>
</form>
{% elif waffle.switch('iarc') and not addon.is_rated() %}
{% trans ratings_url=addon.get_dev_url('ratings') %}
You must <a href="{{ ratings_url }}">obtain content ratings</a>
before resubmitting your app.
{% endtrans %}
{% endif %}
{% endif %}
</div>
Expand Down
12 changes: 12 additions & 0 deletions mkt/developers/tests/test_views_versions.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,18 @@ def test_rejected(self):
addon=webapp, activity_log__action=action.id).exists(), (
"Didn't find `%s` action in logs." % action.short)

def test_no_ratings_no_resubmit(self):
self.create_switch('iarc')
self.webapp.update(status=amo.STATUS_REJECTED)
r = self.client.post(self.url, {'notes': 'lol',
'resubmit-app': ''})
eq_(r.status_code, 403)

self.webapp.content_ratings.create(ratings_body=0, rating=0)
r = self.client.post(self.url, {'notes': 'lol',
'resubmit-app': ''})
self.assert3xx(r, self.webapp.get_dev_url('versions'))

def test_comm_thread_after_resubmission(self):
self.create_switch('comm-dashboard')
self.webapp.update(status=amo.STATUS_REJECTED)
Expand Down
6 changes: 6 additions & 0 deletions mkt/developers/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,12 @@ def status(request, addon_id, addon, webapp=False):

if request.method == 'POST':
if 'resubmit-app' in request.POST and form.is_valid():
if waffle.switch_is_active('iarc') and not addon.is_rated():
# Cannot resubmit without content ratings.
return http.HttpResponseForbidden(
'This app must obtain content ratings before being '
'resubmitted.')

form.save()
create_comm_note(addon, addon.latest_version,
request.amo_user, form.data['notes'],
Expand Down
7 changes: 6 additions & 1 deletion mkt/webapps/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -1210,11 +1210,16 @@ def set_content_ratings(self, data):
geodata.region_de_usk_exclude = has_usk_refused

# Un-exclude games in Brazil/Germany once they get a content rating.
save = (save or geodata.region_br_iarc_exclude or
save = (save or
geodata.region_br_iarc_exclude or
geodata.region_de_iarc_exclude)
geodata.region_br_iarc_exclude = False
geodata.region_de_iarc_exclude = False

# Un-disable apps that were disabled by the great IARC purge.
if (self.status == amo.STATUS_DISABLED and self.iarc_purged):
self.update(status=amo.STATUS_PUBLIC, iarc_purged=False)

if save:
geodata.save()
log.info('Un-excluding IARC-excluded app:%s from br/de')
Expand Down
14 changes: 12 additions & 2 deletions mkt/webapps/tests/test_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -715,7 +715,7 @@ def test_set_content_ratings_usk_refused(self):
})
ok_(not Geodata.objects.get(addon=app).region_de_usk_exclude)

def test_set_content_ratings_iarc_unexclude(self):
def test_set_content_ratings_iarc_games_unexclude(self):
app = app_factory()
app._geodata.update(region_br_iarc_exclude=True,
region_de_iarc_exclude=True)
Expand All @@ -728,6 +728,17 @@ def test_set_content_ratings_iarc_unexclude(self):
ok_(not geodata.region_br_iarc_exclude)
ok_(not geodata.region_de_iarc_exclude)

def test_set_content_ratings_purge_unexclude(self):
app = app_factory()
app.update(status=amo.STATUS_DISABLED, iarc_purged=True)

app.set_content_ratings({
mkt.ratingsbodies.USK: mkt.ratingsbodies.USK_12
})

ok_(not app.reload().iarc_purged)
eq_(app.status, amo.STATUS_PUBLIC)

def test_set_descriptors(self):
app = app_factory()
eq_(RatingDescriptors.objects.count(), 0)
Expand All @@ -751,7 +762,6 @@ def test_set_descriptors(self):
app.set_descriptors([
'has_esrb_blood', 'has_classind_drugs'
])
eq_(RatingDescriptors.objects.count(), 1)
descriptors = RatingDescriptors.objects.get(addon=app)
assert descriptors.has_esrb_blood
assert descriptors.has_classind_drugs
Expand Down

0 comments on commit f636a63

Please sign in to comment.