Пример #1
0
    def __init__(self, session, parent=None):
        """Create the dialog and initialize the fields.

        session -- Sqlalchemy session.
        parent -- Parent for the QDialog.
        """
        self.parent = parent
        super().__init__(parent=self.parent)
        self.ui = Ui_NewMember()
        self.ui.setupUi(self)
        self.session = session
        self.setWindowTitle("Ny medlem")
        self.usernamevalidator = UsernameValidator(self.session, self)
        self.member = Member()  # Needed in UsernameValidator
        self.ui.username_fld.setValidator(self.usernamevalidator)
        init_gender_combobox(self.ui.gender_fld)
        configure_membership_qcombobox(self.ui.department_comboBox,
                                       "Department", self.session)

        # Set correct lengths for QTextEdits
        for field in self.member.editable_text_fields:
            fill_qlineedit_from_db(self.ui, field, self.member)

        contactinfo = ContactInformation()
        for field in contactinfo.publicfields:
            fill_qlineedit_from_db(self.ui, field, contactinfo)

        if self.member.birthDate_fld:
            self.ui.birthDate_fld.setDateTime(self.member.birthDate_fld)

        self.show()
Пример #2
0
    def __init__(self, session, parent=None):
        """Create the dialog and initialize the fields.

        session -- Sqlalchemy session.
        parent -- Parent for the QDialog.
        """
        self.parent = parent
        super().__init__(parent=self.parent)
        self.ui = Ui_NewMember()
        self.ui.setupUi(self)
        self.session = session
        self.setWindowTitle("Ny medlem")
        self.usernamevalidator = UsernameValidator(self.session, self)
        self.member = Member()  # Needed in UsernameValidator
        self.ui.username_fld.setValidator(self.usernamevalidator)
        init_gender_combobox(self.ui.gender_fld)
        configure_membership_qcombobox(self.ui.department_comboBox,
                "Department", self.session)

        # Set correct lengths for QTextEdits
        for field in self.member.editable_text_fields:
            fill_qlineedit_from_db(self.ui, field, self.member)

        contactinfo = ContactInformation()
        for field in contactinfo.publicfields:
            fill_qlineedit_from_db(self.ui, field, contactinfo)

        if self.member.birthDate_fld:
            self.ui.birthDate_fld.setDateTime(self.member.birthDate_fld)

        self.show()
Пример #3
0
class NewMemberDialog(QDialog):
    def __init__(self, session, parent=None):
        """Create the dialog and initialize the fields.

        session -- Sqlalchemy session.
        parent -- Parent for the QDialog.
        """
        self.parent = parent
        super().__init__(parent=self.parent)
        self.ui = Ui_NewMember()
        self.ui.setupUi(self)
        self.session = session
        self.setWindowTitle("Ny medlem")
        self.usernamevalidator = UsernameValidator(self.session, self)
        self.member = Member()  # Needed in UsernameValidator
        self.ui.username_fld.setValidator(self.usernamevalidator)
        init_gender_combobox(self.ui.gender_fld)
        configure_membership_qcombobox(self.ui.department_comboBox,
                "Department", self.session)

        # Set correct lengths for QTextEdits
        for field in self.member.editable_text_fields:
            fill_qlineedit_from_db(self.ui, field, self.member)

        contactinfo = ContactInformation()
        for field in contactinfo.publicfields:
            fill_qlineedit_from_db(self.ui, field, contactinfo)

        if self.member.birthDate_fld:
            self.ui.birthDate_fld.setDateTime(self.member.birthDate_fld)

        self.show()

    def accept(self):
        """Commit the new member to the database."""
        self.member = None
        if self.ui.makePhux_CheckBox.isChecked():
            self.member = create_phux(self.session)

        else:
            self.member = create_member(self.session)

        for field in Member.editable_text_fields:
            if (field == "username_fld" and not
                    self.ui.username_fld.hasAcceptableInput()):
                continue

            update_qtextfield_to_db(self.ui, field, self.member)

        contactinfo = self.member.contactinfo
        for field in contactinfo.publicfields:
            update_qtextfield_to_db(self.ui, field, contactinfo)
        department = self.ui.department_comboBox.currentText()
		
        if department and not assign_membership_to_member(self.session, "Department",
                department, self.member, parent=self,
                combobox=self.ui.department_comboBox, indefinite_time=True):
            return # Don't yet commit if Department not chosen.

        self.member.gender_fld = self.ui.gender_fld.currentIndex()
        self.member.birthDate_fld = self.ui.birthDate_fld.dateTime().toPyDateTime()

        self.session.commit()

        self.parent.populateMemberList(choosemember=self.member)
        self.parent.setStatusMessage("Medlem %s skapad!" %
                self.member.getWholeName())
        super().accept()

    def reject(self):
        """Close the dialog without saving any changes."""
        super().reject()
Пример #4
0
class NewMemberDialog(QDialog):
    def __init__(self, session, parent=None):
        """Create the dialog and initialize the fields.

        session -- Sqlalchemy session.
        parent -- Parent for the QDialog.
        """
        self.parent = parent
        super().__init__(parent=self.parent)
        self.ui = Ui_NewMember()
        self.ui.setupUi(self)
        self.session = session
        self.setWindowTitle("Ny medlem")
        self.usernamevalidator = UsernameValidator(self.session, self)
        self.member = Member()  # Needed in UsernameValidator
        self.ui.username_fld.setValidator(self.usernamevalidator)
        init_gender_combobox(self.ui.gender_fld)
        configure_membership_qcombobox(self.ui.department_comboBox,
                                       "Department", self.session)

        # Set correct lengths for QTextEdits
        for field in self.member.editable_text_fields:
            fill_qlineedit_from_db(self.ui, field, self.member)

        contactinfo = ContactInformation()
        for field in contactinfo.publicfields:
            fill_qlineedit_from_db(self.ui, field, contactinfo)

        if self.member.birthDate_fld:
            self.ui.birthDate_fld.setDateTime(self.member.birthDate_fld)

        self.show()

    def accept(self):
        """Commit the new member to the database."""
        self.member = None
        if self.ui.makePhux_CheckBox.isChecked():
            self.member = create_phux(self.session)

        else:
            self.member = create_member(self.session)

        for field in Member.editable_text_fields:
            if (field == "username_fld"
                    and not self.ui.username_fld.hasAcceptableInput()):
                continue

            update_qtextfield_to_db(self.ui, field, self.member)

        contactinfo = self.member.contactinfo
        for field in contactinfo.publicfields:
            update_qtextfield_to_db(self.ui, field, contactinfo)
        department = self.ui.department_comboBox.currentText()

        if department and not assign_membership_to_member(
                self.session,
                "Department",
                department,
                self.member,
                parent=self,
                combobox=self.ui.department_comboBox,
                indefinite_time=True):
            return  # Don't yet commit if Department not chosen.

        self.member.gender_fld = self.ui.gender_fld.currentIndex()
        self.member.birthDate_fld = self.ui.birthDate_fld.dateTime(
        ).toPyDateTime()

        self.session.commit()

        self.parent.populateMemberList(choosemember=self.member)
        self.parent.setStatusMessage("Medlem %s skapad!" %
                                     self.member.getWholeName())
        super().accept()

    def reject(self):
        """Close the dialog without saving any changes."""
        super().reject()