Exemplo n.º 1
0
class GroupViewWidget(QDialog, FWidget):

    def __init__(self, table_group, parent, *args, **kwargs):
        QDialog.__init__(self, parent, *args, **kwargs)

        vbox = QVBoxLayout()
        vbox.addWidget(FBoxTitle(u"Ajout d'un nouveau groupe"))
        self.parent = table_group

        self.name = LineEdit()
        formbox = QGridLayout()

        self.error_field = FLabel(u"")
        formbox.addWidget(self.error_field, 0, 1)
        formbox.addWidget(FLabel(u"Nom"), 1, 0)
        formbox.addWidget(self.name, 1, 1)
        butt = Button(u"Enregistrer")
        butt.clicked.connect(self.edit_prod)
        cancel_but = Button(u"Annuler")
        cancel_but.clicked.connect(self.cancel)
        formbox.addWidget(butt, 2, 1)
        formbox.addWidget(cancel_but, 2, 0)

        formbox.setColumnStretch(3, 3)
        formbox.setRowStretch(2, 2)
        vbox.addLayout(formbox)
        self.setLayout(vbox)

    def cancel(self):
        self.close()

    def isvalid(self):
        if unicode(self.name.text()) == "":
            return False

    def edit_prod(self):
        self.error_field.setStyleSheet("")
        name = unicode(self.name.text())
        if name == "":
            self.error_field.setStyleSheet("font-size:20px; color: red")
            self.error_field.setText(u"Ce champ est obligatoire.")
            return False

        group = Group()
        try:
            group.name = name
            group.save()
            self.cancel()
            self.parent.table_group.refresh_()
        except sqlite3.IntegrityError:
            self.error_field.setStyleSheet("font-size:20px; color: red")
            self.error_field.setText(u"%s existe déjà" % name)
Exemplo n.º 2
0
class GroupViewWidget(QDialog, FWidget):
    def __init__(self, table_group, parent, *args, **kwargs):
        QDialog.__init__(self, parent, *args, **kwargs)

        vbox = QVBoxLayout()
        vbox.addWidget(FBoxTitle(u"Ajout d'un nouveau groupe"))
        self.parent = table_group

        self.name = LineEdit()
        formbox = QGridLayout()

        self.error_field = FLabel(u"")
        formbox.addWidget(self.error_field, 0, 1)
        formbox.addWidget(FLabel(u"Nom"), 1, 0)
        formbox.addWidget(self.name, 1, 1)
        butt = Button(u"Enregistrer")
        butt.clicked.connect(self.edit_prod)
        cancel_but = Button(u"Annuler")
        cancel_but.clicked.connect(self.cancel)
        formbox.addWidget(butt, 2, 1)
        formbox.addWidget(cancel_but, 2, 0)

        formbox.setColumnStretch(3, 3)
        formbox.setRowStretch(2, 2)
        vbox.addLayout(formbox)
        self.setLayout(vbox)

    def cancel(self):
        self.close()

    def isvalid(self):
        if unicode(self.name.text()) == "":
            return False

    def edit_prod(self):
        self.error_field.setStyleSheet("")
        name = unicode(self.name.text())
        if name == "":
            self.error_field.setStyleSheet("font-size:20px; color: red")
            self.error_field.setText(u"Ce champ est obligatoire.")
            return False

        group = Group()
        try:
            group.name = name
            group.save()
            self.cancel()
            self.parent.table_group.refresh_()
        except sqlite3.IntegrityError:
            self.error_field.setStyleSheet("font-size:20px; color: red")
            self.error_field.setText(u"%s existe déjà" % name)
