|
|
|
@ -15,7 +15,7 @@ from flask_session import Session
|
|
|
|
|
from flask_cors import CORS
|
|
|
|
|
from flask_pymongo import PyMongo
|
|
|
|
|
from flask_mongo_sessions import MongoDBSessionInterface
|
|
|
|
|
|
|
|
|
|
import transport
|
|
|
|
|
import stripe
|
|
|
|
|
import json
|
|
|
|
|
# from StringIO import StringIO
|
|
|
|
@ -53,18 +53,21 @@ app = Flask(__name__)
|
|
|
|
|
CORS(app)
|
|
|
|
|
|
|
|
|
|
SYS_STORE = CONFIG['store']
|
|
|
|
|
|
|
|
|
|
LOGGER = transport.factory.instance(**SYS_STORE['logger'])
|
|
|
|
|
# @app.route("/donate")
|
|
|
|
|
# def _donate() :
|
|
|
|
|
|
|
|
|
|
# amount = float(request.args['amount']) if 'amount' in request.args else 5.0
|
|
|
|
|
# args = {'amount':amount,'context':CONTEXT}
|
|
|
|
|
# return render_template('donate.html',**args)
|
|
|
|
|
def get_id(id):
|
|
|
|
|
return CONFIG['default']['id'] if not id else id
|
|
|
|
|
@app.route("/")
|
|
|
|
|
def index():
|
|
|
|
|
if 'default' in CONFIG:
|
|
|
|
|
id = CONFIG['default']['id']
|
|
|
|
|
return get_plans_ui(id)
|
|
|
|
|
|
|
|
|
|
headers = {"content-type":"application/json"}
|
|
|
|
|
mystore = store.factory.instance(name='music')
|
|
|
|
|
products = mystore.get.products()
|
|
|
|
@ -234,6 +237,7 @@ def get_plans_ui(id):
|
|
|
|
|
This function loads the form for signup and information about the various plans for a given product.
|
|
|
|
|
:id name of the products
|
|
|
|
|
"""
|
|
|
|
|
id = get_id(id) #-- will return default if need be
|
|
|
|
|
mystore = store.factory.instance(name=id)
|
|
|
|
|
#
|
|
|
|
|
# sort plans by
|
|
|
|
@ -243,7 +247,6 @@ def get_plans_ui(id):
|
|
|
|
|
args = {"product":id,"label":label,"description":description,"context":CONTEXT,"plans":mystore.get.plans(),"now":datetime.now().year}
|
|
|
|
|
args['product'] = mystore.product
|
|
|
|
|
args['theme'] = 'theme-clouds'
|
|
|
|
|
# print (mystore.product.keys())
|
|
|
|
|
session['cloud-view'] = CONFIG['cloud-view'].replace(':id',id)
|
|
|
|
|
session['product'] = mystore.product
|
|
|
|
|
return render_template('plans.html',**args)
|
|
|
|
@ -382,6 +385,7 @@ def init(product):
|
|
|
|
|
|
|
|
|
|
user = mystore.user
|
|
|
|
|
user.init (uid)
|
|
|
|
|
# prrint (user.plan.info())
|
|
|
|
|
if not user.plan.info() :
|
|
|
|
|
mystore.plan.subscribe(email = user.info()['email'])
|
|
|
|
|
|
|
|
|
@ -449,16 +453,16 @@ def features(product):
|
|
|
|
|
if __name__ == '__main__' :
|
|
|
|
|
#
|
|
|
|
|
# setup mongodb session management (not sure why)
|
|
|
|
|
app.config['SESSION_TYPE'] = 'mongodb'
|
|
|
|
|
app.config['MONGO_URI'] = 'mongodb://localhost:27017'
|
|
|
|
|
app.config['SESSION_MONGODB_DB'] = 'sessions'
|
|
|
|
|
app.config['SESSION_MONGODB_COLLECT'] = 'store'
|
|
|
|
|
mongo = PyMongo(app)
|
|
|
|
|
app.session_interface = MongoDBSessionInterface(app,mongo.db, 'store')
|
|
|
|
|
#app.config['SESSION_TYPE'] = 'mongodb'
|
|
|
|
|
#app.config['MONGO_URI'] = 'mongodb://localhost:27017'
|
|
|
|
|
#app.config['SESSION_MONGODB_DB'] = CONFIG['store']['logger']['db']
|
|
|
|
|
#app.config['SESSION_MONGODB_COLLECT'] = 'session'
|
|
|
|
|
#mongo = PyMongo(app)
|
|
|
|
|
#app.session_interface = MongoDBSessionInterface(app,mongo.db, 'store')
|
|
|
|
|
|
|
|
|
|
app.debug = True ;
|
|
|
|
|
app.secret_key = '360-8y-[0v@t10n]+kr81v17y'
|
|
|
|
|
app.config['MAX_CONTENT_LENGTH'] = 1600 * 1024 * 1024
|
|
|
|
|
Session(app)
|
|
|
|
|
#Session(app)
|
|
|
|
|
app.run(port=PORT,threaded=True,host='0.0.0.0')
|
|
|
|
|
# app.run() #'0.0.0.0',PORT,True,threaded=True)
|
|
|
|
|