Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
styling
  • Loading branch information
rochacbruno committed Sep 3, 2015
1 parent c9611b6 commit b1e7339
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 23 deletions.
6 changes: 2 additions & 4 deletions __init__.py
@@ -1,14 +1,12 @@
# coding: utf-8

from quokka.core.app import QuokkaModule
module = QuokkaModule("cart", __name__,
template_folder="templates", static_folder="static")

from .views import CartView, SetItemView, RemoveItemView, SetProcessorView, \
CheckoutView, HistoryView, ConfirmationView, NotificationView

from .functions import get_current_cart

module = QuokkaModule("cart", __name__,
template_folder="templates", static_folder="static")

# template globals
module.add_app_template_global(get_current_cart)
Expand Down
2 changes: 1 addition & 1 deletion commands.py
Expand Up @@ -20,4 +20,4 @@ def run(self, title=None):
carts = carts(title=title)

for cart in carts:
print(cart)
print(cart) # noqa
6 changes: 2 additions & 4 deletions models.py
Expand Up @@ -451,10 +451,8 @@ def set_item(self, **kwargs):

def remove_item(self, **kwargs):
deleted = self.items.delete(**kwargs)
print self.reference
if self.reference and hasattr(self.reference, 'remove_item'):
self.reference.remove_item(**kwargs)
print self.reference
return deleted

def checkout(self, processor=None, *args, **kwargs):
Expand Down Expand Up @@ -493,8 +491,8 @@ def process_pipeline(self):

pipelines = self.build_pipeline()
index = session.get('cart_pipeline_index', 0)
Pipeline = import_string(pipelines[index])
return Pipeline(self, pipelines, index)._preprocess()
pipeline = import_string(pipelines[index])
return pipeline(self, pipelines, index)._preprocess()

def set_processor(self, processor=None):
if not self.processor:
Expand Down
8 changes: 4 additions & 4 deletions pipelines/base.py
Expand Up @@ -61,14 +61,14 @@ def process(self):
def go(self, index=None, name=None):
index = index or self.index + 1
try:
Pipeline = import_string(self.pipeline[index])
pipeline = import_string(self.pipeline[index])
except IndexError:
raise PipelineOverflow("Pipeline overflow at %s" % index)
raise PipelineOverflow("pipeline overflow at %s" % index)

if not issubclass(Pipeline, CartPipeline):
if not issubclass(pipeline, CartPipeline):
raise ValueError("Pipelines should be subclass of CartPipeline")

return Pipeline(self.cart, self.pipeline, index)
return pipeline(self.cart, self.pipeline, index)


class CartItemPipeline(CartPipeline):
Expand Down
16 changes: 8 additions & 8 deletions processors/pagseguro_processor.py
Expand Up @@ -103,15 +103,15 @@ def notification(self):
if not reference:
return "reference not found"

PREFIX = self.pg.config.get('REFERENCE_PREFIX', '') or ''
PREFIX = PREFIX.replace('%s', '')
prefix = self.pg.config.get('REFERENCE_PREFIX', '') or ''
prefix = prefix.replace('%s', '')

status = getattr(response, 'status', None)
transaction_code = getattr(response, 'code', None)

# TODO: get grossAmount to populate a payment with methods
# get grossAmount to populate a payment with methods
try:
ref = reference.replace(PREFIX, '')
ref = reference.replace(prefix, '')
qs = Cart.objects.filter(
reference_code=ref
) or Cart.objects.filter(id=ref)
Expand Down Expand Up @@ -162,17 +162,17 @@ def confirmation(self): # redirect_url
logger.error("no reference found")
return render_template('cart/simple_confirmation.html',
**context)
PREFIX = self.pg.config.get('REFERENCE_PREFIX', '') or ''
PREFIX = PREFIX.replace('%s', '')
prefix = self.pg.config.get('REFERENCE_PREFIX', '') or ''
prefix = prefix.replace('%s', '')

status = getattr(response, 'status', None)

# TODO: get grossAmount to populate a payment with methods
# get grossAmount to populate a payment with methods
try:
# self.cart = Cart.objects.get(
# reference_code=reference.replace(PREFIX, '')
# )
ref = reference.replace(PREFIX, '')
ref = reference.replace(prefix, '')
qs = Cart.objects.filter(
reference_code=ref
) or Cart.objects.filter(id=ref)
Expand Down
2 changes: 1 addition & 1 deletion tasks.py
Expand Up @@ -7,4 +7,4 @@

@celery.task
def cart_task():
print "Doing something async..."
print "Doing something async..." # noqa
1 change: 0 additions & 1 deletion views.py
Expand Up @@ -69,7 +69,6 @@ def get(self):
class SetItemView(BaseView):
def post(self):
cart = Cart.get_cart()
print request.form
params = {k: v for k, v in request.form.items() if not k == "next"}
item = cart.set_item(**params)
return self.redirect(item=item)
Expand Down

0 comments on commit b1e7339

Please sign in to comment.