Exemplo n.º 3
0
class InfoTableWidget(FWidget):

    def __init__(self, parent, *args, **kwargs):
        super(FWidget, self).__init__(parent=parent, *args, **kwargs)

        self.parent = parent

        self.refresh()

        self.details = FLabel()
        self.edit_ow_but = Button(u"Mettre à jour")
        self.edit_ow_but.setIcon(QIcon.fromTheme('document-new',
                                                 QIcon(u"{}edit_user.png".format(Config.img_cmedia))))
        self.edit_ow_but.setEnabled(False)
        self.edit_ow_but.clicked.connect(self.edit_owner)

        self.formbox = QGridLayout()
        self.formbox.addWidget(self.details, 0, 0)
        self.formbox.addWidget(self.edit_ow_but, 0, 1)
        # self.formbox.ColumnStretch(4, 2)
        # self.formbox.RowStretch(6, 2)
        vbox = QVBoxLayout()
        vbox.addLayout(self.formbox)
        self.setLayout(vbox)

    def refresh_(self, owner):
        self.refresh()
        self.owner = owner

        if isinstance(self.owner, int):
            return
        self.details.setText(
            """<h2>Nom:  {username}</h2>
                <h4><b>Active:</b> {isactive}</h4>
                <h4><b>Numéro tel:</b> {phone}</h4>
                <h4><b>Dernière login:</b> {last_login}</h4>
                <h4><b>Nombre de connexion:</b> {login_count}</h4>
                <h4><b>Groupe:</b> {group}</h4>
            """.format(group=self.owner.group,
                       login_count=self.owner.login_count,
                       last_login=self.owner.last_login.strftime(u"%c"),
                       phone=self.owner.phone,
                       isactive=self.owner.isactive,
                       username=self.owner.username))

    def edit_owner(self):
        self.parent.parent.open_dialog(NewOrEditUserViewWidget, owner=self.owner,
                                       modal=True, pp=self.parent.table_info)
