|
|
@ -37,23 +37,46 @@ COUCHDB = Server(uri=CONFIG['couchdb']['uri']) ;
|
|
|
|
@app.route("/init/<app_name>",methods=['POST'])
|
|
|
|
@app.route("/init/<app_name>",methods=['POST'])
|
|
|
|
def init(app_name):
|
|
|
|
def init(app_name):
|
|
|
|
plans = []
|
|
|
|
plans = []
|
|
|
|
if 'uid' in request.headers:
|
|
|
|
handler = None
|
|
|
|
uid = request.headers['uid']
|
|
|
|
uid = request.headers['uid']
|
|
|
|
plan= request.headers['pid']
|
|
|
|
plan = request.headers['pid']
|
|
|
|
couchdb = Couchdb(uri=CONFIG['couchdb']['uri'],dbname=app_name,uid=uid)
|
|
|
|
auid = None
|
|
|
|
DB = couchdb.dbase
|
|
|
|
if 'uid' in request.headers and 'auid' not in request.headers:
|
|
|
|
handler = Domain.User(DB,stripe) ;
|
|
|
|
id = uid
|
|
|
|
if 'customer.id' not in session :
|
|
|
|
#couchdb = Couchdb(uri=CONFIG['couchdb']['uri'],dbname=app_name,uid=uid,create=False)
|
|
|
|
handler.init(uid,plan)
|
|
|
|
#DB = couchdb.dbase
|
|
|
|
id=handler.getId(uid)
|
|
|
|
if 'auid' in request.headers :
|
|
|
|
session['customer.id'] = id
|
|
|
|
auid = request.headers['auid']
|
|
|
|
else:
|
|
|
|
auid = json.loads(auid)if auid.startswith('[') else auid
|
|
|
|
id = session['customer.id']
|
|
|
|
if isinstance(auid,list) :
|
|
|
|
handler.initialize(uid)
|
|
|
|
auid = list(set(auid) - set([uid]))
|
|
|
|
handler.update_user(id,uid=uid)
|
|
|
|
|
|
|
|
plans = handler.plans()
|
|
|
|
if len(auid) == 0:
|
|
|
|
|
|
|
|
auid = None
|
|
|
|
|
|
|
|
id = uid
|
|
|
|
|
|
|
|
else:
|
|
|
|
|
|
|
|
auid = auid[0]
|
|
|
|
|
|
|
|
id = auid
|
|
|
|
|
|
|
|
couchdb = Couchdb(uri=CONFIG['couchdb']['uri'],dbname=app_name,uid=id,create=False)
|
|
|
|
|
|
|
|
DB = couchdb.dbase
|
|
|
|
|
|
|
|
#handler.update_user(id=handler.getId(auid),uid=uid)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
handler = Domain.User(DB,stripe) ;
|
|
|
|
|
|
|
|
if auid is None :
|
|
|
|
|
|
|
|
handler.init(uid,plan) ;
|
|
|
|
|
|
|
|
else:
|
|
|
|
|
|
|
|
if couchdb.isready() == False:
|
|
|
|
|
|
|
|
handler.init(auid,plan)
|
|
|
|
|
|
|
|
id = handler.getId(uid)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
handler.initialize(auid)
|
|
|
|
|
|
|
|
id = handler.getId(auid)
|
|
|
|
|
|
|
|
handler.update_user(id=id,uid=uid) ;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
plans = handler.plans()
|
|
|
|
#return json.dumps(plans)
|
|
|
|
#return json.dumps(plans)
|
|
|
|
return features(app_name)
|
|
|
|
_features = features(app_name)
|
|
|
|
|
|
|
|
return _features
|
|
|
|
"""
|
|
|
|
"""
|
|
|
|
This function will update the user's email
|
|
|
|
This function will update the user's email
|
|
|
|
"""
|
|
|
|
"""
|
|
|
|