| 
						
						
							
								
							
						
						
					 | 
					 | 
					@ -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
 | 
				
			
			
				
				
			
		
	
		
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
						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]))
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
								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
 | 
					 | 
					 | 
					 | 
						DB = couchdb.dbase
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
							#handler.update_user(id=handler.getId(auid),uid=uid)
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
						
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
						handler = Domain.User(DB,stripe) ;
 | 
					 | 
					 | 
					 | 
						handler = Domain.User(DB,stripe) ;
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
							if 'customer.id' not in session :
 | 
					 | 
					 | 
					 | 
						if auid is None :
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
								handler.init(uid,plan)		
 | 
					 | 
					 | 
					 | 
							handler.init(uid,plan) ;
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
								id=handler.getId(uid)	
 | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
								session['customer.id'] = id
 | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
						else:
 | 
					 | 
					 | 
					 | 
						else:
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
								id = session['customer.id']
 | 
					 | 
					 | 
					 | 
							if couchdb.isready() == False:
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
								handler.initialize(uid)
 | 
					 | 
					 | 
					 | 
								handler.init(auid,plan)
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
								handler.update_user(id,uid=uid)
 | 
					 | 
					 | 
					 | 
								id = handler.getId(uid) 
 | 
				
			
			
				
				
			
		
	
		
		
	
		
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
							handler.initialize(auid)
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
							id = handler.getId(auid)
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
							handler.update_user(id=id,uid=uid) ;
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
						
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
						plans = handler.plans()
 | 
					 | 
					 | 
					 | 
						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
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					"""
 | 
					 | 
					 | 
					 | 
					"""
 | 
				
			
			
		
	
	
		
		
			
				
					| 
						
							
								
							
						
						
						
					 | 
					 | 
					
 
 |