Skip to content

Commit

Permalink
stripe form bs3 compatible, disabled cache.ram max utilization
Browse files Browse the repository at this point in the history
  • Loading branch information
mdipierro committed Apr 5, 2015
1 parent b02e8a6 commit a921751
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 43 deletions.
12 changes: 6 additions & 6 deletions applications/examples/views/appadmin.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ <h2>{{=T("Available Databases and Tables")}}</h2>
</ul>
<div class="tab-content">
<div class="tab-pane active" id="alltables">
<table>
<table class="table">
{{for db in sorted(databases):}}
{{for table in databases[db].tables:}}
{{qry='%s.%s.id>0'%(db,table)}}
Expand All @@ -40,7 +40,7 @@ <h2>{{=T("Available Databases and Tables")}}</h2>
{{=A("%s.%s" % (db,table),_href=URL('select',args=[db],vars=dict(query=qry)))}}
</th>
<td>
{{=A(str(T('New Record')),_href=URL('insert',args=[db,table]),_class="btn")}}
{{=A(str(T('New Record')),_href=URL('insert',args=[db,table]),_class="btn btn-default")}}
</td>
</tr>
{{pass}}
Expand All @@ -61,7 +61,7 @@ <h3>{{=T('Traceback')}}</h3>
</pre>
{{pass}}
{{if table:}}
{{=A(str(T('New Record')),_href=URL('insert',args=[request.args[0],table]),_class="btn")}}<br/><br/>
{{=A(str(T('New Record')),_href=URL('insert',args=[request.args[0],table]),_class="btn btn-default")}}<br/><br/>
<h3>{{=T("Rows in Table")}}</h3><br/>
{{else:}}
<h3>{{=T("Rows selected")}}</h3><br/>
Expand All @@ -72,8 +72,8 @@ <h3>{{=T("Rows selected")}}</h3><br/>
{{=T('"update" is an optional expression like "field1=\'newvalue\'". You cannot update or delete the results of a JOIN')}}</p>
<br/><br/>
<h4>{{=T("%s selected", nrows)}}</h4>
{{if start>0:}}{{=A(T('previous %s rows') % step,_href=URL('select',args=request.args[0],vars=dict(start=start-step)),_class="btn")}}{{pass}}
{{if stop<nrows:}}{{=A(T('next %s rows') % step,_href=URL('select',args=request.args[0],vars=dict(start=start+step)),_class="btn")}}{{pass}}
{{if start>0:}}{{=A(T('previous %s rows') % step,_href=URL('select',args=request.args[0],vars=dict(start=start-step)),_class="btn btn-default")}}{{pass}}
{{if stop<nrows:}}{{=A(T('next %s rows') % step,_href=URL('select',args=request.args[0],vars=dict(start=start+step)),_class="btn btn-default")}}{{pass}}
{{if rows:}}
<div style="overflow:auto; width:80%;">
{{linkto = lambda f, t, r: URL('update', args=[request.args[0], r, f]) if f else "#"}}
Expand All @@ -82,7 +82,7 @@ <h4>{{=T("%s selected", nrows)}}</h4>
</div>
{{pass}}
<br/><br/><h3>{{=T("Import/Export")}}</h3><br/>
<a href="{{=URL('csv',args=request.args[0],vars=dict(query=query))}}" class="btn">{{=T("export as csv file")}}</a>
<a href="{{=URL('csv',args=request.args[0],vars=dict(query=query))}}" class="btn btn-default">{{=T("export as csv file")}}</a>
{{=formcsv or ''}}

{{elif request.function=='insert':}}
Expand Down
2 changes: 1 addition & 1 deletion gluon/cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ class CacheAbstract(object):
"""

cache_stats_name = 'web2py_cache_statistics'
max_ram_utilization = 90 # percent
max_ram_utilization = None # percent

def __init__(self, request=None):
"""Initializes the object
Expand Down
70 changes: 35 additions & 35 deletions gluon/contrib/stripe.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,24 @@

