diff --git a/make_post_sell/lib/currency.py b/make_post_sell/lib/currency.py new file mode 100644 index 0000000..cf40aeb --- /dev/null +++ b/make_post_sell/lib/currency.py @@ -0,0 +1,5 @@ +def dollars_to_cents(dollars): + return int(float(dollars) * 100) + +def cents_to_dollars(cents): + return int(cents) / 100.0 diff --git a/make_post_sell/models/cart.py b/make_post_sell/models/cart.py index 4b7b254..27644c7 100644 --- a/make_post_sell/models/cart.py +++ b/make_post_sell/models/cart.py @@ -29,11 +29,9 @@ from .shop import get_shops_by_ids from .cart_coupon import CartCoupon -from miscutils import ( - timestamp_to_ago_string, - dollars_to_cents, - cents_to_dollars, -) +from miscutils import timestamp_to_ago_string + +from ..lib.currency import cents_to_dollars try: unicode("") diff --git a/make_post_sell/models/coupon.py b/make_post_sell/models/coupon.py index bf6ea96..ed074d4 100644 --- a/make_post_sell/models/coupon.py +++ b/make_post_sell/models/coupon.py @@ -18,9 +18,9 @@ from .meta import ( from .cart_coupon import CartCoupon -from miscutils import ( - datetime_to_timestamp, - timestamp_to_datetime, +from miscutils import datetime_to_timestamp, timestamp_to_datetime + +from ..lib.currency import ( dollars_to_cents, cents_to_dollars, ) diff --git a/make_post_sell/models/price.py b/make_post_sell/models/price.py index 7344660..cecdc8c 100644 --- a/make_post_sell/models/price.py +++ b/make_post_sell/models/price.py @@ -6,10 +6,7 @@ from .meta import Base, RBase, UUIDType, foreign_key, now_timestamp from sqlalchemy.orm import relationship -from miscutils import ( - dollars_to_cents, - cents_to_dollars, -) +from ..lib.currency import cents_to_dollars class Price(RBase, Base): diff --git a/make_post_sell/models/product.py b/make_post_sell/models/product.py index d9cb255..e1fd5e5 100644 --- a/make_post_sell/models/product.py +++ b/make_post_sell/models/product.py @@ -28,7 +28,7 @@ from make_post_sell.lib.render import markdown_to_html from slugify import slugify -from miscutils import ( +from ..lib.currency import ( dollars_to_cents, cents_to_dollars, ) diff --git a/make_post_sell/views/product.py b/make_post_sell/views/product.py index 77ec74e..7106659 100644 --- a/make_post_sell/views/product.py +++ b/make_post_sell/views/product.py @@ -1,5 +1,7 @@ from pyramid.view import view_config +from pyramid.httpexceptions import HTTPFound + from . import ( user_required, shop_editor_required, @@ -8,12 +10,7 @@ from . import ( from ..models.product import Product -from pyramid.httpexceptions import HTTPFound - -from miscutils import ( - dollars_to_cents, - cents_to_dollars, -) +from ..lib.currency import dollars_to_cents def checkbox_to_bool(checkbox):