diff --git a/make_post_sell/lib/mail.py b/make_post_sell/lib/mail.py index 4872408..8ba7238 100644 --- a/make_post_sell/lib/mail.py +++ b/make_post_sell/lib/mail.py @@ -76,10 +76,10 @@ def send_purchase_email(request, to_email, products, total_cost): product_text = "
".join(product_text_list) message_text = PURCHASE_1_TEXT.format( - "%.2f" % total_cost, request.app_url + "%.2f" % total_cost, request.host_url ) message_html = PURCHASE_1_HTML.format( - subject, request.app_url, product_text, "%.2f" % total_cost + subject, request.host_url, product_text, "%.2f" % total_cost ) send_pyramid_email(request, to_email, subject, message_text, message_html) @@ -119,10 +119,10 @@ def send_sale_email(request, shop, products, total_cost): product_text = "
".join(product_text_list) message_text = SALE_1_TEXT.format( - "%.2f" % total_cost, request.app_url + "%.2f" % total_cost, shop.absolute_sales_url(request) ) message_html = SALE_1_HTML.format( - subject, request.app_url, shop.id, product_text, "%.2f" % total_cost + subject, shop.absolute_sales_url(request), product_text, "%.2f" % total_cost ) # send a separate email for each shop owner. diff --git a/make_post_sell/lib/mail_messages.py b/make_post_sell/lib/mail_messages.py index 306cf0c..7dab3cf 100644 --- a/make_post_sell/lib/mail_messages.py +++ b/make_post_sell/lib/mail_messages.py @@ -40,7 +40,7 @@ Thank you very much! """ # 0: subject, -# 1: request.app_url, +# 1: request.host_url, # 2: product_text, # 3: total_cost, @@ -99,10 +99,9 @@ Great job! """ # 0: subject, -# 1: request.app_url, -# 2: shop.id, -# 3: product_text, -# 4: total_cost, +# 1: shop.absolute_sales_url +# 2: product_text, +# 3: total_cost, SALE_1_HTML = """ @@ -116,12 +115,12 @@ SALE_1_HTML = """ You made a sale! - ${4} + ${3} - {3} + {2}

- You may view all your sales at any time. + You may view all your sales at any time.

