Ejemplo n.º 1
0
def set_nickname():
    """ xxx """
    part1 = ''
    part2 = ''
    num = ''
    return_data = ''

    connection = pymysql.connect(host=DB_SRV,
                                 user=DB_USR,
                                 password=DB_PWD,
                                 db=DB_NAME,
                                 charset='utf8mb4',
                                 cursorclass=pymysql.cursors.DictCursor)
    cursor = connection.cursor(pymysql.cursors.SSCursor)
    sql = "SELECT part_one FROM randwords ORDER BY RAND() LIMIT 1"
    cursor.execute(sql)
    res = cursor.fetchall()
    for row in res:
        part1 = row[0]
    sql = "SELECT part_two FROM randwords ORDER BY RAND() LIMIT 1"
    cursor.execute(sql)
    res = cursor.fetchall()
    for row in res:
        part2 = row[0]
    cursor.close()
    connection.close()
    num = str(get_random_num(99))
    return_data = part1 + part2 + num
    return return_data
Ejemplo n.º 2
0
def get_doc_illustration(burl):
    ret = ''
    img_filename = str(get_random_num(9)) + 'a.png'
    file_location = burl + 'static/img/' + img_filename
    ret = '<img src="' + str(
        file_location) + '" width="100%" alt="article image">'
    return ret
Ejemplo n.º 3
0
def set_ogp(burl, ogp_type, title, desc):
    """ xxx """
    if int(ogp_type) == 1:
        return_data = '' +\
        '<meta property="og:title" content="A.I. Powered Trading Insights">'+\
        '<meta property="og:site_name" content="SmartAlpha Trade">'+\
        '<meta property="og:url" content="http://smartalphatrade.com">'+\
        '<meta property="og:description" content="SmartAlpha will help you to turn any trading portfolio into a profitable one.">'+\
        '<meta property="og:type" content="article">'+\
        '<meta property="og:image" content="'+ burl +'static/ogp.png?'+ str(get_random_num(9)) +'">'

    if int(ogp_type) == 2:
        return_data = '' +\
        '<meta property="og:title" content="'+ title +'">'+\
        '<meta property="og:site_name" content="SmartAlpha Trade">'+\
        '<meta property="og:url" content="'+ desc +'">'+\
        '<meta property="og:description" content="'+ desc +'">'+\
        '<meta property="og:type" content="article">'+\
        '<meta property="og:image" content="'+ burl +'static/img/'+ str(get_random_num(10)) +'.png?'+ str(get_random_num(9)) +'">'
    return return_data
Ejemplo n.º 4
0
def ini_portf_select(response):
    """ Initialize strategy portfolio selection """
    resp = make_response(response)
    conviction = 'neutral'
    for i in range(5):

        if get_random_num(3) == 1:
            conviction = 'neutral'
        if get_random_num(3) == 2:
            conviction = 'weak'
        if get_random_num(3) == 3:
            conviction = 'strong'

        resp.set_cookie('portf_s_' +\
                        str(i+1), '0', expires=datetime.datetime.now() +\
                        datetime.timedelta(days=1))
        resp.set_cookie('portf_s_' +\
                        str(i+1) +\
                        '_type', 'long/short', expires=datetime.datetime.now() +\
                        datetime.timedelta(days=1))
        resp.set_cookie('portf_s_' +\
                        str(i+1) + '_conv', conviction, expires=datetime.datetime.now() +\
                        datetime.timedelta(days=1))
    return resp
Ejemplo n.º 5
0
def gen_createuser_page(uid, appname, burl, name, username, password, from_ip,
                        broker, username_broker, terminal):
    """ xxx """
    return_data = ''
    if uid == '0':
        return_data = get_head(get_loading_head() +\
                               get_googleanalytics() +\
                               get_title(appname) +\
                               get_metatags(burl) +\
                               set_ogp(burl, 1, '', '') +\
                               get_bootstrap(get_sa_theme(), burl) +\
                               get_font_awesome() +\
                               get_stylesheet(burl))
        return_data = return_data +\
        get_body(get_loading_body(), navbar(burl, 0, terminal) +\
                 get_user_creation_form(burl, broker) +\
                 get_page_footer(burl, False),'')
        return_data = set_page(return_data)
    else:
        connection = pymysql.connect(host=DB_SRV,
                                     user=DB_USR,
                                     password=DB_PWD,
                                     db=DB_NAME,
                                     charset='utf8mb4',
                                     cursorclass=pymysql.cursors.DictCursor)
        cursor = connection.cursor(pymysql.cursors.SSCursor)
        sql = "SELECT username FROM users WHERE uid = '"+\
        str(uid) +"' OR username LIKE '"+\
        str(username) +"' "
        cursor.execute(sql)
        res = cursor.fetchall()
        check_exists = ''
        for row in res:
            check_exists = row[0]
        if check_exists == '':
            name = name.lower()
            nickname = set_nickname()
            date_today = datetime.datetime.now()
            date_today = date_today.strftime('%Y%m%d')
            referred_by_code = get_refer_by_code()
            avatar_id = get_random_num(19)
            email_subscription = 'ALL'
            password = get_hash_string(password)
            broker = str(broker)
            username_broker = str(username_broker)
            sql = "INSERT INTO users(uid, name, nickname, username, "+\
            "password, created_on, referred_by_code, avatar_id, "+\
            "from_ip,lang,email_subscription,broker,username_broker) "+\
            "VALUES ('"+\
            str(uid) +"','"+\
            str(name) +"','"+\
            str(nickname) +"','"+\
            str(username) +"','"+\
            str(password) +"',"+\
            str(date_today) +", '"+\
            str(referred_by_code) +"', "+\
            str(avatar_id) +", '"+\
            str(from_ip) + "', '"+\
            str(get_lang())  +"', '"+\
            str(email_subscription) +"','"+\
            str(broker)+"', '"+\
            str(username_broker) +"' )"
            cursor.execute(sql)
            connection.commit()
            return_data = set_sa_cookie(uid,
                                        set_page(
                                            get_head('<meta http-equiv="refresh" content="0;URL=' +\
                                                         burl + 'n/?step=c" />') +\
                                                         get_body('', '','')))
            send_email_notification(broker, name, username)
        else:
            return_data = 'user already exists :P !'
        cursor.close()
        connection.close()
    return return_data