|
|
@ -17,7 +17,7 @@ from flask_cors import CORS
|
|
|
|
# from couchdbkit import Server, Document
|
|
|
|
# from couchdbkit import Server, Document
|
|
|
|
import stripe
|
|
|
|
import stripe
|
|
|
|
import json
|
|
|
|
import json
|
|
|
|
from StringIO import StringIO
|
|
|
|
# from StringIO import StringIO
|
|
|
|
import re
|
|
|
|
import re
|
|
|
|
import os
|
|
|
|
import os
|
|
|
|
from utils.params import PARAMS
|
|
|
|
from utils.params import PARAMS
|
|
|
@ -66,10 +66,20 @@ def get_plans_json(id):
|
|
|
|
# Log this shit or not
|
|
|
|
# Log this shit or not
|
|
|
|
pass
|
|
|
|
pass
|
|
|
|
return "[]",HEADER
|
|
|
|
return "[]",HEADER
|
|
|
|
@app.route("/ui/signup/<id>")
|
|
|
|
@app.route("/signup",methods=['GET','POST'])
|
|
|
|
|
|
|
|
def get_stripe():
|
|
|
|
|
|
|
|
if request.method == 'GET' :
|
|
|
|
|
|
|
|
_object = {"data-key":CONFIG['stripe']['pub'].strip()}
|
|
|
|
|
|
|
|
return json.dumps(_object)
|
|
|
|
|
|
|
|
else:
|
|
|
|
|
|
|
|
print (request.args)
|
|
|
|
|
|
|
|
return 1
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@app.route("/ui/signup/<id>",methods=['GET','PUT'])
|
|
|
|
def signup(id):
|
|
|
|
def signup(id):
|
|
|
|
"""
|
|
|
|
"""
|
|
|
|
"""
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
|
|
mystore = store.factory.instance(name=id)
|
|
|
|
mystore = store.factory.instance(name=id)
|
|
|
|
plans = mystore.get.plans()
|
|
|
|
plans = mystore.get.plans()
|
|
|
|
index = int(request.args['index'])
|
|
|
|
index = int(request.args['index'])
|
|
|
@ -77,6 +87,8 @@ def signup(id):
|
|
|
|
|
|
|
|
|
|
|
|
args = {"product":id,"label":mystore.product['statement_descriptor'],"plan":plan,"context":CONTEXT,"now":datetime.now().year}
|
|
|
|
args = {"product":id,"label":mystore.product['statement_descriptor'],"plan":plan,"context":CONTEXT,"now":datetime.now().year}
|
|
|
|
args['theme'] = 'theme-clouds'
|
|
|
|
args['theme'] = 'theme-clouds'
|
|
|
|
|
|
|
|
args['cloud-view'] = CONFIG['cloud-view']
|
|
|
|
|
|
|
|
|
|
|
|
return render_template("signup.html",**args)
|
|
|
|
return render_template("signup.html",**args)
|
|
|
|
@app.route("/ui/<id>")
|
|
|
|
@app.route("/ui/<id>")
|
|
|
|
def get_plans_ui(id):
|
|
|
|
def get_plans_ui(id):
|
|
|
@ -88,7 +100,8 @@ def get_plans_ui(id):
|
|
|
|
label = mystore.product['statement_descriptor']
|
|
|
|
label = mystore.product['statement_descriptor']
|
|
|
|
args = {"product":id,"label":label,"description":description,"context":CONTEXT,"plans":mystore.get.plans(),"now":datetime.now().year}
|
|
|
|
args = {"product":id,"label":label,"description":description,"context":CONTEXT,"plans":mystore.get.plans(),"now":datetime.now().year}
|
|
|
|
args['theme'] = 'theme-clouds'
|
|
|
|
args['theme'] = 'theme-clouds'
|
|
|
|
print (mystore.product.keys())
|
|
|
|
# print (mystore.product.keys())
|
|
|
|
|
|
|
|
session['cloud-view'] = CONFIG['cloud-view']
|
|
|
|
return render_template('plans.html',**args)
|
|
|
|
return render_template('plans.html',**args)
|
|
|
|
@app.route("/init/<product>",methods=['POST'])
|
|
|
|
@app.route("/init/<product>",methods=['POST'])
|
|
|
|
def init(product):
|
|
|
|
def init(product):
|
|
|
@ -106,31 +119,42 @@ def init(product):
|
|
|
|
#
|
|
|
|
#
|
|
|
|
# We should just pull the factory method and get a storage handler to handle the logs
|
|
|
|
# We should just pull the factory method and get a storage handler to handle the logs
|
|
|
|
#
|
|
|
|
#
|
|
|
|
store = dict(CONFIG['couchdb'])
|
|
|
|
# store = dict(CONFIG['couchdb'])
|
|
|
|
store['dbname'] = product
|
|
|
|
# store['dbname'] = product
|
|
|
|
user = User(stripe=stripe,store=store,product=product)
|
|
|
|
# user = User(stripe=stripe,store=store,product=product)
|
|
|
|
user.subscribe(uid,plan_id)
|
|
|
|
# user.subscribe(uid,plan_id)
|
|
|
|
|
|
|
|
|
|
|
|
sub = None
|
|
|
|
# sub = None
|
|
|
|
if 'auid' in request.headers :
|
|
|
|
# if 'auid' in request.headers :
|
|
|
|
auid = request.headers['auid']
|
|
|
|
# auid = request.headers['auid']
|
|
|
|
user.update(emails=auid)
|
|
|
|
# user.update(emails=auid)
|
|
|
|
user.post()
|
|
|
|
# user.post()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
store = dict(CONFIG['couchdb'],**{})
|
|
|
|
# store = dict(CONFIG['couchdb'],**{})
|
|
|
|
store['dbname'] = product
|
|
|
|
# store['dbname'] = product
|
|
|
|
store['uid'] = 'logs'
|
|
|
|
# store['uid'] = 'logs'
|
|
|
|
|
|
|
|
|
|
|
|
sub = user.get(uid,'subscriptions')
|
|
|
|
# sub = user.get(uid,'subscriptions')
|
|
|
|
features = {}
|
|
|
|
# features = {}
|
|
|
|
for id in sub :
|
|
|
|
# for id in sub :
|
|
|
|
if sub[id]['active'] is True :
|
|
|
|
# if sub[id]['active'] is True :
|
|
|
|
features[id] = sub[id]
|
|
|
|
# features[id] = sub[id]
|
|
|
|
|
|
|
|
|
|
|
|
user.refresh(uid)
|
|
|
|
# user.refresh(uid)
|
|
|
|
session['key'] = user.user_key
|
|
|
|
# session['key'] = user.user_key
|
|
|
|
session['uid'] = uid
|
|
|
|
# session['uid'] = uid
|
|
|
|
|
|
|
|
mystore = store.factory.instance(name=product,email=uid)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
user = mystore.user
|
|
|
|
|
|
|
|
user.init (uid)
|
|
|
|
|
|
|
|
if not user.plan.info() :
|
|
|
|
|
|
|
|
mystore.plan.subscribe(email = user.info()['email'])
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
features = user.plan.info()['metadata']['features'] if 'features' in user.plan.info()['metadata'] else {}
|
|
|
|
|
|
|
|
print (features)
|
|
|
|
return json.dumps(features),200
|
|
|
|
return json.dumps(features),200
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -175,7 +199,7 @@ def subscribe(product):
|
|
|
|
session['key'] = user.user_key
|
|
|
|
session['key'] = user.user_key
|
|
|
|
session['uid'] = uid
|
|
|
|
session['uid'] = uid
|
|
|
|
session['active-plans'] = [item['id'] for item in plans]
|
|
|
|
session['active-plans'] = [item['id'] for item in plans]
|
|
|
|
print session['active-plans']
|
|
|
|
print (session['active-plans'])
|
|
|
|
return (json.dumps(plans),200)
|
|
|
|
return (json.dumps(plans),200)
|
|
|
|
|
|
|
|
|
|
|
|
def get_plans(product) :
|
|
|
|
def get_plans(product) :
|
|
|
@ -323,3 +347,4 @@ if __name__ == '__main__' :
|
|
|
|
app.config['MAX_CONTENT_LENGTH'] = 1600 * 1024 * 1024
|
|
|
|
app.config['MAX_CONTENT_LENGTH'] = 1600 * 1024 * 1024
|
|
|
|
|
|
|
|
|
|
|
|
app.run(port=PORT,threaded=True,host='0.0.0.0')
|
|
|
|
app.run(port=PORT,threaded=True,host='0.0.0.0')
|
|
|
|
|
|
|
|
# app.run() #'0.0.0.0',PORT,True,threaded=True)
|
|
|
|