Exemplo n.º 4
0
class HomeViewWidget(FWidget):
    """ Shows the home page  """
    def __init__(self, parent=0, *args, **kwargs):
        super(HomeViewWidget, self).__init__(parent=parent, *args, **kwargs)

        self.parent = parent

        self.parentWidget().setWindowTitle(u"Bienvenu sur transfert Wari")
        self.title = FPageTitle(u"Tranfert")
        vbox = QVBoxLayout(self)
        vbox.addWidget(self.title)
        self.sttg = SettingsAdmin().select().where(SettingsAdmin.id == 1).get()
        if self.sttg.can_use:
            self.createHomeGroupBox()
            vbox.addWidget(self.homegbox)
        else:
            self.activationGroupBox()
            vbox.addWidget(self.topLeftGroupBoxBtt)
        self.setLayout(vbox)

    def createHomeGroupBox(self):
        self.homegbox = QGroupBox()

        self.table = OperationTableWidget(parent=self)
        table_box = QVBoxLayout()
        self.title_table = FPageTitle(u"Historique des transferts")
        table_box.addWidget(self.title_table)
        table_box.addWidget(self.table)

        # form transfer
        self.number = LineEdit()
        self.number.setInputMask("D9.99.99.99")
        self.number.setAlignment(Qt.AlignCenter)
        self.number.setFont(QFont("Arial", 17))
        self.number.setToolTip(u"""Taper le nom ou le numéro de téléphone du
                                beneficiare""")
        self.amount = LineEdit()
        self.amount.setFont(QFont("Arial", 15))
        self.amount.setValidator(QIntValidator())
        self.amount.setToolTip(u"Taper le montant du transfert")
        self.password_field = EnterTabbedLineEdit()
        self.password_field.setFont(QFont("Arial", 15))
        self.password_field.setEchoMode(LineEdit.Password)
        self.password_field.setToolTip(u"Taper le code orange money")
        self.msg_field = FLabel("")
        butt = Button(u"Envoyer")
        butt.clicked.connect(self.get_or_creat_nbr)

        formbox = QGridLayout()
        formbox.addWidget(FLabel(u"Numéro"), 0, 0)
        formbox.addWidget(self.number, 1, 0)
        formbox.addWidget(FLabel(u"Montant"), 0, 1)
        formbox.addWidget(self.amount, 1, 1)
        formbox.addWidget(FLabel(u"code"), 0, 2)
        formbox.addWidget(self.password_field, 1, 2)
        formbox.addWidget(self.msg_field, 0, 5)
        formbox.addWidget(butt, 1, 4)
        formbox.setColumnStretch(5, 3)

        transfer_box = QVBoxLayout()
        # formbox.setSizeConstraint(QLayout.SetFixedSize)
        transfer_box.addWidget(self.title)
        transfer_box.addLayout(formbox)
        transfer_box.addLayout(table_box)
        # self.setLayout(transfer_box)
        self.homegbox.setLayout(transfer_box)

    def activationGroupBox(self):
        self.topLeftGroupBoxBtt = QGroupBox(self.tr("Nouvelle license"))
        self.setWindowTitle(u"License")
        self.parentWidget().setWindowTitle(u"Activation de la license")

        self.code_field = PyTextViewer(
            u"""Vous avez besoin du code ci desous
                                           pour l'activation:<hr> <b>{code}</b><hr>
                                           <h4>Contacts:</h4>{contact}""".
            format(code=SettingsAdmin().select().get().clean_mac,
                   contact=Constants.TEL_AUT))
        self.name_field = LineEdit()
        self.license_field = QTextEdit()
        self.pixmap = QPixmap("")
        self.image = FLabel(self)
        self.image.setPixmap(self.pixmap)

        butt = Button_save(u"Enregistrer")
        butt.clicked.connect(self.add_lience)

        editbox = QGridLayout()
        editbox.addWidget(FLabel(u"Nom: "), 0, 0)
        editbox.addWidget(self.name_field, 0, 1)
        editbox.addWidget(FLabel(u"License: "), 1, 0)
        editbox.addWidget(self.license_field, 1, 1)
        editbox.addWidget(self.code_field, 1, 2)
        editbox.addWidget(self.image, 5, 1)
        editbox.addWidget(butt, 6, 1)

        self.topLeftGroupBoxBtt.setLayout(editbox)

    def get_or_creat_nbr(self):
        ''' add operation '''

        if not self.is_complete():
            return

        number = unicode(self.number.text().replace('.', ''))
        amount = unicode(self.amount.text())
        Contact.get_or_create(number)

        data = {
            "phone_num": [
                number,
            ],
            "amount": amount,
            "code": unicode(self.password_field.text())
        }
        # print(data)
        # multiple_sender(data)
        self.number.clear()
        self.amount.clear()
        self.password_field.clear()
        self.table.refresh_()
        self.msg_field.setText(
            u"Transfert  vers ({}) a été effectué.".format(number))
        self.msg_field.setStyleSheet("color: green")

    def is_complete(self):
        self.amount.setStyleSheet("")
        self.password_field.setStyleSheet("")
        if unicode(self.amount.text()) == "":
            self.amount.setStyleSheet("font-size:20px; color: red")
            self.amount.setText(u"Ce champ est obligatoire.")
            return False
        if unicode(self.password_field.text()) == "":
            self.password_field.setStyleSheet("font-size:20px; color: red")
            self.password_field.setText(u"Ce champ est obligatoire.")
            return False
        return True

    def check_license(self, license):

        self.flog = False

        if (SettingsAdmin().is_valide_mac(license)):
            self.pixmap = QPixmap(u"{}accept.png".format(Constants.img_cmedia))
            self.image.setToolTip("License correct")
            self.flog = True
        else:
            self.pixmap = QPixmap(u"{}decline.png".format(
                Constants.img_cmedia))
            self.image.setToolTip("License incorrect")
        self.image.setPixmap(self.pixmap)

    def add_lience(self):
        """ add User """
        name = unicode(self.name_field.text()).strip()
        license = unicode(self.license_field.toPlainText())
        self.check_license(license)

        if self.flog:
            sttg = self.sttg
            sttg.user = name
            sttg.license = license
            sttg.save()
            raise_success(
                u"Confirmation",
                u"""La license (<b>{}</b>) à éte bien enregistré pour cette
                           machine.\n
                           Elle doit être bien gardé""".format(license))
            self.goto_archi()