class Stripe:
"""
Usage:
Use in WEB2PY (guaranteed PCI compliant)
def pay():
from gluon.contrib.stripe import StripeForm
form = StripeForm(
pk=STRIPE_PUBLISHABLE_KEY,
sk=STRIPE_SECRET_KEY,
amount=150, # $1.5 (amount is in cents)
description="Nothing").process()
if form.accepted:
payment_id = form.response['id']
redirect(URL('thank_you'))
elif form.errors:
redirect(URL('pay_error'))
return dict(form=form)
Low level API:
key='<api key>'
d = Stripe(key).charge(
amount=100, # 1 dollar!!!!
Expand All @@ -22,22 +39,6 @@ class Stripe:
{u'fee': 0, u'description': u'test charge', u'created': 1321242072, u'refunded': False, u'livemode': False, u'object': u'charge', u'currency': u'usd', u'amount': 100, u'paid': True, u'id': u'ch_sdjasgfga83asf', u'card': {u'exp_month': 5, u'country': u'US', u'object': u'card', u'last4': u'4242', u'exp_year': 2012, u'type': u'Visa'}}
if paid is True than transaction was processed
Use in WEB2PY (guaranteed PCI compliant)
def pay():
from gluon.contrib.stripe import StripeForm
form = StripeForm(
pk=STRIPE_PUBLISHABLE_KEY,
sk=STRIPE_SECRET_KEY,
amount=150, # $1.5 (amount is in cents)
description="Nothing").process()
if form.accepted:
payment_id = form.response['id']
redirect(URL('thank_you'))
elif form.errors:
redirect(URL('pay_error'))
return dict(form=form)
"""

URL_CHARGE = 'https://%s:@api.stripe.com/v1/charges'
Expand Down Expand Up @@ -188,37 +189,36 @@ def xml(self):
<h3>Payment Amount: {{=currency_symbol}} {{="%.2f" % (0.01*amount)}}</h3>
<form action="" method="POST" id="payment-form" class="form-horizontal">
<div class="form-row control-group">
<label class="control-label">Card Number</label>
<div class="controls">
<div class="form-row form-group">
<label class="col-sm-2 control-label">Card Number</label>
<div class="controls col-sm-10">
<input type="text" size="20" data-stripe="number"
placeholder="4242424242424242"/>
placeholder="4242424242424242" class="form-control"/>
</div>
</div>
<div class="form-row control-group">
<label class="control-label">CVC</label>
<div class="controls">
<div class="form-row form-group">
<label class="col-sm-2 control-label">CVC</label>
<div class="controls col-sm-10">
<input type="text" size="4" style="width:80px" data-stripe="cvc"
placeholder="XXX"/>
placeholder="XXX" class="form-control"/>
<a href="http://en.wikipedia.org/wiki/Card_Verification_Code" target="_blank">What is this?</a>
</div>
</div>
<div class="form-row control-group">
<label class="control-label">Expiration</label>
<div class="controls">
<input type="text" size="2" style="width:40px" data-stripe="exp-month"
placeholder="MM"/>
<div class="form-row form-group">
<label class="col-sm-2 control-label">Expiration</label>
<div class="controls col-sm-10">
<input type="text" size="2" style="width:40px; display:inline-block"
data-stripe="exp-month" placeholder="MM" class="form-control"/>
/
<input type="text" size="4" style="width:80px" data-stripe="exp-year"
placeholder="YYYY"/>
<input type="text" size="4" style="width:80px; display:inline-block"
data-stripe="exp-year" placeholder="YYYY" class="form-control"/>
</div>
</div>
<div class="control-group">
<div class="controls">
<div class="form-row form-group">
<div class="controls col-sm-offset-2 col-sm-10">
<button type="submit" class="btn btn-primary">Submit Payment</button>
<div class="payment-errors error hidden"></div>
</div>
Expand Down
2 changes: 1 addition & 1 deletion gluon/packages/dal

1 comment on commit a921751

@niphlod
Copy link
Member

@niphlod niphlod commented on a921751 Apr 6, 2015

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

again a bad commit pulling in latest NON-TAGGED DAL....

Please sign in to comment.