|
|
|
@ -17,7 +17,7 @@ from flask_cors import CORS
|
|
|
|
|
# from couchdbkit import Server, Document
|
|
|
|
|
import stripe
|
|
|
|
|
import json
|
|
|
|
|
from StringIO import StringIO
|
|
|
|
|
# from StringIO import StringIO
|
|
|
|
|
import re
|
|
|
|
|
import os
|
|
|
|
|
from utils.params import PARAMS
|
|
|
|
@ -66,10 +66,20 @@ def get_plans_json(id):
|
|
|
|
|
# Log this shit or not
|
|
|
|
|
pass
|
|
|
|
|
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):
|
|
|
|
|
"""
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
mystore = store.factory.instance(name=id)
|
|
|
|
|
plans = mystore.get.plans()
|
|
|
|
|
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['theme'] = 'theme-clouds'
|
|
|
|
|
args['cloud-view'] = CONFIG['cloud-view']
|
|
|
|
|
|
|
|
|
|
return render_template("signup.html",**args)
|
|
|
|
|
@app.route("/ui/<id>")
|
|
|
|
|
def get_plans_ui(id):
|
|
|
|
@ -88,7 +100,8 @@ def get_plans_ui(id):
|
|
|
|
|
label = mystore.product['statement_descriptor']
|
|
|
|
|
args = {"product":id,"label":label,"description":description,"context":CONTEXT,"plans":mystore.get.plans(),"now":datetime.now().year}
|
|
|
|
|
args['theme'] = 'theme-clouds'
|
|
|
|
|
print (mystore.product.keys())
|
|
|
|
|
# print (mystore.product.keys())
|
|
|
|
|
session['cloud-view'] = CONFIG['cloud-view']
|
|
|
|
|
return render_template('plans.html',**args)
|
|
|
|
|
@app.route("/init/<product>",methods=['POST'])
|
|
|
|
|
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
|
|
|
|
|
#
|
|
|
|
|
store = dict(CONFIG['couchdb'])
|
|
|
|
|
store['dbname'] = product
|
|
|
|
|
user = User(stripe=stripe,store=store,product=product)
|
|
|
|
|
user.subscribe(uid,plan_id)
|
|
|
|
|
# store = dict(CONFIG['couchdb'])
|
|
|
|
|
# store['dbname'] = product
|
|
|
|
|
# user = User(stripe=stripe,store=store,product=product)
|
|
|
|
|
# user.subscribe(uid,plan_id)
|
|
|
|
|
|
|
|
|
|
sub = None
|
|
|
|
|
if 'auid' in request.headers :
|
|
|
|
|
auid = request.headers['auid']
|
|
|
|
|
user.update(emails=auid)
|
|
|
|
|
user.post()
|
|
|
|
|
# sub = None
|
|
|
|
|
# if 'auid' in request.headers :
|
|
|
|
|
# auid = request.headers['auid']
|
|
|
|
|
# user.update(emails=auid)
|
|
|
|
|
# user.post()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
store = dict(CONFIG['couchdb'],**{})
|
|
|
|
|
store['dbname'] = product
|
|
|
|
|
store['uid'] = 'logs'
|
|
|
|
|
# store = dict(CONFIG['couchdb'],**{})
|
|
|
|
|
# store['dbname'] = product
|
|
|
|
|
# store['uid'] = 'logs'
|
|
|
|
|
|
|
|
|
|
sub = user.get(uid,'subscriptions')
|
|
|
|
|
features = {}
|
|
|
|
|
for id in sub :
|
|
|
|
|
if sub[id]['active'] is True :
|
|
|
|
|
features[id] = sub[id]
|
|
|
|
|
# sub = user.get(uid,'subscriptions')
|
|
|
|
|
# features = {}
|
|
|
|
|
# for id in sub :
|
|
|
|
|
# if sub[id]['active'] is True :
|
|
|
|
|
# features[id] = sub[id]
|
|
|
|
|
|
|
|
|
|
user.refresh(uid)
|
|
|
|
|
session['key'] = user.user_key
|
|
|
|
|
session['uid'] = uid
|
|
|
|
|
# user.refresh(uid)
|
|
|
|
|
# session['key'] = user.user_key
|
|
|
|
|
# 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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -175,7 +199,7 @@ def subscribe(product):
|
|
|
|
|
session['key'] = user.user_key
|
|
|
|
|
session['uid'] = uid
|
|
|
|
|
session['active-plans'] = [item['id'] for item in plans]
|
|
|
|
|
print session['active-plans']
|
|
|
|
|
print (session['active-plans'])
|
|
|
|
|
return (json.dumps(plans),200)
|
|
|
|
|
|
|
|
|
|
def get_plans(product) :
|
|
|
|
@ -323,3 +347,4 @@ if __name__ == '__main__' :
|
|
|
|
|
app.config['MAX_CONTENT_LENGTH'] = 1600 * 1024 * 1024
|
|
|
|
|
|
|
|
|
|
app.run(port=PORT,threaded=True,host='0.0.0.0')
|
|
|
|
|
# app.run() #'0.0.0.0',PORT,True,threaded=True)
|
|
|
|
|