Exemplo n.º 5
0
class ContactNewViewWidget(QDialog, FWidget):

    def __init__(self, parent, *args, **kwargs):
        QDialog.__init__(self, parent, *args, **kwargs)

        vbox = QVBoxLayout()
        vbox.addWidget(FBoxTitle(u"<h3>Ajout de contact </h3>"))
        self.combo_grp = QComboBox()
        groups = Group()
        groups.name = "Aucun"

        self.list_grp = Group.all()
        self.list_grp.append(groups)
        self.list_grp.reverse()

        for index in self.list_grp:
            sentence = u"%(name)s" % {'name': index.name}
            self.combo_grp.addItem(sentence)

        self.full_name = LineEdit()
        self.msg_e_or_c = FLabel("")
        self.full_name.setFont(QFont("Arial", 16))
        self.phone_number = IntLineEdit()
        self.phone_number.setInputMask("D9.99.99.99")
        self.phone_number.setAlignment(Qt.AlignCenter)
        self.phone_number.setFont(QFont("Arial", 16))

        send_butt = Button(u"Enregistrer")
        send_butt.clicked.connect(self.save_form)
        cancel_but = Button(u"Fermer")
        cancel_but.clicked.connect(self.cancel)

        formbox = QGridLayout()
        formbox.addWidget(FLabel(u"Groupes:"), 0, 0)
        formbox.addWidget(self.combo_grp, 1, 0)
        formbox.addWidget(FLabel(u"Nom complèt: "), 0, 1)
        formbox.addWidget(self.full_name, 1, 1)
        formbox.addWidget(FLabel(u"Numéro: "), 0, 2)
        formbox.addWidget(self.phone_number, 1, 2)
        formbox.addWidget(send_butt, 2, 1)
        formbox.addWidget(cancel_but, 2, 0)
        formbox.addWidget(self.msg_e_or_c, 3, 0, 3, 2)

        vbox.addLayout(formbox)
        self.setLayout(vbox)

    def cancel(self):
        self.close()

    def iscomplet(self):
        self.phone_number.setStyleSheet("")
        self.msg_e_or_c.setText("")
        self.msg_e_or_c.setStyleSheet("")

        try:
            int(self.phone_number.text().replace('.', ''))
        except:
            self.phone_number.setStyleSheet("border-bottom: 3px solid red;"
                                            "background-color:#AFAFAF;")
            self.phone_number.setToolTip(u"Ce champ est obligatoire.")
            return False
        return True

    def save_form(self):

        if not self.iscomplet():
            return
        full_name = unicode(self.full_name.text())
        phone_number = int(self.phone_number.text().replace('.', ''))
        try:
            Contact(number=phone_number, name=full_name).save()
        except:
            self.msg_e_or_c.setText(u"Ce numéro existe déjà")
            self.msg_e_or_c.setStyleSheet("color: red")
            return

        grp = unicode(self.list_grp[self.combo_grp.currentIndex()])

        if not grp == "Aucun":
            grp = Group.select().where(Group.name == grp).get()
            contact = Contact.select().where(Contact.number == phone_number).get()
            ContactGroup(group=grp.id, contact=contact).save()
        self.full_name.setText("")
        self.phone_number.setText("")
        self.msg_e_or_c.setText(u"Le numéro (<b>{}</b>) à éte bien enregistré"
                                .format(phone_number))
Exemplo n.º 6
0
class InfoTableWidget(FWidget):

    def __init__(self, parent, *args, **kwargs):
        super(FWidget, self).__init__(parent=parent, *args, **kwargs)

        self.parent = parent

        self.refresh()
        self.info_box = FLabel(" ")
        self.image = FLabel(" ")
        self.image_btt = BttSmall("Zoom")
        self.image_btt.setFlat(True)
        self.image_btt.clicked.connect(self.show_image)

        hbox = QHBoxLayout()
        gridbox = QGridLayout()
        gridbox.addWidget(self.info_box, 0, 0)
        gridbox.addWidget(self.image, 1, 0)
        gridbox.addWidget(self.image_btt, 1, 1)
        hbox.addLayout(gridbox)
        self.setLayout(hbox)

    def refresh_(self, idd):

        self.prod = Product.get(id=idd)
        rest_by_store = ""

        for store in Store.select():
            remaining, nbr_parts = store.get_remaining_and_nb_parts(self.prod)

            if remaining < 10:
                color_style = 'color: DarkGreen'
            if remaining <= 5:
                color_style = 'color: LightCoral'
            if remaining <= 2:
                color_style = 'color: red; text-decoration: blink'
            if remaining >= 10:
                color_style = 'color: LimeGreen;'
            color_style = color_style + \
                "; border:3px solid green; font-size: 15px"

            rest_by_store += """<li> {store}: <strong style='{color_style}'>
                {remaining} </strong> <i>carton</i> ({nbr_parts} <i>pièces</i>)
                </li>""".format(store=store.name, color_style=color_style,
                                remaining=remaining,
                                nbr_parts=nbr_parts * remaining)
        width = height = 50
        if self.prod.image_link:
            width = 200
            height = 100

        self.info_box.setText(u"""<h2>{name}</h2>
            <h4>Quantité restante:</h4>
            <ul>{remaining}</ul>
            """.format(name=self.prod.name,
                       remaining=rest_by_store))
        self.image.setText("""<img src="{image}" width='{width}'
            height='{height}'>""".format(image=self.prod.image_link,
                                         width=width, height=height))

    def show_image(self):
        """ afficher l'image complete dans une autre fenetre"""
        from GCommon.ui.show_image import ShowImageViewWidget
        try:
            self.parent.open_dialog(
                ShowImageViewWidget, modal=False, prod=self.prod)
        except AttributeError:
            pass
