Return empty object only if there was no attempt to upload an add-on before

* some pylint fixes
This commit is contained in:
Piotr Zalewa 2011-11-14 16:04:16 +01:00
Родитель b899bd4090
Коммит b5ec71688b
2 изменённых файлов: 15 добавлений и 12 удалений

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

@ -1,14 +1,14 @@
import commonware.log
import simplejson
from django.shortcuts import render_to_response, get_object_or_404
from django.http import HttpResponse, HttpResponseNotAllowed, HttpResponseBadRequest
from django.shortcuts import get_object_or_404 # render_to_response,
from django.http import HttpResponse, HttpResponseBadRequest
from amo import tasks
from amo.constants import *
from amo.constants import STATUS_UPLOAD_FAILED, STATUS_UPLOAD_SCHEDULED
from amo.helpers import get_addon_details as _get_addon_details
from jetpack.models import PackageRevision
from utils.exceptions import SimpleException
#from utils.exceptions import SimpleException
log = commonware.log.getLogger('f.amo')
@ -33,7 +33,7 @@ def upload_to_amo(request, pk):
PackageRevision.objects.get(
package=revision.package, amo_version_name=version,
amo_status=STATUS_UPLOAD_SCHEDULED)
except:
except PackageRevision.DoesNotExist:
pass
else:
log.debug("This Add-on is currently scheduled to upload")
@ -105,18 +105,21 @@ def get_addon_details(request, pk):
"""
# get PackageRevision
revision = get_object_or_404(PackageRevision, pk=pk)
# check if Package is synced with the AMO and last update was successful
if not (revision.package.amo_id or revision.amo_status != None):
return HttpResponse('{}')# mimetype="application/json")
# check if Package was scheduled for upload
if revision.amo_status == None:
return HttpResponse('{}', mimetype="application/json")
amo_meta = {'status': revision.get_status_name(),
'status_code': revision.amo_status,
'version': revision.amo_version_name,
'get_addon_info_url': revision.get_addon_info_url(),
'pk': revision.pk,
'uploaded': revision.amo_status != STATUS_UPLOAD_FAILED}
if revision.package.amo_slug:
amo_meta['view_on_amo_url'] = revision.package.get_view_on_amo_url()
amo_meta['edit_on_amo_url'] = revision.package.get_edit_on_amo_url()
return HttpResponse(simplejson.dumps(amo_meta))
#mimetype="application/json")
return HttpResponse(simplejson.dumps(amo_meta),
mimetype="application/json")

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

@ -87,7 +87,6 @@ FlightDeck = Class.refactor(FlightDeck, {
* pull Add-o status and update data on the page
*/
getStatus: function(status_el) {
var pk = status_el.get('data-revision_id');
new Request.JSON({
url: status_el.get('data-get_addon_info_url'),
useSpinner: true,
@ -121,7 +120,8 @@ FlightDeck = Class.refactor(FlightDeck, {
};
if (data.status) update('.amo-review_status', data.status);
if (data.version) update('.amo-latest_version', data.version);
if (data.pk) status_el.set('data-revision_id', data.pk) ;
if (data.get_addon_info_url status_el.set('data-get_addon_info_url', data.get_addon_info_url)
//if (data.pk) status_el.set('data-revision_id', data.pk) ;
var edit_on_amo = status_el.getElements('.UI_AMO_Edit_On_AMO');
edit_on_amo = edit_on_amo ? edit_on_amo[0] : false;
var view_on_amo = status_el.getElements('.UI_AMO_View_On_AMO');