diff --git a/apps/jetpack/models.py b/apps/jetpack/models.py index e7d9cf42..e122ae99 100644 --- a/apps/jetpack/models.py +++ b/apps/jetpack/models.py @@ -1341,7 +1341,7 @@ class PackageRevision(BaseModel): return self.sdk.kit_lib if self.sdk.kit_lib else self.sdk.core_lib def export_source(self, modules=None, attachments=None, tstart=None, - temp_dir=None, package_overrides=None): + temp_dir=None, package_overrides=None): """ Export source of the PackageRevision and all it's dependencies @@ -1391,6 +1391,15 @@ class PackageRevision(BaseModel): statsd.timing('export.attachments', t3) log.debug("[export] attachments exported (time %dms)" % t3) + # export commit message + #self.message + #self.commit_message + commit_msg_path = os.path.join(package_dir, 'commit_message') + with codecs.open(commit_msg_path, mode='w', encoding='utf-8') as f: + f.write("%s\n--\n%s" % (self.version_name, self.commit_message)) + if (self.message): + f.write("\n--\n%s" % self.message) + # XPI: copying to local from memory/db/files self.export_dependencies(temp_dir) t4 = (time.time() - (t3 / 1000) - tstart) * 1000 @@ -1847,6 +1856,10 @@ class Package(BaseModel, SearchMixin): settings.AMO_SITE_PROTOCOL, settings.AMO_SITE_DOMAIN, self.amo_slug) + def get_all_zipped_url(self): + " returns a url to zip_all view " + return reverse('jp_package_zip', args=[self.pk]) + def get_edit_on_amo_url(self, step=5): " returns the url to resume an incomplete add-on " if not self.amo_slug: diff --git a/apps/jetpack/templates/edit.html b/apps/jetpack/templates/edit.html index ba005de1..4b43ce3f 100644 --- a/apps/jetpack/templates/edit.html +++ b/apps/jetpack/templates/edit.html @@ -95,6 +95,9 @@
  • +
  • + +
  • diff --git a/apps/jetpack/templates/view.html b/apps/jetpack/templates/view.html index e6190fc5..68d0d8a1 100644 --- a/apps/jetpack/templates/view.html +++ b/apps/jetpack/templates/view.html @@ -84,6 +84,9 @@
  • +
  • + +
  • {% endif %} {% if revision.package.public_permission != 2 and user.is_authenticated %} diff --git a/apps/jetpack/urls.py b/apps/jetpack/urls.py index 5e2c6e0d..a62da740 100644 --- a/apps/jetpack/urls.py +++ b/apps/jetpack/urls.py @@ -101,7 +101,7 @@ urlpatterns = patterns('jetpack.views', url(r'^package/remove_attachment/(?P\d+)/$', 'remove_attachment', name='jp_package_revision_remove_attachment'), - # rename attachment + # rename attachment url(r'^package/rename_attachment/(?P\d+)/$', 'rename_attachment', name='jp_package_revision_rename_attachment'), @@ -143,4 +143,6 @@ urlpatterns = patterns('jetpack.views', 'get_zip', name='jp_revision_download_zip'), url(r'^revision/check_zip/(?P[a-zA-Z0-9]+)/$', 'check_zip', name='jp_revision_check_zip'), + url(r'^package/zip/(?P\d+)/$', + 'all_zip', name='jp_package_zip'), ) diff --git a/apps/jetpack/views.py b/apps/jetpack/views.py index ec7e76da..6813646f 100644 --- a/apps/jetpack/views.py +++ b/apps/jetpack/views.py @@ -10,8 +10,10 @@ import urllib2 import time import waffle +from contextlib import closing from simplejson import JSONDecodeError from statsd import statsd +from zipfile import ZipFile, ZIP_DEFLATED from django.contrib import messages from django.core.urlresolvers import reverse @@ -1313,3 +1315,27 @@ def check_zip(r, hashtag): if os.path.isfile(path): return HttpResponse('{"ready": true}') return HttpResponse('{"ready": false}') + + +@never_cache +def all_zip(request, pk): + """Zip all and return a file.""" + if not pk: + log.critical("[zip] No package_id provided") + return + package = Package.objects.get(pk=pk) + zips = [] + # Zip all revisions of the package + for revision in package.revisions.all(): + zips.append(revision.zip_source(hashtag=revision.get_cache_hashtag())) + # Zip all zipped revisions into one file + zip_targetname = "package-%d.zip" % package.pk + zip_targetpath = os.path.join(settings.XPI_TARGETDIR, zip_targetname) + with closing(ZipFile(zip_targetpath, 'w', ZIP_DEFLATED)) as z: + for fn in zips: + z.write(fn) + log.info('[zipall:%s] Downloading All zipped' % pk) + + response = serve(request, zip_targetpath, '/', show_indexes=False) + response['Content-Disposition'] = ('attachment; filename="%s"' % zip_targetname) + return response diff --git a/vendor b/vendor index c9e54057..5bccd472 160000 --- a/vendor +++ b/vendor @@ -1 +1 @@ -Subproject commit c9e5405789630c273dca1916b007033bac7f507a +Subproject commit 5bccd4720b81b6135c06dc773da1cddadfde5ca4