Exemplo n.º 7
0
class ContactNewViewWidget(QDialog, FWidget):
    def __init__(self, parent, *args, **kwargs):
        QDialog.__init__(self, parent, *args, **kwargs)

        vbox = QVBoxLayout()
        vbox.addWidget(FBoxTitle(u"<h3>Ajout de contact </h3>"))
        self.combo_grp = QComboBox()
        groups = Group()
        groups.name = "Aucun"

        self.list_grp = Group.all()
        self.list_grp.append(groups)
        self.list_grp.reverse()

        for index in self.list_grp:
            sentence = u"%(name)s" % {'name': index.name}
            self.combo_grp.addItem(sentence)

        self.full_name = LineEdit()
        self.msg_e_or_c = FLabel("")
        self.full_name.setFont(QFont("Arial", 16))
        self.phone_number = IntLineEdit()
        self.phone_number.setInputMask("D9.99.99.99")
        self.phone_number.setAlignment(Qt.AlignCenter)
        self.phone_number.setFont(QFont("Arial", 16))

        send_butt = Button(u"Enregistrer")
        send_butt.clicked.connect(self.save_form)
        cancel_but = Button(u"Fermer")
        cancel_but.clicked.connect(self.cancel)

        formbox = QGridLayout()
        formbox.addWidget(FLabel(u"Groupes:"), 0, 0)
        formbox.addWidget(self.combo_grp, 1, 0)
        formbox.addWidget(FLabel(u"Nom complèt: "), 0, 1)
        formbox.addWidget(self.full_name, 1, 1)
        formbox.addWidget(FLabel(u"Numéro: "), 0, 2)
        formbox.addWidget(self.phone_number, 1, 2)
        formbox.addWidget(send_butt, 2, 1)
        formbox.addWidget(cancel_but, 2, 0)
        formbox.addWidget(self.msg_e_or_c, 3, 0, 3, 2)

        vbox.addLayout(formbox)
        self.setLayout(vbox)

    def cancel(self):
        self.close()

    def iscomplet(self):
        self.phone_number.setStyleSheet("")
        self.msg_e_or_c.setText("")
        self.msg_e_or_c.setStyleSheet("")

        try:
            int(self.phone_number.text().replace('.', ''))
        except:
            self.phone_number.setStyleSheet("border-bottom: 3px solid red;"
                                            "background-color:#AFAFAF;")
            self.phone_number.setToolTip(u"Ce champ est obligatoire.")
            return False
        return True

    def save_form(self):

        if not self.iscomplet():
            return
        full_name = unicode(self.full_name.text())
        phone_number = int(self.phone_number.text().replace('.', ''))
        try:
            Contact(number=phone_number, name=full_name).save()
        except:
            self.msg_e_or_c.setText(u"Ce numéro existe déjà")
            self.msg_e_or_c.setStyleSheet("color: red")
            return

        grp = unicode(self.list_grp[self.combo_grp.currentIndex()])

        if not grp == "Aucun":
            grp = Group.select().where(Group.name == grp).get()
            contact = Contact.select().where(
                Contact.number == phone_number).get()
            ContactGroup(group=grp.id, contact=contact).save()
        self.full_name.setText("")
        self.phone_number.setText("")
        self.msg_e_or_c.setText(
            u"Le numéro (<b>{}</b>) à éte bien enregistré".format(
                phone_number))
