From 5a201bddf77ef08a1135ceb6c5c2d2d540235706 Mon Sep 17 00:00:00 2001 From: Steve Nyemba Date: Mon, 21 Dec 2020 23:32:19 -0600 Subject: [PATCH] bug fix: added contracting work support on products --- src/api/static/css/plans.css | 6 ++-- src/api/store.py | 10 +++++- src/api/templates/plans.html | 70 +++++++++++++++++++++--------------- 3 files changed, 53 insertions(+), 33 deletions(-) diff --git a/src/api/static/css/plans.css b/src/api/static/css/plans.css index 15b8fa1..e071385 100644 --- a/src/api/static/css/plans.css +++ b/src/api/static/css/plans.css @@ -84,7 +84,7 @@ img {width:48px} margin-left:10%; margin-right:10%; - height:70%; + height:85%; align-content:center; } .footer { @@ -104,6 +104,6 @@ img {width:48px} grid-template-columns: auto 32px; grid-gap:2px; font-size:24px; font-family:verdana; text-transform: capitalize; border-bottom:1px solid #CAD5E0; } -.plan .feature {display:grid; grid-template-columns: 60% 40%; grid-gap:2px; margin:2px;} +.plan .feature {display:grid; grid-template-columns: 60% 40%; grid-gap:2px; margin:4px;} .plan .feature .label {text-transform: uppercase; grid-column:1; font-size:14px;} -.plan .feature .status {font-size:20px; text-align: right; font-size:14px;} \ No newline at end of file +.plan .feature .status {font-size:14px; text-align: right; } diff --git a/src/api/store.py b/src/api/store.py index c738e18..0dd9173 100644 --- a/src/api/store.py +++ b/src/api/store.py @@ -308,7 +308,7 @@ class Plans(Store) : This function will retrieve plan information associated with the given product id """ Store.__init__(self,**args) - + contract = {"nickname":"Enterprise","metadata":{}} info = stripe.price.Price.list(product=self.product['id']).data self.plans = [] self.checkout = [] @@ -322,6 +322,11 @@ class Plans(Store) : self.plans.append(_item) if 'features' in item.metadata : _item['metadata']['features'] = json.loads(item.metadata['features']) + if 'contract' in self.product['metadata'] and not contract['metadata']: + contract['metadata']={'features':{}} + for feature_key in _item['metadata']['features'] : + contract['metadata']['features'][feature_key] = 1 + else: _item['metadata']['features'] = {} # self.plans.append(_item) @@ -332,6 +337,9 @@ class Plans(Store) : # elif self.plans self.plans.sort(key=lambda item: item['unit_amount']) self.checkout.sort(key=lambda item:item['unit_amount']) + if contract['metadata'] : + self.plans.append(contract) + if 'email' in args : self.user = User(args['email'],self.plans) else: diff --git a/src/api/templates/plans.html b/src/api/templates/plans.html index 293f2e1..8091242 100755 --- a/src/api/templates/plans.html +++ b/src/api/templates/plans.html @@ -114,7 +114,6 @@ httpclient.setHeader("Content-Type","application/json") httpclient.setData(JSON.stringify(info) ) httpclient.post('{{context|safe}}/store',function(x){}) - if (data.unit_amount == 0|| data.amount == 0){ // // We should not be prompting the user but automatically logging her into her session @@ -283,25 +282,30 @@ $(document).ready(function(){ {% else %}
{% endif %} - {% if item.unit_amount == 0%} -
- Free -
- - {%else%} -
- - $ {{ item.unit_amount/100 }} - / {{item.recurring.interval[:]}} + {% if 'unit_amount' in item %} + {% if item.unit_amount == 0%} +
+ +
+ + {%else%} +
+ + $ {{ item.unit_amount/100 }} + / {{item.recurring.interval[:]}} -
- {% endif %} +
+ {% endif %} + {% else %} +
+
+ {% endif %}
{% for key,value in item.metadata['features'].items() %}
-
{{ key }}
+
{{ key.replace('_',' ') }}
{% if value == True %}
{% elif value == False %} @@ -316,22 +320,30 @@ $(document).ready(function(){

-

-
Signup Now
- - {% if item.unit_amount == 0 %} -
- Free -
- - {%else%} -
- $ {{ item.unit_amount/100 }} - / {{item.recurring.interval[:]}} + {% if 'unit_amount' in item %} + +
+
Signup Now
+ + {% if item.unit_amount == 0 %} +
+ Free +
+ + {%else%} +
+ $ {{ item.unit_amount/100 }} + / {{item.recurring.interval[:]}} + +
+ {% endif %} +
+ {% else %} -
- {% endif %} -
+
+
Contact Us
+
+ {% endif %}