Example #1
0
def list_get_rec_html(wr, fa, odd):
    #w_cat = locz.get(db.w_cats, db.w_cats[wr.w_cat_id], lang)
    wr_loc = locz.get(db.wagers, wr, lang)

    cash = db.cash[wr.cash_id]
    cash_i = SPAN(
        IMG(_src=URL('static', 'images/cash/' + cash.img_name),
            _width=30,
            _alt=''),
        #' ', SPAN(cash.name, _class='small'),
    )
    ## w_cat.name,': ',
    run_dt = wr.status == 'PAY' and wr.run_dt
    if run_dt:
        import datetime
        name = CAT(SPAN(run_dt.date(), _class='inv'), ' ', wr_loc.name)
    else:
        name = wr_loc.name

    h = DIV(
        DIV(A(XML('<i class="fa fa-%s"></i> ' % fa),
              name,
              _href=URL('hand', 'make', args=[wr.id])),
            _class='col-sm-8'),
        #DIV(wr.status, _class ='col-sm-1'),
        #DIV(cash_i, _class ='col-sm-3'),
        #DIV(cash_i, _class ='col-sm-3'),
        DIV(cash_i, round(float(wr.total), 6), _class='col-sm-2'),
        DIV(A(wr.man_name,
              _href=URL('man', 'index', args=[wr.man_id]),
              _class='small'),
            _class='col-sm-2'),
        _class='row' + (odd and ' odd' or ''))
    return h
Example #2
0
def index():
    response.title = ''
    h = CAT()
    h += DIV(u(T('Make new WAGER'), URL('hand', 'make')),
             u(T('Quick Make Simple WAGER'),
               URL('hand', 'make', vars={'quick': 1})),
             u(T('See WAGERs List'), URL('hand', 'list')),
             _class='row')

    h += BR()
    h += H3(T('You may to bet on Wagers now'),
            ':',
            show_id_btn(1),
            _class='inv_lgrn')
    # сбросим фильтр поиска
    session.wlist_flt = None
    h, _ = list_get_pay(h, None, {}, lang_curr)

    h += H3(T('Last messages'))
    for r in db(db.wager_chat).select(orderby=~db.wager_chat.created_on,
                                      limitby=(0, 20)):
        wager = db.wagers[r.wager_id]
        wr_loc = locz.get(db.wagers, wager, lang_curr)
        user = r.man_id and db.men[r.man_id]
        if r.name or r.mess:
            wr_name = wr_loc.name
            # тут по 2 байта на UTF
            #if len(wr_name)>60: wr_name = wr_name[:55] + '...'
            title = r.name or ''
            #if len(title)>20: title = title[:17] + '...'
            h += DIV(DIV(DIV(
                SPAN(r.created_on, _style='font-size:medium;'),
                ' ',
                user
                and A(B(user.name), _href=URL('man', 'index', args=[user.id]))
                or T('anonim'),
                ': ',
                B(title),
                ' ',
                r.mess or '',
                _class='col-sm-12'),
                         _class='row unv'),
                     DIV(DIV(A(TAG.i(_class='fa fa-eye',
                                     _style='font-size:x-large'),
                               _href=URL('hand', 'make', args=[wager.id]),
                               _class='btn1'),
                             ' ',
                             SPAN(wr_name, _class='una'),
                             _class='col-sm-12'),
                         _class='row'),
                     _style='padding-bottom:10px;',
                     _class='row')

    return dict(h=DIV(h, _class='inv'))
