This commit is contained in:
Kumar McMillan 2011-10-06 13:24:33 -05:00
Родитель d2e1a01e9d 28c6df9946
Коммит 5260ac5141
5 изменённых файлов: 52 добавлений и 10 удалений

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

@ -363,7 +363,7 @@ class DELETE_REVIEW(_LOG):
editor_event = True
class BULK_VALIDATION_UPDATED(_LOG):
class MAX_APPVERSION_UPDATED(_LOG):
id = 46
action_class = None
format = _(u'Application max version for {version} updated.')

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

@ -642,6 +642,15 @@ class TestPlatformSearch(TestVersionEdit):
class TestVersionEditCompat(TestVersionEdit):
def get_form(self, url=None):
if not url:
url = self.url
av = self.version.apps.get()
eq_(av.min.version, '2.0')
eq_(av.max.version, '3.7a1pre')
f = self.client.get(url).context['compat_form'].initial_forms[0]
return initial(f)
def formset(self, *args, **kw):
defaults = formset(prefix='files')
defaults.update(kw)
@ -655,13 +664,11 @@ class TestVersionEditCompat(TestVersionEdit):
eq_(r.status_code, 302)
apps = self.get_version().compatible_apps.keys()
eq_(sorted(apps), sorted([amo.FIREFOX, amo.THUNDERBIRD]))
eq_(list(ActivityLog.objects.all().values_list('action')),
[(amo.LOG.MAX_APPVERSION_UPDATED.id,)])
def test_update_appversion(self):
av = self.version.apps.get()
eq_(av.min.version, '2.0')
eq_(av.max.version, '3.7a1pre')
f = self.client.get(self.url).context['compat_form'].initial_forms[0]
d = initial(f)
d = self.get_form()
d.update(min=self.v1.id, max=self.v4.id)
r = self.client.post(self.url,
self.formset(d, initial_count=1))
@ -669,6 +676,21 @@ class TestVersionEditCompat(TestVersionEdit):
av = self.version.apps.get()
eq_(av.min.version, '1.0')
eq_(av.max.version, '4.0')
eq_(list(ActivityLog.objects.all().values_list('action')),
[(amo.LOG.MAX_APPVERSION_UPDATED.id,)])
def test_ajax_update_appversion(self):
url = reverse('devhub.ajax.compat.update',
args=['a3615', self.version.id])
d = self.get_form(url)
d.update(min=self.v1.id, max=self.v4.id)
r = self.client.post(url, self.formset(d, initial_count=1))
eq_(r.status_code, 200)
av = self.version.apps.get()
eq_(av.min.version, '1.0')
eq_(av.max.version, '4.0')
eq_(list(ActivityLog.objects.all().values_list('action')),
[(amo.LOG.MAX_APPVERSION_UPDATED.id,)])
def test_delete_appversion(self):
# Add thunderbird compat so we can delete firefox.
@ -680,6 +702,8 @@ class TestVersionEditCompat(TestVersionEdit):
eq_(r.status_code, 302)
apps = self.get_version().compatible_apps.keys()
eq_(apps, [amo.THUNDERBIRD])
eq_(list(ActivityLog.objects.all().values_list('action')),
[(amo.LOG.MAX_APPVERSION_UPDATED.id,)])
def test_unique_apps(self):
f = self.client.get(self.url).context['compat_form'].initial_forms[0]

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

@ -126,6 +126,10 @@ def ajax_compat_update(request, addon_id, addon, version_id):
for compat in compat_form.save(commit=False):
compat.version = version
compat.save()
for form in compat_form.forms:
if (isinstance(form, forms.CompatForm) and
'max' in form.changed_data):
_log_max_version_change(addon, version, form.instance)
return jingo.render(request, 'devhub/addons/ajax_compat_update.html',
dict(addon=addon, version=version,
compat_form=compat_form))
@ -1097,6 +1101,10 @@ def version_edit(request, addon_id, addon, version_id):
for compat in data['compat_form'].save(commit=False):
compat.version = version
compat.save()
for form in data['compat_form'].forms:
if (isinstance(form, forms.CompatForm) and
'max' in form.changed_data):
_log_max_version_change(addon, version, form.instance)
messages.success(request, _('Changes successfully saved.'))
return redirect('devhub.versions.edit', addon.slug, version_id)
@ -1105,6 +1113,14 @@ def version_edit(request, addon_id, addon, version_id):
return jingo.render(request, 'devhub/versions/edit.html', data)
def _log_max_version_change(addon, version, appversion):
details = {'version': version.version,
'target': appversion.version.version,
'application': appversion.application.pk}
amo.log(amo.LOG.MAX_APPVERSION_UPDATED,
addon, version, details=details)
def _get_file_history(version):
file_ids = [f.id for f in version.all_files]
addon = version.addon

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

@ -262,10 +262,12 @@ def notify_success(version_pks, job_pk, data, **kw):
else:
stats['author_emailed'] += 1
send_mail(*args, **kwargs)
amo.log(amo.LOG.BULK_VALIDATION_UPDATED,
app_id = job.target_version.application.pk
amo.log(amo.LOG.MAX_APPVERSION_UPDATED,
version.addon, version,
details={'version': version.version,
'target': job.target_version.version})
'target': job.target_version.version,
'application': app_id})
log.info('[%s@%s] bulk update stats for job %s: {%s}'
% (len(version_pks), notify_success.rate_limit, job_pk,
', '.join('%s: %s' % (k, stats[k])

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

@ -350,7 +350,7 @@ class TestBulkUpdate(BulkValidationTest):
self.create_result(self.job, self.create_file(self.version))
eq_(ActivityLog.objects.for_addons(self.addon).count(), 0)
self.client.post(self.update_url, self.data)
upd = amo.LOG.BULK_VALIDATION_UPDATED.id
upd = amo.LOG.MAX_APPVERSION_UPDATED.id
logs = ActivityLog.objects.for_addons(self.addon).filter(action=upd)
eq_(logs.count(), 1)
eq_(logs[0].user, get_task_user())
@ -451,7 +451,7 @@ class TestBulkUpdate(BulkValidationTest):
eq_([e.subject for e in rs], ['the subject'])
# version should not be bumped since it's in preview mode:
eq_(self.version.apps.all()[0].max, self.max)
upd = amo.LOG.BULK_VALIDATION_UPDATED.id
upd = amo.LOG.MAX_APPVERSION_UPDATED.id
logs = ActivityLog.objects.for_addons(self.addon).filter(action=upd)
eq_(logs.count(), 0)