<commit_before># 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
module.add_url_rule('/cart/', view_func=CartView.as_view('cart'))
module.add_url_rule('/cart/setitem/', view_func=SetItemView.as_view('setitem'))
module.add_url_rule('/cart/removeitem/',
                    view_func=RemoveItemView.as_view('removeitem'))
module.add_url_rule('/cart/setprocessor/',
                    view_func=SetProcessorView.as_view('setprocessor'))
module.add_url_rule('/cart/checkout/',
                    view_func=CheckoutView.as_view('checkout'))
module.add_url_rule('/cart/history/', view_func=HistoryView.as_view('history'))

"""
Every url accepts ajax requests, and so do not redirect anything.
in ajax request it will return JSON as response
/cart
    - if there is a cart, but it is checked_out, create a new one
    - show a link to cart history if any
    - show the cart to the user
    - context is "cart"
    - renders cart/cart.html template
    - list items and has form for quantity and extra info
    - different things can be done via api ex: config shipping
/cart/setitem
    - receives a POST with item information
    - if "uid" is present ans item exists it will be updated else created
    - "product" reference is passed as an "id" and converted to a reference
    - receive quantity, weight etc..
    - if "next" is present redirect to there else redirect to "/cart"
/cart/removeitem
    - receives a POST with item_id or product_id
    - use 'next' to redirect or '/cart'
/cart/setprocessor
    - receives a POST with processor identifier or id
/cart/setowner
    - requires logged in user
/cart/setstatus
    - user can set only from abandoned to pending
    - if there is a current 'pending' cart it will be set to 'abandoned'
    - admin can set to any status
/cart/configure
    - requires logged in user as cart owner
    - receive a POST
    - "property" can be shipping_data, sender_data, extra_costs, shipping_cost
/cart/checkout
   - if cart.requires_login:
       if user is not logged in it will redirect user to login page
   - Do the checkout process if the cart is "pending"
       else clean cart from session and redirect to history
   - if the processor has a pipeline in record or in class it will executed
       - record: pipeline
       - class: pre_pipeline, pos_pipeline
   - every method in pipeline  must act like a view
     and it will have self.cart, self.config and flask request and session<commit_msg>deprecated setowner method<commit_after># 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
module.add_url_rule('/cart/', view_func=CartView.as_view('cart'))
module.add_url_rule('/cart/setitem/', view_func=SetItemView.as_view('setitem'))
module.add_url_rule('/cart/removeitem/',
                    view_func=RemoveItemView.as_view('removeitem'))
module.add_url_rule('/cart/setprocessor/',
                    view_func=SetProcessorView.as_view('setprocessor'))
module.add_url_rule('/cart/checkout/',
                    view_func=CheckoutView.as_view('checkout'))
module.add_url_rule('/cart/history/', view_func=HistoryView.as_view('history'))

"""
Every url accepts ajax requests, and so do not redirect anything.
in ajax request it will return JSON as response
/cart
    - if there is a cart, but it is checked_out, create a new one
    - show a link to cart history if any
    - show the cart to the user
    - context is "cart"
    - renders cart/cart.html template
    - list items and has form for quantity and extra info
    - different things can be done via api ex: config shipping
/cart/setitem
    - receives a POST with item information
    - if "uid" is present ans item exists it will be updated else created
    - "product" reference is passed as an "id" and converted to a reference
    - receive quantity, weight etc..
    - if "next" is present redirect to there else redirect to "/cart"
/cart/removeitem
    - receives a POST with item_id or product_id
    - use 'next' to redirect or '/cart'
/cart/setprocessor
    - receives a POST with processor identifier or id
/cart/setstatus
    - user can set only from abandoned to pending
    - if there is a current 'pending' cart it will be set to 'abandoned'
    - admin can set to any status
/cart/configure
    - requires logged in user as cart owner
    - receive a POST
    - "property" can be shipping_data, sender_data, extra_costs, shipping_cost
/cart/checkout
   - if cart.requires_login:
       if user is not logged in it will redirect user to login page
   - Do the checkout process if the cart is "pending"
       else clean cart from session and redirect to history
   - if the processor has a pipeline in record or in class it will executed
       - record: pipeline
       - class: pre_pipeline, pos_pipeline
   - every method in pipeline  must act like a view
     and it will have self.cart, self.config and flask request and session
{'fraction_non_alphanumeric': 0.07870022539444027, 'fraction_numerical': 0.0003756574004507889, 'mean_word_length': 3.186320754716981, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3039010', 'n_tokens_mistral': 1491, 'n_tokens_neox': 1467, 'n_words': 598}