@@ -130,8 +129,8 @@ SALE_1_HTML = """

- - {2}/u/purchases + + {1}

diff --git a/make_post_sell/models/product.py b/make_post_sell/models/product.py index 1b66f51..d9cb255 100644 --- a/make_post_sell/models/product.py +++ b/make_post_sell/models/product.py @@ -86,7 +86,10 @@ class Product(RBase, Base): created_timestamp = Column(BigInteger, nullable=False) updated_timestamp = Column(BigInteger, nullable=False) + # this value should be treated as immutable after object creation. is_bundle = Column(Boolean, default=False, nullable=False) + + # this value should be treated as immutable after object creation. is_sellable = Column(Boolean, default=False, nullable=False) # lazy="joined" performs a left join to reduce queries, it's magic. @@ -188,10 +191,13 @@ class Product(RBase, Base): @property def is_ready(self): + """internal safety checks prior to allowing the sale of this product.""" if self.is_sellable: if self.is_bundle: return True if len(self.bundle_metadata["product-ids"]) >= 1 else False return self.has_product_file + + # content is always ready, for example a blog post only needs a title & description. return True @property @@ -331,11 +337,11 @@ class Product(RBase, Base): For example: - https://makepostsell.com/p/product-uuid + https://my.makepostsell.com/p/product-uuid """ if slug: - return "{}/p/{}/{}".format(request.app_url, self.id, self.slug) - return "{}/p/{}".format(request.app_url, self.id) + return "{}/p/{}/{}".format(request.host_url, self.id, self.slug) + return "{}/p/{}".format(request.host_url, self.id) def absolute_edit_url(self, request): """ diff --git a/make_post_sell/models/shop.py b/make_post_sell/models/shop.py index 6d774a4..7ea0ab7 100644 --- a/make_post_sell/models/shop.py +++ b/make_post_sell/models/shop.py @@ -145,6 +145,7 @@ class Shop(RBase, Base): @property def is_ready(self): + """is the shop ready to accept charges?""" if self.stripe_secret_api_key and self.stripe_public_api_key: return True return False @@ -226,11 +227,11 @@ class Shop(RBase, Base): For example: - https://makepostsell.com/s/ + https://my.makepostsell.com/s/ """ if slug: - return "{}/s/{}/{}".format(request.app_url, self.id, self.slug) - return "{}/s/{}".format(request.app_url, self.id) + return "{}/s/{}/{}".format(request.host_url, self.id, self.slug) + return "{}/s/{}".format(request.host_url, self.id) def absolute_settings_url(self, request): """ @@ -238,9 +239,8 @@ class Shop(RBase, Base): For example: - https://makepostsell.com/s//edit + https://my.makepostsell.com/s//settings """ - return "{}/settings".format(self.absolute_url(request, slug=False)) def absolute_about_url(self, request): @@ -249,8 +249,9 @@ class Shop(RBase, Base): For example: - https://makepostsell.com/s//about + https://my.makepostsell.com/s//about """ + # why ure slug for this URL, is it for SEO? return "{}/about".format(self.absolute_url(request)) def absolute_terms_url(self, request): @@ -259,6 +260,9 @@ class Shop(RBase, Base): def absolute_privacy_policy_url(self, request): return "{}/privacy-policy".format(self.absolute_url(request, slug=False)) + def absolute_sales_url(self, request): + return "{}/sales".format(self.absolute_url(request, slug=False)) + def set_description(self, new_description): self.description = new_description self.description_html = markdown_to_html(self.description) diff --git a/make_post_sell/request_methods.py b/make_post_sell/request_methods.py index 57bd3c2..844f733 100644 --- a/make_post_sell/request_methods.py +++ b/make_post_sell/request_methods.py @@ -129,22 +129,6 @@ def includeme(config): """Attach app settings dictionary.""" return app_settings - def add_app_url(request): - """ - Use the app_url from config if request.domain ends with the - configured root_domain. Otherwise just use the request's host_url - """ - config_app_url = request.app.get("app_url", request.host_url) - root_domain = request.app.get("root_domain") - if root_domain and request.domain.endswith(root_domain): - return config_app_url - elif request.domain == "localhost": - return config_app_url - return request.host_url - - def add_app_domain(request): - return request.app_url.split("://")[-1].split(":")[0] - def add_secure_uploads_client(request): """returns an S3 compatible client.""" import boto3 @@ -206,8 +190,6 @@ def includeme(config): config.add_request_method(add_spam, "spam", reify=True) config.add_request_method(add_app, "app", reify=True) - config.add_request_method(add_app_url, "app_url", reify=True) - config.add_request_method(add_app_domain, "app_domain", reify=True) config.add_request_method(add_is_shop_domain, "is_shop_domain", reify=True) config.add_request_method(add_is_saas_domain, "is_saas_domain", reify=True) diff --git a/make_post_sell/templates/base.j2 b/make_post_sell/templates/base.j2 index 7c911e5..9731a74 100644 --- a/make_post_sell/templates/base.j2 +++ b/make_post_sell/templates/base.j2 @@ -24,7 +24,7 @@ {% endif %} {%- block append_to_head_tag_section %} - {{ request.app_domain }} + {{ request.domain }} {% endblock %} diff --git a/make_post_sell/templates/product_edit.j2 b/make_post_sell/templates/product_edit.j2 index 31e3c05..6383e1d 100644 --- a/make_post_sell/templates/product_edit.j2 +++ b/make_post_sell/templates/product_edit.j2 @@ -1,6 +1,9 @@ {% extends "base.j2" -%} {%- block call_to_action -%} +
+
+permanent link: {{ product.absolute_url(request) }} {%- endblock call_to_action -%} {% block content -%}