Example #3
0
def show_wager():
    wager_id = request.args(0)
    wager = wager_id and db.wagers[wager_id]

    h = CAT(
        SCRIPT("""
            if ( ! $('#show_wager').is(':visible')) {
                $('#show_wager').animate({ height: 'show' }, 1000);
            }
            """))

    if not wager:
        h += wager_id and T('Wager [%s] not found') % wager_id or ''
        return h

    status = wager.status
    if wager.run_dt and status in ['NEW', 'PAY']:
        h += DIV(T('Auto run on'), ': ', SPAN(wager.run_dt, _class='inv'))
    #lang = session.lang or request.env.http_accept_language
    #print lang
    w_cat = locz.get(db.w_cats, db.w_cats[wager.w_cat_id], lang_curr)
    wr_loc = locz.get(db.wagers, wager, lang_curr)
    wl_name = wr_loc.name
    ## тут это не работает так как это по аяксу
    ## response.meta_title = wl_name
    h_name = DIV(
        H3(
            wl_name,
            _itemprop='name',  # название события длля микроразметки поисковиков
            _class='ask'),
        _class='col-sm-9')
    h_descr = wr_loc.descr and DIV(
        XML(wr_loc.descr),
        _itemprop='description',  # микроразметка для поисковиков и социалки
        _class='row') or ''
    s_url = URL('hand', 'make', args=[wager_id], scheme=True, host=True)
    title, descr = get_title_descr(wr_loc)
    twit = 'http://twitter.com/home?status=' + title + '%20' + s_url
    facebook = 'http://www.facebook.com/sharer.php?u=' + s_url
    gplus = 'https://plus.google.com/share?url=' + s_url
    h_social = DIV(A(IMG(_src=URL('static', 'images/twitter.png'),
                         _alt="Share on Twitter",
                         _width="32",
                         _height="32",
                         _style='margin: 2px 5px;'),
                     _target='_blabk',
                     _href=twit,
                     _id="twit",
                     _title="Share on twitter"),
                   A(IMG(_src=URL('static', 'images/facebook.png'),
                         _alt="Share on facebook",
                         _width="32",
                         _height="32",
                         _style='margin: 2px 5px;'),
                     _target='_blabk',
                     _href=facebook,
                     _id="facebook",
                     _title="Share on facebook"),
                   A(IMG(_src=URL('static', 'images/gplus-32.png'),
                         _alt="Share on Google Plus",
                         _width="32",
                         _height="32",
                         _style='margin: 2px 5px;'),
                     _target='_blabk',
                     _href=gplus,
                     _id="twit",
                     _title="Share on Google Plus"),
                   _class='pull-right')

    if wager.man_id == session.man_id:
        h_man = DIV(P(T('Your is maker'), _class='header'),
                    h_social,
                    _class='col-sm-2 pull-right')
        h += DIV(h_name, h_man, _class='row')
        h += h_descr
    else:
        # это не хозяин спора - запретиа все редактирования
        man = db.men[wager.man_id]

        h_man = DIV(P(A(man.name,
                        _href=URL('man', 'index', args=[wager.man_id])),
                      _class='header'),
                    P(fa_icons('fa-heart green', man.trust), _class='header'),
                    h_social,
                    _class='col-sm-3 pull-right')
        h += DIV(h_name, h_man, _class='row')
        h += h_descr
        return h

    conds = db(db.wager_conds.wager_id == wager_id).select()
    conds_cnt = len(conds)
    if conds_cnt < 2:
        # позволим открыть кнопку только когда добавлено 2-е условие
        session.wager_new = True
    else:

        # только когда 2 условия готовы
        go_btn = status == 'NEW' and 'Go to PAY' or status == 'PAY' and 'Go to RUN' or status == 'RUN' and 'Go to END'
        go_lbl = status == 'NEW' and 'If all conditions is setted click' or status == 'PAY' and 'If all Bets is made click' or status == 'RUN' and 'If the winners decided, select them and press'
        if status == 'PAY' and wager.total <= 0:
            go_btn = None
            h += DIV(T('Wager can not be runned - bet total is null!'))
        if go_btn:
            form_go = FORM(T(go_lbl),
                           ': ',
                           BUTTON(B(T(go_btn)),
                                  _type='submit',
                                  _class='btn-' + CLRS.btn),
                           formname='form_go',
                           _id='form_go')
            h += BR()
            h += DIV(DIV(form_go, _class='col-sm-12'), _class='row')

            if wager.man_id != session.man_id:
                return h  # дополнительная защита - если кто вручную форму создал
            if form_go.accepts(request, formname='form_go'):
                if status == 'NEW':
                    status = 'PAY'
                elif status == 'PAY':
                    ## запускаем на сервисе
                    ## выдаст ошибку или False при успехе
                    mess = ws.lite_wager_go(wager, LITEcash) or T(
                        'Wager was closed for payments and awaiting resolve now'
                    )
                    response.flash = '%s' % mess
                    status = 'RUN'
                elif status == 'RUN':
                    # тут должны быть заданы победители
                    winned = request.vars.winned  ## в форме нету их - из реквайст только
                    if winned and winned.isdigit():
                        if type(winned) != type([]): winned = [winned]
                        res = lite_wager_end(wager, winned)
                        err = res.get('error')
                        if err:
                            response.flash = err
                            return h

                        for w in winned:
                            db.wager_conds[w].update_record(winned=True)
                        response.flash = res
                        status = 'END'
                    else:
                        response.flash = T('Winned conditions not selected!')
                        return h
                wager.update_record(status=status)
                response.js = "$('#show_wager').hide();"
                response.js += "$('#show_conds').hide();"
                response.js += "jQuery('#show_wager').get(0).reload();"
                response.js += "jQuery('#show_conds').get(0).reload();"
                return  # не нужно ничего возвращатьтак как перегрузка все равно начнктся

    return h
