adding signup to parser

main
Steve Nyemba 2 years ago
parent 7c17aef037
commit b4e7acc5db

@ -1,6 +1,6 @@
{ {
"system":{ "system":{
"logo":"logo.svg","context":"", "theme":"oss.css", "logo":"www/parser/_images/cog-red.png","context":"", "theme":"oss.css",
"app":{ "app":{
"debug":true,"port":8000}, "debug":true,"port":8000},
@ -9,12 +9,19 @@
"id":"cloud", "id":"cloud",
"auth":"nextcloud-auth.json", "auth":"nextcloud-auth.json",
"store":"/home/steve/git/sites/parser/store-auth.json" "store":"/home/steve/git/sites/parser/store-auth.json"
},
"routes":{
"data-transport":{
"menu":"tools",
"path":"/home/steve/git/sites/data-transport/config.json"
}
} }
}, },
"plugins":{ "plugins":{
"store":["init","plans"] "store":["init","plans"],
"users":["signup"]
}, },
"layout":{ "layout":{
"header":{"title":"{x12} Parser :: Healthcare/IO","logo":true,"subtitle":"Open, Simple & Extensible - Powered by data-transport"}, "header":{"title":"{x12} Parser :: Healthcare/IO","logo":true,"subtitle":"Open, Simple & Extensible - Powered by data-transport"},
@ -22,7 +29,7 @@
"root":"www/parser", "root":"www/parser",
"index":"index.html", "index":"index.html",
"order":{ "order":{
"menu":["resources","about"] "menu":["tools","resources","about"]
}, },
"overwrite":{ "overwrite":{
"license":{ "license":{

@ -39,9 +39,15 @@ def plans (**_args) :
_features = _features.sort_values(by=[_key],ascending=False) _features = _features.sort_values(by=[_key],ascending=False)
_lrow = pd.DataFrame([dict(zip(columns,pricing))],index=['']) _lrow = pd.DataFrame([dict(zip(columns,pricing))],index=[''])
_df = pd.concat([_features,_lrow]) _df = _features
# _df = pd.concat([_features,_lrow])
return _df.to_json() return _df.to_json()
# _df[_plan['nickname']] = _features.values
# _df.index = list(_features.keys()) def signup (**_args):
# print (pd.DataFrame(_df)) _email = _args['email']
# return json.dumps([_plan for _plan in .. if _plan['active'] == True]) _name = None if 'name' in _args else _args['name']
product = store.get.product('healthcareio')
#
# If the user is already signed up
customer = store.get.customer(_email)

@ -0,0 +1,46 @@
import store
import json
import os
def __init__ (**_args):
_path = _args['config']['system']['source']['store']
if not store.isready() :
if os.path.exists(_path) :
f = open(_path)
_info = json.loads(f.read())
f.close()
store.init(_info['secret'])
return "1"
else:
return "0"
else:
return "1"
def signup(**_args):
"""
This function creates or pulls a customer's key from the backend (stripe)
"""
if not store.isready() :
__init__(**_args)
_email = _args['email']
_customer = store.get.customer(_email)
_user = {}
if not _customer :
#
# Create/add a new user information to the backend
_customer = store.set.customer(_email,'')
plans = store.get.plans('healthcareio')
plans = [plan for plan in plans if plan.amount == 0]
plan = plans[0]
#
# signup to free plan
store.set.subscribe(_customer.id,plan.id)
if _customer :
_customer = _customer[0]
_user['email'] = _email
_user['token'] = _customer['id']
return json.dumps(_user)
def upgrade (**_args):
pass
Loading…
Cancel
Save