Exemplo n.º 8
0
class HomeViewWidget(FWidget):
    """ Shows the home page  """

    def __init__(self, parent=0, *args, **kwargs):
        super(HomeViewWidget, self).__init__(parent=parent,
                                             *args, **kwargs)

        self.parent = parent

        self.parentWidget().setWindowTitle(u"Bienvenu sur transfert Wari")
        self.title = FPageTitle(u"Tranfert")
        vbox = QVBoxLayout(self)
        vbox.addWidget(self.title)
        self.sttg = SettingsAdmin().select().where(SettingsAdmin.id == 1).get()
        if self.sttg.can_use:
            self.createHomeGroupBox()
            vbox.addWidget(self.homegbox)
        else:
            self.activationGroupBox()
            vbox.addWidget(self.topLeftGroupBoxBtt)
        self.setLayout(vbox)

    def createHomeGroupBox(self):
        self.homegbox = QGroupBox()

        self.table = OperationTableWidget(parent=self)
        table_box = QVBoxLayout()
        self.title_table = FPageTitle(u"Historique des transferts")
        table_box.addWidget(self.title_table)
        table_box.addWidget(self.table)

        # form transfer
        self.number = LineEdit()
        self.number.setInputMask("D9.99.99.99")
        self.number.setAlignment(Qt.AlignCenter)
        self.number.setFont(QFont("Arial", 17))
        self.number.setToolTip(u"""Taper le nom ou le numéro de téléphone du
                                beneficiare""")
        self.amount = LineEdit()
        self.amount.setFont(QFont("Arial", 15))
        self.amount.setValidator(QIntValidator())
        self.amount.setToolTip(u"Taper le montant du transfert")
        self.password_field = EnterTabbedLineEdit()
        self.password_field.setFont(QFont("Arial", 15))
        self.password_field.setEchoMode(LineEdit.Password)
        self.password_field.setToolTip(u"Taper le code orange money")
        self.msg_field = FLabel("")
        butt = Button(u"Envoyer")
        butt.clicked.connect(self.get_or_creat_nbr)

        formbox = QGridLayout()
        formbox.addWidget(FLabel(u"Numéro"), 0, 0)
        formbox.addWidget(self.number, 1, 0)
        formbox.addWidget(FLabel(u"Montant"), 0, 1)
        formbox.addWidget(self.amount, 1, 1)
        formbox.addWidget(FLabel(u"code"), 0, 2)
        formbox.addWidget(self.password_field, 1, 2)
        formbox.addWidget(self.msg_field, 0, 5)
        formbox.addWidget(butt, 1, 4)
        formbox.setColumnStretch(5, 3)

        transfer_box = QVBoxLayout()
        # formbox.setSizeConstraint(QLayout.SetFixedSize)
        transfer_box.addWidget(self.title)
        transfer_box.addLayout(formbox)
        transfer_box.addLayout(table_box)
        # self.setLayout(transfer_box)
        self.homegbox.setLayout(transfer_box)

    def activationGroupBox(self):
        self.topLeftGroupBoxBtt = QGroupBox(self.tr("Nouvelle license"))
        self.setWindowTitle(u"License")
        self.parentWidget().setWindowTitle(u"Activation de la license")

        self.code_field = PyTextViewer(u"""Vous avez besoin du code ci desous
                                           pour l'activation:<hr> <b>{code}</b><hr>
                                           <h4>Contacts:</h4>{contact}"""
                                       .format(code=SettingsAdmin().select().get().clean_mac,
                                               contact=Constants.TEL_AUT))
        self.name_field = LineEdit()
        self.license_field = QTextEdit()
        self.pixmap = QPixmap("")
        self.image = FLabel(self)
        self.image.setPixmap(self.pixmap)

        butt = Button_save(u"Enregistrer")
        butt.clicked.connect(self.add_lience)

        editbox = QGridLayout()
        editbox.addWidget(FLabel(u"Nom: "), 0, 0)
        editbox.addWidget(self.name_field, 0, 1)
        editbox.addWidget(FLabel(u"License: "), 1, 0)
        editbox.addWidget(self.license_field, 1, 1)
        editbox.addWidget(self.code_field, 1, 2)
        editbox.addWidget(self.image, 5, 1)
        editbox.addWidget(butt, 6, 1)

        self.topLeftGroupBoxBtt.setLayout(editbox)

    def get_or_creat_nbr(self):
        ''' add operation '''

        if not self.is_complete():
            return

        number = unicode(self.number.text().replace('.', ''))
        amount = unicode(self.amount.text())
        Contact.get_or_create(number)

        data = {"phone_num": [number, ], "amount": amount,
                "code": unicode(self.password_field.text())}
        # print(data)
        # multiple_sender(data)
        self.number.clear()
        self.amount.clear()
        self.password_field.clear()
        self.table.refresh_()
        self.msg_field.setText(
            u"Transfert  vers ({}) a été effectué.".format(number))
        self.msg_field.setStyleSheet("color: green")

    def is_complete(self):
        self.amount.setStyleSheet("")
        self.password_field.setStyleSheet("")
        if unicode(self.amount.text()) == "":
            self.amount.setStyleSheet("font-size:20px; color: red")
            self.amount.setText(u"Ce champ est obligatoire.")
            return False
        if unicode(self.password_field.text()) == "":
            self.password_field.setStyleSheet("font-size:20px; color: red")
            self.password_field.setText(u"Ce champ est obligatoire.")
            return False
        return True

    def check_license(self, license):

        self.flog = False

        if (SettingsAdmin().is_valide_mac(license)):
            self.pixmap = QPixmap(u"{}accept.png".format(Constants.img_cmedia))
            self.image.setToolTip("License correct")
            self.flog = True
        else:
            self.pixmap = QPixmap(
                u"{}decline.png".format(Constants.img_cmedia))
            self.image.setToolTip("License incorrect")
        self.image.setPixmap(self.pixmap)

    def add_lience(self):
        """ add User """
        name = unicode(self.name_field.text()).strip()
        license = unicode(self.license_field.toPlainText())
        self.check_license(license)

        if self.flog:
            sttg = self.sttg
            sttg.user = name
            sttg.license = license
            sttg.save()
            raise_success(u"Confirmation",
                          u"""La license (<b>{}</b>) à éte bien enregistré pour cette
                           machine.\n
                           Elle doit être bien gardé""".format(license))
            self.goto_archi()