Example #4
0
def show_conds():

    wager_id = request.args(0)
    wager = wager_id and db.wagers[wager_id]
    if not wager: return ''

    h = CAT(
        SCRIPT("""
            if ( ! $('#show_conds').is(':visible')) {
                $('#show_conds').animate({ height: 'show' }, 1000);
            }
            """))

    status = wager.status
    h += DIV(DIV(T('List of Conditions for'),
                 ' ',
                 A(T('WAGER #%s') % wager_id,
                   _href=URL('hand', 'make', args=[wager_id]),
                   _class='btn btn-' + CLRS.btn),
                 ' ',
                 T('status'),
                 ' [',
                 fa_status(status, 1),
                 status,
                 ']',
                 _class='col-sm-8'),
             DIV(P(A(T('Other Wagers'),
                     _href=URL('hand', 'list'),
                     _class='btn btn-' + CLRS.btn),
                   _class='pull-right'),
                 _class='col-sm-4'),
             _class='row')
    if status == 'PAY':
        h += DIV(P(
            T('ATTENTION!!! You must to pay only from your addresses and local wallets! Online wallets and accounts of exchanges are not supported.'
              )),
                 _class='row')

    h_reload = SPAN(
        A(
            TAG.i(_class='fa fa-refresh bbig'),  # fa-spin
            _onclick="""
                $(this).addClass('fa-spin');
                jQuery('#show_wager').get(0).reload();
                jQuery('#show_conds').get(0).reload();
                            """,
            _class='btn circ btn-' + CLRS.btn2),
        _class='pull-right')
    if status == 'NEW':
        hh = (DIV(P(B(T('Name')), _class='header'), _class='col-sm-4'))
    elif status == 'PAY':
        hh = (DIV(P(B(T('Click to make a BET')), _class='header'),
                  _class='col-sm-7'),
              DIV(P(B(T('Total Bet')), _class='header'), _class='col-sm-3'),
              DIV(h_reload, T('Win Ratio'), _class='col-sm-2'))
    elif status == 'RUN':
        # загрузим стили для кнопок
        ## тут не пашет response.files.append(URL('static','css/chechbox.css'))
        hh = (DIV(P(B(T('Winned')), _class='header'), _class='col-sm-1'),
              DIV(P(B(T('Name')), _class='header'), _class='col-sm-6'),
              DIV(P(B(T('Total Bet')), _class='header'), _class='col-sm-3'),
              DIV(h_reload, T('Win Ratio'), _class='col-sm-2'))
    else:
        hh = (DIV(P(B(T('Name')), _class='header'),
                  _class='col-sm-4'), DIV(B(T('Stats')), _class='col-sm-4'),
              DIV(B(T('Payed')), _class='col-sm-3'))
    hh = DIV(CAT(hh), _class='row')

    conds_payed = []
    for cond in db(db.wager_conds.wager_id == wager_id).select():
        wcond_loc = locz.get(db.wager_conds, cond, lang_curr)

        if status == 'NEW':
            hh += DIV(DIV(wcond_loc.name, _class='col-sm-5'),
                      DIV(wcond_loc.name, _class='col-sm-2'),
                      _class='row')
        elif status == 'PAY':
            bill_id = cond.bill_id
            ratio = (not cond.total or not wager.total) and 100 or float(
                wager.total / cond.total)
            if ratio > 100: ratio = int(ratio)
            elif ratio > 10: ratio = round(ratio, 1)
            else: ratio = round(ratio, 2)
            if bill_id:
                aa = A(wcond_loc.name,
                       _href=LITEcash.url + LITEcash.show % bill_id,
                       _target='_blank',
                       _class='col-sm-11 btn_a pay_btn inv')
                conds_payed.append(cond.total)
            else:
                aa = A(wcond_loc.name,
                       _href=URL('hand', 'make_bill', args=[cond.id]),
                       _target='_blank',
                       _class='col-sm-11 btn_a pay_btn inv')
            hh += DIV(DIV(aa, _class='col-sm-7'),
                      DIV(H3(cond.total), _class='col-sm-3'),
                      DIV(H3('x', ratio), _class='col-sm-2'),
                      _class='row')
        elif status == 'RUN':
            ratio = (not cond.total or not wager.total) and 100 or float(
                wager.total / cond.total)
            if ratio > 100: ratio = int(ratio)
            elif ratio > 10: ratio = round(ratio, 1)
            else: ratio = round(ratio, 2)
            hh += DIV(
                DIV(DIV(INPUT(_type='checkbox',
                              _id=cond.id,
                              _name='winned',
                              _value=cond.id,
                              _form='form_go'),
                        LABEL(_for=cond.id),
                        _class='squaredOne pull-right'),
                    _class='col-sm-1'),
                DIV(wcond_loc.name, _class='col-sm-6'),
                DIV(cond.total,
                    cond.bill_id
                    and A(TAG.i(_class='fa fa-info-circle bbig'),
                          _href=LITEcash.url + LITEcash.info % cond.bill_id,
                          _target='_blank') or '',
                    _class='col-sm-3'),
                DIV(H3('x', ratio), _class='col-sm-2'),
                _class='row')
        else:
            hh += DIV(
                DIV(wcond_loc.name, _class='col-sm-6'),
                DIV(cond.winned and B(T('Winner!')) or '',
                    _class='win col-sm-2'),
                DIV(
                    cond.total,
                    cond.bill_id
                    and A(TAG.i(_class='fa fa-info-circle bbig'),
                          _href=LITEcash.url + LITEcash.info % cond.bill_id,
                          _target='_blank') or '',
                    #_href=URL('api_bill', 'info', host=LITEcash.url,
                    #    args=[cond.bill_id], vars={'get_payouts':1}), _target='_blank') or '',
                    _class='col-sm-4'),
                _class='row')

    h += DIV(hh, _class='game_stats row')

    # только для хозяина разрешим это
    if status == 'NEW' and session.man_id == wager.man_id:
        h += add_cond(wager_id)
    ##elif status == 'NEW' and len(conds_payed)<2

    return h
