Exemplo n.º 1
0
def accept_all(sa, trades=True, markets=True, others=True):
    AccountHandler.refresh_session(sa)
    confs = ConfirmationHandler.fetch_confirmations(sa)
    for i in range(len(confs)):
        if (not trades) and (confs[i].type == 2):
            del confs[i]
        if (not markets) and (confs[i].type == 3):
            del confs[i]
        if (not others) and not (confs[i].type in [2, 3]):
            del confs[i]
    if len(confs) == 0:
        return True
    return ConfirmationHandler.confirm_multi(sa, confs, 'allow')
Exemplo n.º 2
0
 def refresh_confs():
     AccountHandler.refresh_session(sa)
     info.confs = ConfirmationHandler.fetch_confirmations(sa)
     load_info()
Exemplo n.º 3
0
 def deny():
     AccountHandler.refresh_session(sa)
     if not info.confs[info.index].deny(sa):
         Common.error_popup('Failed to accept confirmation.')
     info.confs = ConfirmationHandler.fetch_confirmations(sa)
     load_info()
Exemplo n.º 4
0
def open_conf_dialog(sa):
    if not AccountHandler.refresh_session(sa):
        return
    info = Empty()
    info.index = 0
    info.confs = ConfirmationHandler.fetch_confirmations(sa)
    if len(info.confs) == 0:
        Common.error_popup('Nothing to confirm.', '  ')
        main_ui.confListButton.setText('Confirmations')
        return
    conf_dialog = QtWidgets.QDialog()
    conf_ui = PyUIs.ConfirmationDialog.Ui_Dialog()
    conf_ui.setupUi(conf_dialog)
    default_pixmap = QtGui.QPixmap(':/icons/confirmation_placeholder.png')

    def load_info():
        if len(info.confs) == 0:
            conf_dialog.hide()
            conf_dialog.close()
            conf_dialog.deleteLater()
            Common.error_popup('Nothing to confirm.', '  ')
            main_ui.confListButton.setText('Confirmations')
            return
        while True:
            try:
                conf = info.confs[info.index]
                break
            except IndexError:
                info.index -= 1
        conf_ui.titleLabel.setText(conf.description)
        conf_ui.infoLabel.setText('{0}\nTime: {1}\nID: {2}\nType: {3}'.format(
            conf.sub_description, conf.time, conf.id, conf.type_str))
        if conf.icon_url:
            pixmap = QtGui.QPixmap()
            pixmap.loadFromData(requests.get(conf.icon_url).content)
            conf_ui.iconLabel.setPixmap(pixmap)
        else:
            conf_ui.iconLabel.setPixmap(default_pixmap)
        conf_ui.backButton.setDisabled(info.index == 0)
        conf_ui.nextButton.setDisabled(info.index == (len(info.confs) - 1))

    def accept():
        AccountHandler.refresh_session(sa)
        if not info.confs[info.index].accept(sa):
            Common.error_popup('Failed to accept confirmation.')
        info.confs = ConfirmationHandler.fetch_confirmations(sa)
        load_info()

    def deny():
        AccountHandler.refresh_session(sa)
        if not info.confs[info.index].deny(sa):
            Common.error_popup('Failed to accept confirmation.')
        info.confs = ConfirmationHandler.fetch_confirmations(sa)
        load_info()

    def refresh_confs():
        AccountHandler.refresh_session(sa)
        info.confs = ConfirmationHandler.fetch_confirmations(sa)
        load_info()

    load_info()
    conf_ui.refreshButton.clicked.connect(refresh_confs)
    conf_ui.nextButton.clicked.connect(lambda: (setattr(
        info, 'index', ((info.index + 1) if info.index <
                        (len(info.confs) - 1) else info.index)), load_info()))
    conf_ui.backButton.clicked.connect(
        lambda: (setattr(info, 'index', (
            (info.index - 1) if info.index > 0 else info.index)), load_info()))
    conf_ui.acceptButton.clicked.connect(accept)
    conf_ui.denyButton.clicked.connect(deny)
    conf_dialog.exec_()