Exemplo n.º 9
0
class NewOrEditOfficeViewWidget(QDialog, FWidget):
    def __init__(self, pp=None, owner=None, parent=None, *args, **kwargs):
        QDialog.__init__(self, parent, *args, **kwargs)

        self.setWindowTitle(u"Nouvel Organisation")
        self.parent = parent

        vbox = QVBoxLayout()

        self.office_group_box()
        vbox.addWidget(self.organGroupBoxBtt)
        self.setLayout(vbox)

    def office_group_box(self):
        self.organGroupBoxBtt = QGroupBox(
            self.tr("Configuration des localités"))

        self.office_box = QComboBox()
        self.office_box.currentIndexChanged.connect(self.change_select_office)

        self.office_list = get_offices()
        self.region_box = QComboBox()
        self.region_label = FLabel()
        self.cercle_label = FLabel()
        self.phone_field = IntLineEdit()
        self.phone_field.setInputMask('## ## ## ##')
        self.bp = LineEdit()
        self.adress_org = QTextEdit()
        self.email_org = LineEdit()

        for index, value in enumerate(self.office_list):
            self.office_box.addItem("{}".format(office_name(value)), value)

        formbox = QFormLayout()
        formbox.addRow(FormLabel(u"Nom service :"), self.office_box)
        formbox.addRow(FormLabel(u"Région"), self.region_label)
        formbox.addRow(FormLabel(u"Cercle"), self.cercle_label)
        formbox.addRow(FormLabel(u"Tel :"), self.phone_field)
        formbox.addRow(FormLabel(u"B.P :"), self.bp)
        formbox.addRow(FormLabel(u"E-mail :"), self.email_org)
        formbox.addRow(FormLabel(u"Adresse complete :"), self.adress_org)
        butt = Button_save(u"Enregistrer")
        butt.clicked.connect(self.save_edit)
        formbox.addRow("", butt)

        self.organGroupBoxBtt.setLayout(formbox)

    def change_select_office(self):
        select_o = self.office_box.itemData(self.office_box.currentIndex())
        self.r_select = office_region(select_o)
        self.c_select = office_cercle(select_o)
        self.region_label.setText(get_entity_name(self.r_select))
        self.cercle_label.setText(get_entity_name(self.c_select))

    def is_valide(self):
        if check_is_empty(self.phone_field):
            return False
        return True

    def save_edit(self):
        ''' add operation '''

        if not self.is_valide():
            return

        office = Office()
        office.slug = self.office_box.itemData(self.office_box.currentIndex())
        office.slug_region = self.r_select
        office.slug_cercle = self.c_select
        office.phone = is_int(self.phone_field.text())
        office.email_org = str(self.email_org.text())
        office.bp = str(self.bp.text())
        office.adress_org = str(self.adress_org.toPlainText())
        office.save_()
        self.accept()