Example #5
0
def make():
    response.title = None
    wager_id = request.args(0)
    if wager_id:
        if not wager_id.isdigit():
            #return response.stream('x' * 3333)
            return response.stream(Jammer(), 40000)
    else:
        cond_id = request.vars.cond
        if cond_id and cond_id.isdigit():
            if cond_id.startswith('up_'):
                redirect(URL('man', 'meet'))
            if not cond_id.isdigit():
                #return response.stream('x' * 3333)
                return response.stream(Jammer(), 40000)
            cond = db.wager_conds[cond_id]
            wager_id = cond and cond.wager_id

    session.wager_id = wager_id
    wager = wager_id and db.wagers[wager_id]

    if wager and (wager.status == 'PAY' or wager.status == 'RUN'):
        # загрузим стили для кнопок здесь - в LOAD не пашет это
        response.files.append(URL('static', 'css/chechbox.css'))

    h = CAT()

    if session.man_id:
        # можно менять валюту
        response.menu.append(cash_sel())  # in menu model

        cash_id = session.cash_id
        cash = db.cash[cash_id]
        cash_i = CAT(
            cash.system_name, ' ',
            IMG(_src=URL('static', 'images/cash/' + cash.img_name),
                _width=30,
                _alt=''))

        if wager:
            # зазадим титл страницы для социальных сетей
            wr_loc = locz.get(db.wagers, wager, lang_curr)
            ###<!-- all META included in web2py_ajax.html -->
            title, descr = get_title_descr(wr_loc)
            response.meta_title = response.meta.title = title
            response.meta.description = descr
            itemprop_name = title
            # <script type="application/ld+json">
            response.ld_json = '''
                {
                "@context": "http://schema.org/Event",
                "@type": "Article",
                "name": "%s",
                "description"; "%s"
                }
                ''' % (title, descr or '')
        else:
            quick = request.vars.quick
            if quick:
                form = form_quick_make(response, session, cash_i)
                import datetime
                request.vars.run_dt = datetime.datetime.now(
                ) + datetime.timedelta(1)
            else:
                form = form_full_make(response, session, cash_i)

            quick_btn = request.vars.quick_btn
            if form.accepts(request,
                            session,
                            keepvalues=True,
                            formname='make_wager'):
                print 'form.vars', form.vars
                session.wager_name = '%s' % form.vars.wager_name
                print 'session.wager_name', session.wager_name
                #return
                session.def_bet = form.vars.def_bet
                session.w_cat_id = form.vars.w_cat_id
                session.w_cat = form.vars.w_cat
                # сначала созддадим у нас
                cash = db.cash[session.cash_id]
                if cash.used:
                    wager_id = insert_wager(request, session, quick_btn)
                    if wager_id:
                        # теперь внесем в ЛАЙТ
                        wager = db.wagers[wager_id]
                        mess = make_lt_wager(wager, cash,
                                             db.men[session.man_id])
                        if mess:
                            # ошибка - покажем
                            response.flash = mess
                        else:
                            redirect(URL('hand', 'make', args=[wager_id]))
                    else:
                        response.flash = T('Number wrong')
                else:
                    response.flash = T(
                        'That currency %s not used now. Select Bitcoin please'
                    ) % cash.name

            h += form
            h += DIV(_id='make_wager')
    elif not wager:
        h += DIV(XML(
            T('You can not make a wagers, %s or %s first!') %
            (A(T('to Meet'), _href=URL(
                'man', 'meet')), A(T('to Greet'), _href=URL('man', 'greet')))),
                 _class='row')

    if wager:
        times = 'infinity'  # если огранисить то перезагрузка будет ограничена данное число раз по reload
    else:
        times = wager_id and 2 or 1  # если = 1 - то нначальной загрузки нету а только через 20сек загрузит

    h += LOAD(
        'hand',
        'show_wager',
        args=wager_id
        and [wager_id],  # иначе передеает строковое значение "None'
        ajax=True,
        times=times,
        timeout=9999999,  #settings.UPD_TIMEOUT,
        target='show_wager',  # вместо _id
        _style='display:none; height:0%;',
        _class='',  #  ### !!!! обязательно нужен - иначе анимация сбивается!
    )
    #h += BR()
    h += LOAD(
        'hand',
        'show_conds',
        args=wager_id and [wager_id],
        ajax=True,
        times=times,
        timeout=9999999,  #settings.UPD_TIMEOUT,
        target='show_conds',  # вместо _id
        _style='display:none; height:0%; margin-top:20px;',
        _class='',  #  ### !!!! обязательно нужен - иначе анимация сбивается!
    )
    if wager and wager.status != 'NEW':
        h += show_chat_add(wager_id)
        h += LOAD(
            'hand',
            'show_chat',
            args=wager_id and [wager_id],
            ajax=True,
            times='infinity',
            timeout=111111,  #settings.UPD_TIMEOUT,
            target='show_chat',  # вместо _id
            #_style='display:none; height:0%; margin-top:20px;',
            _class='',  #  ### !!!! обязательно нужен - иначе анимация сбивается!
        )

    return dict(h=DIV(
        h, _itemscope='', _itemtype='http://schema.org/Evant', _class='row'))
Example #6
0
def locz():
    import locz
    rec = db.wagers[request.args(1) or 1]
    rec_locz = locz.get(db.wagers, rec, request.args(0))
    return rec_locz.name