This repository has been archived by the owner on Mar 15, 2018. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
adding addon compat reporter endpoints (bug 647031, 647032, 647034)
- Loading branch information
Jeff Balogh
committed
May 2, 2011
1 parent
b9d0589
commit 7c078ff
Showing
8 changed files
with
292 additions
and
22 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
from django.db import models | ||
|
||
import json_field | ||
|
||
import amo.models | ||
|
||
|
||
class CompatReport(amo.models.ModelBase): | ||
guid = models.CharField(max_length=128) | ||
version = models.CharField(max_length=128) | ||
app_guid = models.CharField(max_length=128) | ||
app_version = models.CharField(max_length=128) | ||
app_build = models.CharField(max_length=128) | ||
client_os = models.CharField(max_length=128) | ||
client_ip = models.CharField(max_length=128) | ||
comments = models.TextField() | ||
other_addons = json_field.JSONField() | ||
works_properly = models.BooleanField() | ||
|
||
class Meta: | ||
db_table = 'compatibility_reports' |
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 |
---|---|---|
@@ -0,0 +1,37 @@ | ||
{% extends "base.html" %} | ||
|
||
{% block title %}{{ page_title(_('Add-on Compatibility Reports')) }}{% endblock %} | ||
|
||
{% block content %} | ||
<div class="primary"> | ||
<hgroup> | ||
<h2>{{ _('Add-on Compatibility Reports') }}</h2> | ||
<h4>{{ _("Enter the GUID of an add-on below to view any reports we've received.") }}</h4> | ||
</hgroup> | ||
<form action=""> | ||
<input name="guid" value="{{ query }}" id="compat-query"> | ||
</form> | ||
</div> | ||
<div class="secondary"> | ||
<div class="highlight"> | ||
{% trans url_ = '/en-US/firefox/addon/15003' %}<p> | ||
Reports submitted to us through the | ||
<a href="{{ url_ }}">Add-on Compatibility Reporter</a> are collected here | ||
for developers to view. These reports help us determine which add-ons will | ||
need help supporting an upcoming Firefox version. | ||
</p>{% endtrans %} | ||
</div> | ||
{% if addons %} | ||
<div class="highlight"> | ||
<h4>{{ _('Reports for your Add-ons') }}</h4> | ||
<ul> | ||
{% for addon in addons %} | ||
<li> | ||
<a href="{{ url('compat.reporter_detail', addon.guid) }}">{{ addon.name }}</a> | ||
</li> | ||
{% endfor %} | ||
</ul> | ||
</div> | ||
{% endif %} | ||
</div> | ||
{% endblock %} |
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 |
---|---|---|
@@ -0,0 +1,66 @@ | ||
{% extends "base.html" %} | ||
|
||
{% block title %}{{ page_title(_('{addon} Compatibility Reports')|f(addon=name)) }}{% endblock %} | ||
|
||
{% block bodyclass %}inverse{% endblock %} | ||
|
||
{% block content %} | ||
<div class="primary"> | ||
{{ breadcrumbs([(url('compat.reporter'), _('Add-on Compatibility Center')), | ||
(None, _('{addon} Compatibility Reports')|f(addon=name))]) }} | ||
<h2>{{ _('{addon} Compatibility Reports')|f(addon=name) }}</h2> | ||
{% trans url_ = '/en-US/firefox/addon/15003' %}<p> | ||
Reports submitted to us through the | ||
<a href="{{ url_ }}">Add-on Compatibility Reporter</a> are collected here | ||
for developers to view. These reports help us determine which add-ons will | ||
need help supporting an upcoming Firefox version. | ||
</p>{% endtrans %} | ||
|
||
<table class="compat-info"> | ||
<thead> | ||
<th>{{ _('Report Type') }}</th> | ||
<th>{{ _('Version') }}</th> | ||
<th>{{ _('Application') }}</th> | ||
<th>{{ _('Application Build') }}</th> | ||
<th>{{ _('Operating System') }}</th> | ||
<th>{{ _('Submitted') }}</th> | ||
</thead> | ||
<tbody> | ||
{% for report in reports.object_list %} | ||
{% set cls = 'success' if report.works_properly else 'problem' %} | ||
<tr class="{{ cls }}"> | ||
<td>{{ _('Success') if report.works_properly else _('Problem') }}</td> | ||
<td>{{ report.version }}</td> | ||
<td>{{ amo.APP_GUIDS[report.app_guid].pretty }} {{ report.app_version }}</td> | ||
<td>{{ report.app_build }}</td> | ||
<td>{{ report.client_os }}</td> | ||
<td>{{ report.created|datetime }}</td> | ||
</tr> | ||
{% if report.comments %} | ||
<tr class="comments" class="{{ cls }}"> | ||
<td colspan="6">{{ report.comments }}</td> | ||
</tr> | ||
{% endif %} | ||
{% endfor %} | ||
</tbody> | ||
</table> | ||
{{ reports|paginator }} | ||
</div> | ||
|
||
<div class="secondary"> | ||
<div class="highlight"> | ||
<ul> | ||
<li> | ||
<a href="{{ url('compat.reporter_detail', guid)|urlparams(works_properly=1) }}"> | ||
{{ ngettext('{0} success report', '{0} success reports', | ||
works['success'])|f(works['success']|numberfmt) }}</a> | ||
</li> | ||
<li> | ||
<a href="{{ url('compat.reporter_detail', guid)|urlparams(works_properly=0) }}"> | ||
{{ ngettext('{0} problem report', '{0} problem reports', | ||
works['problem'])|f(works['failure']|numberfmt) }}</a> | ||
</li> | ||
</ul> | ||
</div> | ||
</div> | ||
{% endblock %} |
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 |
---|---|---|
@@ -0,0 +1,79 @@ | ||
import json | ||
|
||
from django.conf import settings | ||
|
||
import test_utils | ||
from nose.tools import eq_ | ||
|
||
import amo | ||
from amo.urlresolvers import reverse | ||
from compat.models import CompatReport | ||
|
||
|
||
# This is the structure sent to /compatibility/incoming from the ACR. | ||
incoming_data = { | ||
'appBuild': '20110429030623', | ||
'appGUID': '{ec8030f7-c20a-464f-9b0e-13a3a9e97384}', | ||
'appVersion': '6.0a1', | ||
'clientOS': 'Intel Mac OS X 10.6', | ||
'comments': 'what the what', | ||
'guid': 'jid0-VsMuA0YYTKCjBh5F0pxHAudnEps@jetpack', | ||
'otherAddons': [['yslow@yahoo-inc.com', '2.1.0']], | ||
'version': '2.2', | ||
'worksProperly': False, | ||
} | ||
|
||
|
||
class TestIncoming(test_utils.TestCase): | ||
|
||
def setUp(self): | ||
self.url = reverse('compat.incoming') | ||
self.data = dict(incoming_data) | ||
self.json = json.dumps(self.data) | ||
|
||
def test_success(self): | ||
count = CompatReport.objects.count() | ||
r = self.client.post(self.url, self.json, | ||
content_type='application/json') | ||
eq_(r.status_code, 204) | ||
eq_(CompatReport.objects.count(), count + 1) | ||
|
||
cr = CompatReport.objects.order_by('-id')[0] | ||
eq_(cr.app_build, incoming_data['appBuild']) | ||
eq_(cr.app_guid, incoming_data['appGUID']) | ||
eq_(cr.works_properly, incoming_data['worksProperly']) | ||
eq_(cr.comments, incoming_data['comments']) | ||
eq_(cr.client_ip, '127.0.0.1') | ||
|
||
# Check that the other_addons field is stored as json. | ||
vals = CompatReport.objects.filter(id=cr.id).values('other_addons') | ||
eq_(vals[0]['other_addons'], | ||
json.dumps(incoming_data['otherAddons'], separators=(',', ':'))) | ||
|
||
def test_bad_json(self): | ||
r = self.client.post(self.url, 'wuuu#$', | ||
content_type='application/json') | ||
eq_(r.status_code, 400) | ||
|
||
def test_bad_field(self): | ||
self.data['save'] = 1 | ||
js = json.dumps(self.data) | ||
r = self.client.post(self.url, js, content_type='application/json') | ||
eq_(r.status_code, 400) | ||
|
||
|
||
class TestCompat(test_utils.TestCase): | ||
|
||
def test_success(self): | ||
r = self.client.get(reverse('compat.index')) | ||
eq_(r.status_code, 200) | ||
version = [v['version'] for v in settings.COMPAT | ||
if v['app'] == amo.FIREFOX.id][0] | ||
eq_(r.context['version'], version) | ||
|
||
|
||
class TestReporter(test_utils.TestCase): | ||
|
||
def test_success(self): | ||
r = self.client.get(reverse('compat.reporter')) | ||
eq_(r.status_code, 200) |
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,9 +1,14 @@ | ||
from django.conf.urls.defaults import patterns, url | ||
from django.conf.urls.defaults import url | ||
|
||
from . import views | ||
|
||
|
||
urlpatterns = patterns('', | ||
urlpatterns = ( | ||
url('^incoming/?$', views.incoming, name='compat.incoming'), | ||
url('^reporter/?$', views.reporter, name='compat.reporter'), | ||
url('^reporter/([^/]+)$', | ||
views.reporter_detail, name='compat.reporter_detail'), | ||
|
||
url('^(?P<version>[.\w]+)?$', views.index, name='compat.index'), | ||
url('^(?P<version>[.\w]+)/details$', views.details, name='compat.details'), | ||
) |
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 |
---|---|---|
@@ -0,0 +1,4 @@ | ||
ALTER TABLE compatibility_reports ADD COLUMN `modified` datetime DEFAULT NULL; | ||
CREATE INDEX created_idx ON compatibility_reports (created); | ||
CREATE INDEX guid_created_idx ON compatibility_reports (guid, created); | ||
CREATE INDEX guid_wp_idx ON compatibility_reports (guid, works_properly); |