Permalink
Browse files

check.py refactoring

  • Loading branch information...
1 parent fab43de commit 08f01c71bc434fdab7dcf1ad890ccb8e954b0bc1 @zalun zalun committed Feb 1, 2011
View
@@ -75,7 +75,7 @@ def _get_hunks(text):
hunks = list(apiparser.parse_hunks(text))
except Exception, err:
log.error(str(err))
- hunks = [[None,'<p>Sorry. Error in reading the doc. '
+ hunks = [[None, '<p>Sorry. Error in reading the doc. '
'Please check <a href="https://jetpack.mozillalabs.com/'
'sdk/1.0b1/docs/#package/addon-kit">official docs</a></p>']]
return hunks
@@ -150,7 +150,7 @@ def _save_package(packed, name, harness_options, package_type, author):
)
obj.save()
obj.latest.set_version('empty.uploaded')
- new_revision=False
+ new_revision = False
obj.create_revision_from_xpi(packed, manifest, author,
harness_options['jetpackID'], new_revision=new_revision)
View
@@ -1,5 +1,3 @@
-import commonware.log
-
from celery.decorators import task
from xpi import xpi_utils
@@ -8,7 +8,7 @@
from nose import SkipTest
from mock import patch
-from pyquery import PyQuery as pq
+#from pyquery import PyQuery as pq
from django.conf import settings
from django.contrib.auth.models import User
@@ -19,6 +19,7 @@
from jetpack.views import latest_by_uid
from base.templatetags.base_helpers import hashtag
+
def next(revision):
number = revision.revision_number
return (PackageRevision.objects.filter(revision_number__gt=number)
View
@@ -20,15 +20,16 @@
from django.core.paginator import Paginator
from django.db.models import Q, ObjectDoesNotExist
from django.views.decorators.http import require_POST
-from django.template.defaultfilters import slugify, escape
+from django.template.defaultfilters import escape
from django.conf import settings
from django.utils import simplejson
from base.shortcuts import get_object_with_related_or_404
from utils import validator
from jetpack.models import Package, PackageRevision, Module, Attachment, SDK
-from jetpack.package_helpers import get_package_revision, create_package_from_xpi
+from jetpack.package_helpers import get_package_revision, \
+ create_package_from_xpi
from jetpack.errors import FilenameExistException
log = commonware.log.getLogger('f.jetpack')
@@ -260,7 +261,8 @@ def package_add_module(r, id_number, type_id,
'You are not the author of this %s' % escape(
revision.package.get_type_name()))
- filename = re.sub('[^a-zA-Z0-9_\-\/]+', '-', r.POST.get('filename').strip())
+ filename = re.sub('[^a-zA-Z0-9_\-\/]+', '-',
+ r.POST.get('filename').strip())
mod = Module(
filename=filename,
@@ -280,6 +282,7 @@ def package_add_module(r, id_number, type_id,
context_instance=RequestContext(r),
mimetype='application/json')
+
@require_POST
@login_required
def package_rename_module(r, id_number, type_id, revision_number):
@@ -316,8 +319,8 @@ def package_rename_module(r, id_number, type_id, revision_number):
module = mod
if not module:
- log_msg = 'Attempt to delete a non existing module %s from %s.' % (
- filename, id_number)
+ log_msg = 'Attempt to rename a non existing module %s from %s.' % (
+ old_name, id_number)
log.warning(log_msg)
return HttpResponseForbidden(
'There is no such module in %s' % escape(
@@ -428,6 +431,7 @@ def package_add_attachment(r, id_number, type_id,
context_instance=RequestContext(r),
mimetype='application/json')
+
@require_POST
@login_required
def package_rename_attachment(r, id_number, type_id, revision_number):
@@ -459,8 +463,6 @@ def package_rename_attachment(r, id_number, type_id, revision_number):
'with the name "%s.%s". Each attachment in your add-on '
'needs to have a unique name.') % (new_name, attachment.ext)
)
-
-
attachment.filename = new_name
revision.update(attachment)
@@ -469,6 +471,7 @@ def package_rename_attachment(r, id_number, type_id, revision_number):
context_instance=RequestContext(r),
mimetype='application/json')
+
@require_POST
@login_required
def package_remove_attachment(r, id_number, type_id, revision_number):
@@ -799,6 +802,7 @@ def get_revisions_list_html(r, id_number):
},
context_instance=RequestContext(r))
+
def get_latest_revision_number(request, package_id):
""" returns the latest revision number for given package """
package = get_object_or_404(Package, id_number=package_id)
@@ -243,4 +243,3 @@ def test_xpi_clean(self):
eq_(len(find_files()), 1)
clean_tmp(length=0)
assert not find_files()
-
@@ -1,9 +1,7 @@
-import os
import simplejson
from test_utils import TestCase
from nose.tools import eq_
-from nose import SkipTest
from mock import patch
from django.core.urlresolvers import reverse
View
@@ -1,13 +1,8 @@
import os
import commonware.log
-from django.core.urlresolvers import reverse
from django.views.static import serve
-from django.shortcuts import render_to_response
-from django.http import HttpResponseRedirect, HttpResponse, \
- HttpResponseForbidden, HttpResponseServerError
-# Http404
-from django.template import RequestContext
+from django.http import HttpResponse, HttpResponseForbidden
from django.conf import settings
from base.shortcuts import get_object_with_related_or_404
View
@@ -5,7 +5,6 @@
import os
import shutil
import subprocess
-import time
import commonware.log
from django.http import HttpResponseServerError
@@ -356,10 +356,20 @@ var Attachment = new Class({
if (this.is_editable()) {
this.switchTo();
} else {
- var template_start = '<div id="attachment_view"><h3>'+this.options.filename+'</h3><div class="UI_Modal_Section">';
- var template_end = '</div><div class="UI_Modal_Actions"><ul><li><input type="reset" value="Close" class="closeModal"/></li></ul></div></div>';
- var template_middle = 'Download <a href="'+this.options.get_url+'">'+this.options.filename+'</a>';
- if (this.is_image()) template_middle += '<p><img src="'+this.options.get_url+'"/></p>';
+ var template_start = '<div id="attachment_view"><h3>'
+ +this.options.filename+'</h3><div class="UI_Modal_Section">';
+ var template_end = '</div><div class="UI_Modal_Actions"><ul><li>'
+ +'<input type="reset" value="Close" class="closeModal"/>'
+ +'</li></ul></div></div>';
+ var template_middle = 'Download <a href="'
+ +this.options.get_url
+ +'">'
+ +this.options.filename
+ +'</a>';
+ if (this.is_image()) {
+ template_middle += '<p><img src="'+this.options.get_url
+ +'"/></p>';
+ }
this.attachmentWindow = fd.displayModal(template_start+template_middle+template_end);
}
},
View
@@ -25,6 +25,9 @@ source $VENV/bin/activate
pip install -q -r requirements/compiled.txt
+# adding eventual SDK
+git submodule update --init
+
pushd vendor && git pull && git submodule update --init && popd
# Create paths we want for addons
View
@@ -1,44 +0,0 @@
-# script to update from 1.0a5 to 1.0a6
-
-import os
-import sys
-import site
-
-ROOT = os.path.dirname(os.path.abspath(os.path.join(__file__,'..')))
-path = lambda *a: os.path.join(ROOT, *a)
-
-site.addsitedir('./')
-site.addsitedir('../')
-
-site.addsitedir(path('vendor'))
-site.addsitedir(path('vendor/lib/python'))
-
-from django.core.management import execute_manager, setup_environ
-import MySQLdb
-
-import settings_local as settings
-setup_environ(settings)
-
-# database change
-conn = MySQLdb.connect (
- host=settings.DATABASES['default']['HOST'] if settings.DATABASES['default']['HOST'] else 'localhost',
- user=settings.DATABASES['default']['USER'],
- passwd=settings.DATABASES['default']['PASSWORD'],
- db=settings.DATABASES['default']['NAME'],
- )
-cursor = conn.cursor()
-
-SQL = """ALTER TABLE jetpack_sdk
- ADD kit_lib_id INT DEFAULT NULL"""
- #ADD kit_name VARCHAR(100) DEFAULT 'addon-kit',
- #ADD kit_fullname VARCHAR(100) DEFAULT 'Addon Kit',
- #ADD core_name VARCHAR(100) DEFAULT 'jetpack-core',
- #ADD core_fullname VARCHAR(100) DEFAULT 'Jetpack Core'"""
-try:
- cursor.execute(SQL)
-except MySQLdb.OperationalError, err:
- print "Error: %s" % str(err)
- print "Is the database already updated?"
-
-cursor.close()
-conn.close()
View
@@ -105,7 +105,7 @@
}
HOMEPAGE_PACKAGES_NUMBER = 3
-SDKDIR_PREFIX = tempfile.gettempdir() # temporary data - removed after xpi is created
+SDKDIR_PREFIX = tempfile.gettempdir() # removed after xpi is created
XPI_TARGETDIR = tempfile.gettempdir() # target dir - in shared directory
LIBRARY_AUTOCOMPLETE_LIMIT = 20
View
25 urls.py
@@ -1,13 +1,10 @@
-import os
-
from django.conf.urls.defaults import *
from django.views import static
from django.conf import settings
from base import views as base_views
-
urls = [
# home
url(r'^$', base_views.homepage, name='home'),
@@ -24,24 +21,6 @@
])
urls.extend([
- # static files
- # this should be used only in development server
- #url(r'^media/jetpack/(?P<path>.*)$', static.serve,
- # {'document_root': os.path.join(
- # settings.APP_MEDIA_PREFIX, 'jetpack', settings.APP_MEDIA_SUFFIX)
- # }, name='jetpack_media'),
- #url(r'^media/person/(?P<path>.*)$', static.serve,
- # {'document_root': os.path.join(
- # settings.APP_MEDIA_PREFIX, 'person', settings.APP_MEDIA_SUFFIX)
- # }, name='person_media'),
- #url(r'^media/api/(?P<path>.*)$', static.serve,
- # {'document_root': os.path.join(
- # settings.APP_MEDIA_PREFIX, 'api', settings.APP_MEDIA_SUFFIX)
- # }, name='api_media'),
- #url(r'^media/tutorial/(?P<path>.*)$', static.serve,
- # {'document_root': os.path.join(
- # settings.APP_MEDIA_PREFIX, 'tutorial', settings.APP_MEDIA_SUFFIX)
- # }, name='tutorial_media'),
url(r'^media/(?P<path>.*)$', static.serve,
{'document_root': settings.MEDIA_ROOT}, name='media'),
@@ -59,8 +38,8 @@
# Jetpack
(r'', include('jetpack.urls')),
-
- # Monitor
+
+ # Monitor
(r'', include('base.urls'))
])
urlpatterns = patterns('', *urls)
Oops, something went wrong.

0 comments on commit 08f01c7

Please sign in to comment.