Skip to content

Commit

Permalink
pep8 fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
stephenmcd committed Nov 2, 2014
1 parent eb19edf commit 3564efe
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 22 deletions.
4 changes: 2 additions & 2 deletions cartridge/project_template/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -320,8 +320,8 @@
"mezzanine.pages",
"mezzanine.galleries",
"mezzanine.twitter",
#"mezzanine.accounts",
#"mezzanine.mobile",
# "mezzanine.accounts",
# "mezzanine.mobile",
)

# List of processors used by RequestContext to populate the context.
Expand Down
8 changes: 3 additions & 5 deletions cartridge/shop/management/commands/product_db.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
IMAGE = _("Image")
CATEGORY = _("Category")
SUB_CATEGORY = _("Sub-Category")
#SIZE = _("Size")
# SIZE = _("Size")
NUM_IN_STOCK = _("Number in Stock")
UNIT_PRICE = _("Unit Price")
SALE_PRICE = _("Sale Price")
Expand All @@ -49,8 +49,6 @@
DATETIME_FORMAT = "%s %s" % (DATE_FORMAT, TIME_FORMAT)
SITE_MEDIA_IMAGE_DIR = _("product")
PRODUCT_IMAGE_DIR = os.path.join(settings.STATIC_ROOT, SITE_MEDIA_IMAGE_DIR)
# python < 2.7 doesn't have dictionary comprehensions ;(
#TYPE_CHOICES = {choice:id for id, choice in settings.SHOP_OPTION_TYPE_CHOICES}
TYPE_CHOICES = dict()
for id, choice in settings.SHOP_OPTION_TYPE_CHOICES:
TYPE_CHOICES[choice] = id
Expand Down Expand Up @@ -125,7 +123,7 @@ def _make_image(image_str, product):
if not os.path.exists(image_path):
raise CommandError("NO FILE %s" % image_path)
shutil.copy(image_path, PRODUCT_IMAGE_DIR)
#shutil.copy(image_path, os.path.join(PRODUCT_IMAGE_DIR, "orig"))
# shutil.copy(image_path, os.path.join(PRODUCT_IMAGE_DIR, "orig"))
image, created = ProductImage.objects.get_or_create(
file="%s" % (os.path.join(SITE_MEDIA_IMAGE_DIR, image_str)),
description=image_str, # TODO: handle column for this.
Expand All @@ -142,7 +140,7 @@ def _make_date(date_str, time_str):
def import_products(csv_file):
print(_("Importing .."))
# More appropriate for testing.
#Product.objects.all().delete()
# Product.objects.all().delete()
reader = csv.DictReader(open(csv_file), delimiter=',')
for row in reader:
print(row)
Expand Down
11 changes: 3 additions & 8 deletions cartridge/shop/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -779,19 +779,14 @@ def update_products(self):
# Work around for MySQL which does not allow update
# to operate on subquery where the FROM clause would
# have it operate on the same table, so we update
# each instance individually:

# http://dev.mysql.com/doc/refman/5.0/en/subquery-errors.html

# each instance individually: http://bit.ly/1xMOGpU
#
# Also MySQL may raise a 'Data truncated' warning here
# when doing a calculation that exceeds the precision
# of the price column. In this case it's safe to ignore
# it and the calculation will still be applied, but
# we need to massage transaction management in order
# to continue successfully:

# https://groups.google.com/forum/#!topic/django-developers/ACLQRF-71s8

# to continue successfully: http://bit.ly/1xMOJCd
for priced in priced_objects.filter(**extra_filter):
for field, value in list(update.items()):
setattr(priced, field, value)
Expand Down
8 changes: 4 additions & 4 deletions cartridge/shop/payment/authorizenet.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,10 +101,10 @@ def process(request, order_form, order):
# Response_Reason_Codes_and_Response_Reason_Text.htm
# not exactly sure what the reason code is
response_code = parsed_results[0]
#reason_code = parsed_results[1]
#response_reason_code = parsed_results[2]
#response_text = parsed_results[3]
#transaction_id = parsed_results[6]
# reason_code = parsed_results[1]
# response_reason_code = parsed_results[2]
# response_text = parsed_results[3]
# transaction_id = parsed_results[6]
success = response_code == '1'
if not success:
raise CheckoutError("Transaction declined: " + parsed_results[2])
Expand Down
2 changes: 1 addition & 1 deletion cartridge/shop/payment/paypal.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ def __init__(self, *args, **kwargs):
raise CheckoutError("Could not talk to PayPal payment gateway")
parsed_results = QueryDict(all_results)
state = parsed_results['ACK']
if not state in ["Success", "SuccessWithWarning"]:
if state not in ["Success", "SuccessWithWarning"]:
raise CheckoutError(parsed_results['L_LONGMESSAGE0'])
return parsed_results['TRANSACTIONID']

Expand Down
2 changes: 1 addition & 1 deletion cartridge/shop/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def setUp(self):
"""
Set up test data - category, product and options.
"""
self._published = {"status": CONTENT_STATUS_PUBLISHED}
self._published = {"title": "test", "status": CONTENT_STATUS_PUBLISHED}
self._category = Category.objects.create(**self._published)
self._product = Product.objects.create(**self._published)
for option_type in settings.SHOP_OPTION_TYPE_CHOICES:
Expand Down
2 changes: 1 addition & 1 deletion cartridge/shop/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ def cart(request, template="shop/cart.html",
context = {"cart_formset": cart_formset}
settings.use_editable()
if (settings.SHOP_DISCOUNT_FIELD_IN_CART and
DiscountCode.objects.active().exists()):
DiscountCode.objects.active().exists()):
context["discount_form"] = discount_form
return render(request, template, context)

Expand Down

0 comments on commit 3564efe

Please sign in to comment.