Steve L. Nyemba 7 years ago
parent 0368d78496
commit 4c1e326b51

BIN
.DS_Store vendored

Binary file not shown.

BIN
src/.DS_Store vendored

Binary file not shown.

BIN
src/api/.DS_Store vendored

Binary file not shown.

@ -1,6 +1,11 @@
""" """
Steve L. Nyemba <steve@the-phi.com>
The Phi Technology, LLC - Store
This file handles customer & plans associated with a given product/app This file handles customer & plans associated with a given product/app
The subscription works as follows: We understand that a product will have multiple plans under it and we make sure that we always have a free version:
- Having a free product insures there is no excuse not to signup users
- If a product doesn't fall under this model we will find a way to fix it.
- -
""" """
from __future__ import division from __future__ import division
@ -34,49 +39,71 @@ COUCHDB = Server(uri=CONFIG['couchdb']['uri']) ;
This function will set the user information to the session and update the information This function will set the user information to the session and update the information
@header uid user email address @header uid user email address
""" """
@app.route("/init/<app_name>",methods=['POST']) @app.route("/init/<product>",methods=['POST'])
def init(app_name): def init(product):
plans = [] """
handler = None This function initializes a product to a given user,
uid = request.headers['uid'] if the user has provided a user identifier it will be used as her primary email. The understanding is that a product may have multiple plans under it but always a free one
plan = request.headers['pid'] @param uid user's email (primary)
auid = None @param pid plan identifier
if 'uid' in request.headers and 'auid' not in request.headers: """
id = uid email = request.headers['uid']
#couchdb = Couchdb(uri=CONFIG['couchdb']['uri'],dbname=app_name,uid=uid,create=False) plan_id = request.headers['pid']
#DB = couchdb.dbase user = User(stripe=stripe,store=CONFIG['couchdb'],product=product)
user.susbscribe(uid,plan_id)
if 'auid' in request.headers : if 'auid' in request.headers :
auid = request.headers['auid'] auid = request.header['auid']
auid = json.loads(auid)if auid.startswith('[') else auid user.update(emails=auid)
if isinstance(auid,list) : user.post()
auid = list(set(auid) - set([uid])) features = json.loads(users.me['subscriptions'][pid][0]['metadata'])
if len(auid) == 0:
auid = None
id = uid
else: else:
auid = auid[0] features = user.get(uid,key)
id = auid user.refresh()
couchdb = Couchdb(uri=CONFIG['couchdb']['uri'],dbname=app_name,uid=id,create=False) return json.dumps(features),200
DB = couchdb.dbase
#handler.update_user(id=handler.getId(auid),uid=uid)
handler = Domain.User(DB,stripe) ; # @app.route("/init/<app_name>",methods=['POST'])
if auid is None : # def init(app_name):
handler.init(uid,plan) ; # plans = []
else: # handler = None
if couchdb.isready() == False: # uid = request.headers['uid']
handler.init(auid,plan) # plan = request.headers['pid']
id = handler.getId(uid) # auid = None
# if 'uid' in request.headers and 'auid' not in request.headers:
# id = uid
# #couchdb = Couchdb(uri=CONFIG['couchdb']['uri'],dbname=app_name,uid=uid,create=False)
# #DB = couchdb.dbase
# if 'auid' in request.headers :
# auid = request.headers['auid']
# auid = json.loads(auid)if auid.startswith('[') else auid
# if isinstance(auid,list) :
# auid = list(set(auid) - set([uid]))
handler.initialize(auid) # if len(auid) == 0:
id = handler.getId(auid) # auid = None
handler.update_user(id=id,uid=uid) ; # 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)
plans = handler.plans() # handler = Domain.User(DB,stripe) ;
#return json.dumps(plans) # if auid is None :
_features = features(app_name) # handler.init(uid,plan) ;
return _features # 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)
# _features = features(app_name)
# return _features
""" """
This function will update the user's email This function will update the user's email
""" """

Binary file not shown.

Before

Width:  |  Height:  |  Size: 357 KiB

After

Width:  |  Height:  |  Size: 357 KiB

Before

Width:  |  Height:  |  Size: 9.6 KiB

After

Width:  |  Height:  |  Size: 9.6 KiB

Before

Width:  |  Height:  |  Size: 16 KiB

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

Binary file not shown.

File diff suppressed because it is too large Load Diff
Loading…
Cancel
Save