зеркало из https://github.com/mozilla/FlightDeck.git
Merge branch 'bug-600422-oauth_upload'
This commit is contained in:
Коммит
1db2f274e7
|
@ -25,7 +25,7 @@ def upload_to_amo(rev_pk, hashtag=None):
|
|||
revision = PackageRevision.objects.get(pk=rev_pk)
|
||||
# save status
|
||||
revision.amo_status = STATUS_UPLOAD_SCHEDULED
|
||||
revision.amo_version_name = revision.get_version_name_only()
|
||||
revision.amo_version_name = revision.get_version_name()
|
||||
super(PackageRevision, revision).save()
|
||||
response = revision.build_xpi(
|
||||
hashtag=hashtag,
|
||||
|
|
|
@ -16,7 +16,7 @@ def upload_to_amo(request, pk):
|
|||
"""
|
||||
# check if there this Add-on was uploaded with the same version name
|
||||
revision = PackageRevision.objects.get(pk=pk)
|
||||
version = revision.get_version_name_only()
|
||||
version = revision.get_version_name()
|
||||
uploaded = PackageRevision.objects.filter(
|
||||
package=revision.package).filter(
|
||||
amo_version_name=version).exclude(
|
||||
|
|
|
@ -185,7 +185,8 @@ class PackageRevision(BaseModel):
|
|||
error = None
|
||||
if self.package.amo_id:
|
||||
# update addon on AMO
|
||||
log.info('AMOOAUTHAPI: updating addon from %s' % self)
|
||||
log.info('AMOOAUTHAPI: updating addon %s to version %s' % (
|
||||
self, self.amo_version_name))
|
||||
log.debug(data)
|
||||
try:
|
||||
response = amo.create_version(data, self.package.amo_id)
|
||||
|
@ -203,7 +204,8 @@ class PackageRevision(BaseModel):
|
|||
# TODO: update jetpack ID if needed
|
||||
else:
|
||||
# create addon on AMO
|
||||
log.info('AMOOAUTHAPI: creating addon from %s' % self)
|
||||
log.info('AMOOAUTHAPI: creating addon %s version %s' % (
|
||||
self, self.amo_version_name))
|
||||
data.update({'platform': 'all'})
|
||||
try:
|
||||
response = amo.create_addon(data)
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
A class to interact with AMO's api, using OAuth.
|
||||
Ripped off from Daves test_oauth.py and some notes from python-oauth2
|
||||
"""
|
||||
import commonware
|
||||
# Wherein import almost every http or urllib in Python
|
||||
import urllib
|
||||
import urllib2
|
||||
|
@ -16,6 +17,8 @@ import mimetools
|
|||
|
||||
from helpers import encode_multipart, data_keys
|
||||
|
||||
log = commonware.log.getLogger('f.amooauth')
|
||||
|
||||
# AMO Specific end points
|
||||
urls = {
|
||||
'login': '/users/login',
|
||||
|
@ -108,12 +111,14 @@ class AMOOAuth:
|
|||
method, url, parameters))
|
||||
request.sign_request(self.signature_method, self.get_consumer(), token)
|
||||
client = httplib2.Http()
|
||||
strdata = str(data)
|
||||
if data and method == 'POST':
|
||||
data = encode_multipart(boundary, data)
|
||||
headers.update({'Content-Type':
|
||||
'multipart/form-data; boundary=%s' % boundary})
|
||||
else:
|
||||
data = urllib.urlencode(data)
|
||||
log.debug("AMOOAUTH: Sending request %s" % strdata)
|
||||
return client.request(request.to_url(), method=method,
|
||||
headers=headers, body=data)
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче