Ejemplo n.º 1
0
    def follow_protocol(self, message):
        """
            The function checks what the client wants.
        """
		
		# split the message to its headers.
        message = message.split("::")
		
		if len(message) > 2 and message[0] == "register me":
		
			details = message[1].split(',')

			registration_process = Registration(self.general, self.communicator, details)
			
			registration_process.start()
			
		elif len(message) >3 and message[0] == "login me":
			
			login_process = Login(self.general, self.communicator, details)

			login_process.start()
Ejemplo n.º 2
0
    def registrate(self):
        regist_id = ui.regist_idInput.text()
        regist_pass = ui.regist_passInput.text()
        regist_pass2 = ui.regist_passInput2.text()

        registration = Registration(self.conn)
        registration.checkWantId(regist_id)

        if regist_id == '' or regist_pass == '':
            self.regist_alarm("아이디 비밀번호를 입력해주세요")
        else:
            if registration.checkWantIdResult == True:
                self.regist_alarm("아이디 중복체크를 다시 해주세요")

            elif registration.checkWantIdResult == False and regist_pass != regist_pass2:
                self.regist_alarm("비밀번호을 다시 확인 해주세요")

            elif registration.checkWantIdResult == False and regist_pass == regist_pass2:
                registration.addUserInfo(regist_id, regist_pass)
                self.registWindow(True)
                ui.regist_idInput.setText('')
                ui.regist_passInput.setText('')
                ui.regist_passInput2.setText('')
                self.login_alarm("회원가입 성공")
Ejemplo n.º 3
0
                print("")
        # use corner with minimum val as correspondence (if there are any)
        if values:
            src.append(coord)
            min_idx = np.argmin([ssd['VAL'] for ssd in values])
            dst.append(coords_warped[values[min_idx]['corner_idx']])
        if 100 * i / len(coords_orig) > progress:
            print("\rprogress: {}% of corners done".format(progress), end='')
            progress += progress_res
    print("\rprogress: 100% of corners done", end='')
    return src, dst


####################edited end#####################################

reg = Registration(filepath)
index1 = 0  # index van eerste foto
index2 = 1  # index van derde foto
Harris_th_rel = 0.001
Harris_min_dist = 5
window = 5
#transform, corners, inliers = reg.get_transform(index1, index2, match_max_dist=100) # (mag ook de naam van het bestand zijn of de pixels zelf ipv index)
# transform = transformatiematrix, maar je kan ook de translatie, rotatie en schaal afzonderlijk opvragen met transform.rotation,...
# corners = alle gevonden hoeken in img1 in corners['src'] + beste match in img2 bij overeenkomstige index in corners['dst']
# inliers = aanwezigheidslijst van de gekozen corners (zie foto die grplot wordt)

# dit is om te tonen welke corners gekozen zijn
#

img1 = reg.get_image(index1, gray=False)
img2 = reg.get_image(index2, gray=False)
Ejemplo n.º 4
0
                    SSDs.append({'SSD': SSD, 'corner_idx': j})
            except:
                print("")
        # use corner with minimum SSD as correspondence (if there are any)
        if SSDs:
            src.append(coord)
            min_idx = np.argmin([ssd['SSD'] for ssd in SSDs])
            dst.append(coords_warped[SSDs[min_idx]['corner_idx']])
        if 100 * i / len(coords_orig) > progress:
            print("\rprogress: {}% of corners done".format(progress), end='')
            progress += progress_res
    print("\rprogress: 100% of corners done", end='')
    return src, dst


reg = Registration(filepath)
index1 = 0  # index van eerste foto
index2 = 1  # index van derde foto
Harris_th_rel = 0.001
Harris_min_dist = 5
window = 5
#transform, corners, inliers = reg.get_transform(index1, index2, match_max_dist=100) # (mag ook de naam van het bestand zijn of de pixels zelf ipv index)
# transform = transformatiematrix, maar je kan ook de translatie, rotatie en schaal afzonderlijk opvragen met transform.rotation,...
# corners = alle gevonden hoeken in img1 in corners['src'] + beste match in img2 bij overeenkomstige index in corners['dst']
# inliers = aanwezigheidslijst van de gekozen corners (zie foto die grplot wordt)

# dit is om te tonen welke corners gekozen zijn
#

img1 = reg.get_image(index1, gray=False)
img2 = reg.get_image(index2, gray=False)
Ejemplo n.º 5
0
class Ui_MainWindow(object):
    def setupUi(self, MainWindow):
        MainWindow.setObjectName("MainWindow")
        MainWindow.resize(600, 600)
        self.centralwidget = QtWidgets.QWidget(MainWindow)
        self.centralwidget.setObjectName("centralwidget")
        self.log_in_frame = QtWidgets.QFrame(self.centralwidget)
        self.log_in_frame.setGeometry(QtCore.QRect(180, 320, 390, 190))
        font = QtGui.QFont()
        font.setBold(False)
        font.setItalic(False)
        font.setWeight(50)
        self.log_in_frame.setFont(font)
        self.log_in_frame.setFrameShape(QtWidgets.QFrame.NoFrame)
        self.log_in_frame.setFrameShadow(QtWidgets.QFrame.Raised)
        self.log_in_frame.setLineWidth(0)
        self.log_in_frame.setObjectName("log_in_frame")
        self.log_in_login_input = QtWidgets.QLineEdit(self.log_in_frame)
        self.log_in_login_input.setGeometry(QtCore.QRect(0, 0, 240, 35))
        self.log_in_login_input.setInputMask("")
        self.log_in_login_input.setText("")
        self.log_in_login_input.setMaxLength(100)
        self.log_in_login_input.setObjectName("log_in_login_input")
        self.log_in_password_input = QtWidgets.QLineEdit(self.log_in_frame)
        self.log_in_password_input.setGeometry(QtCore.QRect(0, 50, 240, 35))
        self.log_in_password_input.setInputMask("")
        self.log_in_password_input.setText("")
        self.log_in_password_input.setMaxLength(1000)
        self.log_in_password_input.setEchoMode(QtWidgets.QLineEdit.Password)
        self.log_in_password_input.setCursorPosition(0)
        self.log_in_password_input.setObjectName("log_in_password_input")
        self.log_in_log_in_button = QtWidgets.QPushButton(self.log_in_frame)
        self.log_in_log_in_button.setGeometry(QtCore.QRect(30, 100, 180, 35))
        self.log_in_log_in_button.setObjectName("log_in_log_in_button")
        self.log_in_to_registration_button = QtWidgets.QPushButton(
            self.log_in_frame)
        self.log_in_to_registration_button.setGeometry(
            QtCore.QRect(30, 150, 180, 35))
        self.log_in_to_registration_button.setObjectName(
            "log_in_to_registration_button")
        self.log_in_show_password_checkbox = QtWidgets.QCheckBox(
            self.log_in_frame)
        self.log_in_show_password_checkbox.setGeometry(
            QtCore.QRect(250, 60, 140, 25))
        font = QtGui.QFont()
        font.setBold(True)
        font.setItalic(False)
        font.setWeight(75)
        self.log_in_show_password_checkbox.setFont(font)
        self.log_in_show_password_checkbox.setObjectName(
            "log_in_show_password_checkbox")
        self.log_in_password_input.raise_()
        self.log_in_show_password_checkbox.raise_()
        self.log_in_to_registration_button.raise_()
        self.log_in_log_in_button.raise_()
        self.log_in_login_input.raise_()
        self.registration_frame = QtWidgets.QFrame(self.centralwidget)
        self.registration_frame.setEnabled(True)
        self.registration_frame.setGeometry(QtCore.QRect(10, 20, 580, 535))
        self.registration_frame.setFrameShape(QtWidgets.QFrame.NoFrame)
        self.registration_frame.setFrameShadow(QtWidgets.QFrame.Raised)
        self.registration_frame.setLineWidth(1)
        self.registration_frame.setObjectName("registration_frame")
        self.registration_login_input = QtWidgets.QLineEdit(
            self.registration_frame)
        self.registration_login_input.setGeometry(
            QtCore.QRect(20, 250, 240, 35))
        self.registration_login_input.setInputMask("")
        self.registration_login_input.setText("")
        self.registration_login_input.setMaxLength(100)
        self.registration_login_input.setObjectName("registration_login_input")
        self.registration_password_input = QtWidgets.QLineEdit(
            self.registration_frame)
        self.registration_password_input.setGeometry(
            QtCore.QRect(20, 300, 240, 35))
        self.registration_password_input.setInputMask("")
        self.registration_password_input.setText("")
        self.registration_password_input.setMaxLength(1000)
        self.registration_password_input.setEchoMode(
            QtWidgets.QLineEdit.Password)
        self.registration_password_input.setCursorPosition(0)
        self.registration_password_input.setObjectName(
            "registration_password_input")
        self.registration_password_validation_input = QtWidgets.QLineEdit(
            self.registration_frame)
        self.registration_password_validation_input.setGeometry(
            QtCore.QRect(20, 350, 240, 35))
        self.registration_password_validation_input.setInputMask("")
        self.registration_password_validation_input.setText("")
        self.registration_password_validation_input.setMaxLength(1000)
        self.registration_password_validation_input.setEchoMode(
            QtWidgets.QLineEdit.Password)
        self.registration_password_validation_input.setCursorPosition(0)
        self.registration_password_validation_input.setObjectName(
            "registration_password_validation_input")
        self.registration_name_input = QtWidgets.QLineEdit(
            self.registration_frame)
        self.registration_name_input.setGeometry(
            QtCore.QRect(320, 250, 240, 35))
        self.registration_name_input.setMaxLength(100)
        self.registration_name_input.setObjectName("registration_name_input")
        self.registration_last_name_input = QtWidgets.QLineEdit(
            self.registration_frame)
        self.registration_last_name_input.setGeometry(
            QtCore.QRect(320, 300, 240, 35))
        self.registration_last_name_input.setMaxLength(100)
        self.registration_last_name_input.setObjectName(
            "registration_last_name_input")
        self.registration_email_input = QtWidgets.QLineEdit(
            self.registration_frame)
        self.registration_email_input.setGeometry(
            QtCore.QRect(320, 350, 240, 35))
        self.registration_email_input.setMaxLength(255)
        self.registration_email_input.setObjectName("registration_email_input")
        self.registration_register_button = QtWidgets.QPushButton(
            self.registration_frame)
        self.registration_register_button.setGeometry(
            QtCore.QRect(200, 400, 180, 35))
        self.registration_register_button.setObjectName(
            "registration_register_button")
        self.registration_to_log_in_button = QtWidgets.QPushButton(
            self.registration_frame)
        self.registration_to_log_in_button.setGeometry(
            QtCore.QRect(200, 450, 180, 35))
        self.registration_to_log_in_button.setAutoFillBackground(True)
        self.registration_to_log_in_button.setObjectName(
            "registration_to_log_in_button")
        self.user_frame = QtWidgets.QFrame(self.centralwidget)
        self.user_frame.setGeometry(QtCore.QRect(10, 20, 580, 535))
        self.user_frame.setFrameShape(QtWidgets.QFrame.NoFrame)
        self.user_frame.setFrameShadow(QtWidgets.QFrame.Plain)
        self.user_frame.setObjectName("user_frame")
        self.user_log_out_button = QtWidgets.QPushButton(self.user_frame)
        self.user_log_out_button.setGeometry(QtCore.QRect(200, 400, 180, 35))
        self.user_log_out_button.setObjectName("user_log_out_button")
        self.user_text = QtWidgets.QLabel(self.user_frame)
        self.user_text.setGeometry(QtCore.QRect(10, 10, 560, 100))
        font = QtGui.QFont()
        font.setPointSize(20)
        font.setBold(True)
        font.setWeight(75)
        self.user_text.setFont(font)
        self.user_text.setFrameShape(QtWidgets.QFrame.NoFrame)
        self.user_text.setFrameShadow(QtWidgets.QFrame.Plain)
        self.user_text.setLineWidth(1)
        self.user_text.setScaledContents(False)
        self.user_text.setAlignment(QtCore.Qt.AlignLeading
                                    | QtCore.Qt.AlignLeft | QtCore.Qt.AlignTop)
        self.user_text.setObjectName("user_text")
        self.admin_frame = QtWidgets.QFrame(self.centralwidget)
        self.admin_frame.setGeometry(QtCore.QRect(10, 20, 580, 535))
        self.admin_frame.setFrameShape(QtWidgets.QFrame.NoFrame)
        self.admin_frame.setFrameShadow(QtWidgets.QFrame.Raised)
        self.admin_frame.setObjectName("admin_frame")
        self.admin_log_out_button = QtWidgets.QPushButton(self.admin_frame)
        self.admin_log_out_button.setGeometry(QtCore.QRect(200, 400, 180, 35))
        self.admin_log_out_button.setObjectName("admin_log_out_button")
        self.admin_table = QtWidgets.QTreeWidget(self.admin_frame)
        self.admin_table.setGeometry(QtCore.QRect(10, 10, 560, 350))
        self.admin_table.setColumnCount(8)
        self.admin_table.setObjectName("admin_table")
        MainWindow.setCentralWidget(self.centralwidget)
        self.statusbar = QtWidgets.QStatusBar(MainWindow)
        self.statusbar.setObjectName("statusbar")
        MainWindow.setStatusBar(self.statusbar)

        self.retranslateUi(MainWindow)

        #
        try:
            self.db = DB()
        except:
            print("Can't connect to database:")
            self.create_popup_window("Error!", "Can't connect to database!")
            exit()

        self.log_in_to_registration_button.clicked.connect(
            self.registration_menu)
        self.registration_to_log_in_button.clicked.connect(self.log_in_menu)
        self.log_in_log_in_button.clicked.connect(self.log_in)
        self.registration_register_button.clicked.connect(self.register)
        self.log_in_show_password_checkbox.stateChanged.connect(
            self.show_or_hide_password)
        self.user_log_out_button.clicked.connect(self.log_out)
        self.admin_log_out_button.clicked.connect(self.log_out)

        self.registration_frame.hide()
        self.admin_frame.hide()
        self.user_frame.hide()

        self.registration = Registration(self.db)
        self.log_in_object = LogIn(self.db)
        self.user = None
        #
        QtCore.QMetaObject.connectSlotsByName(MainWindow)

    def retranslateUi(self, MainWindow):
        _translate = QtCore.QCoreApplication.translate
        MainWindow.setWindowTitle(_translate("MainWindow", "MainWindow"))
        self.log_in_password_input.setPlaceholderText(
            _translate("MainWindow", "Password"))
        self.log_in_show_password_checkbox.setText(
            _translate("MainWindow", "Show password"))
        self.log_in_log_in_button.setText(_translate("MainWindow", "Log in"))
        self.log_in_to_registration_button.setText(
            _translate("MainWindow", "I don\'t have an account"))
        self.log_in_login_input.setPlaceholderText(
            _translate("MainWindow", "Login"))
        self.registration_password_input.setPlaceholderText(
            _translate("MainWindow", "Password"))
        self.registration_login_input.setPlaceholderText(
            _translate("MainWindow", "Login"))
        self.registration_password_validation_input.setPlaceholderText(
            _translate("MainWindow", "Password"))
        self.registration_name_input.setPlaceholderText(
            _translate("MainWindow", "Name"))
        self.registration_last_name_input.setPlaceholderText(
            _translate("MainWindow", "Last name"))
        self.registration_email_input.setPlaceholderText(
            _translate("MainWindow", "E-mail"))
        self.registration_register_button.setText(
            _translate("MainWindow", "Register"))
        self.registration_to_log_in_button.setText(
            _translate("MainWindow", "I already have an account"))
        self.user_log_out_button.setText(_translate("MainWindow", "Log out"))
        self.user_text.setText(_translate("MainWindow",
                                          "Hello name last_name"))
        self.admin_log_out_button.setText(_translate("MainWindow", "Log out"))
        self.admin_table.headerItem().setText(0,
                                              _translate("MainWindow", "id"))
        self.admin_table.headerItem().setText(1,
                                              _translate("MainWindow", "name"))
        self.admin_table.headerItem().setText(
            2, _translate("MainWindow", "last_name"))
        self.admin_table.headerItem().setText(
            3, _translate("MainWindow", "login"))
        self.admin_table.headerItem().setText(
            4, _translate("MainWindow", "password"))
        self.admin_table.headerItem().setText(
            5, _translate("MainWindow", "e-mail"))
        self.admin_table.headerItem().setText(
            6, _translate("MainWindow", "permission"))
        self.admin_table.headerItem().setText(
            7, _translate("MainWindow", "registration_date"))

    def create_popup_window(self, title, message):
        popup_window = QMessageBox()
        popup_window.setWindowTitle(title)
        popup_window.setText(message)
        popup_window.exec_()

    def clear_inputs(self):
        inputs = self.log_in_frame.findChildren(QtWidgets.QLineEdit)
        inputs += self.registration_frame.findChildren(QtWidgets.QLineEdit)
        for input in inputs:
            input.clear()
        self.log_in_show_password_checkbox.setChecked(False)

    def fill_table(self):
        self.admin_table.clear()
        table = self.db.get_table()
        for item in range(len(table)):
            QtWidgets.QTreeWidgetItem(self.admin_table)
            for value in range(len(table[item])):
                self.admin_table.topLevelItem(item).setText(
                    value, str(table[item][value]))

    def registration_menu(self):
        self.log_in_frame.hide()
        self.user_frame.hide()
        self.admin_frame.hide()
        self.registration_frame.show()
        self.clear_inputs()

    def log_in_menu(self):
        self.registration_frame.hide()
        self.user_frame.hide()
        self.admin_frame.hide()
        self.log_in_frame.show()
        self.clear_inputs()

    def user_menu(self):
        self.registration_frame.hide()
        self.log_in_frame.hide()
        self.admin_frame.hide()
        self.user_frame.show()
        self.user_text.setText(
            f"You are logged in as {self.user.name} {self.user.last_name}")
        self.clear_inputs()

    def admin_menu(self):
        self.registration_frame.hide()
        self.log_in_frame.hide()
        self.user_frame.hide()
        self.admin_frame.show()
        self.fill_table()
        self.clear_inputs()

    def log_out(self):
        self.user = None
        self.log_in_menu()

    def log_in(self):
        login = self.log_in_login_input.text()
        password = self.log_in_password_input.text()
        try:
            self.user = self.log_in_object.log_in(login, password)
            if self.user.is_admin():
                self.admin_menu()
            else:
                self.user_menu()
        except Exception as e:
            self.create_popup_window("Error", str(e))

    def register(self):
        name = self.registration_name_input.text()
        last_name = self.registration_last_name_input.text()
        email = self.registration_email_input.text()
        login = self.registration_login_input.text()
        password = self.registration_password_input.text()
        password_validation = self.registration_password_validation_input.text(
        )

        try:
            message = self.registration.register(login, password,
                                                 password_validation, name,
                                                 last_name, email)
            self.clear_inputs()
            self.create_popup_window(message[0], message[1])
        except Exception as e:
            self.create_popup_window("Error", str(e))

    def show_or_hide_password(self):
        if self.log_in_show_password_checkbox.isChecked():
            self.log_in_password_input.setEchoMode(QtWidgets.QLineEdit.Normal)
        else:
            self.log_in_password_input.setEchoMode(
                QtWidgets.QLineEdit.Password)
Ejemplo n.º 6
0
    def setupUi(self, MainWindow):
        MainWindow.setObjectName("MainWindow")
        MainWindow.resize(600, 600)
        self.centralwidget = QtWidgets.QWidget(MainWindow)
        self.centralwidget.setObjectName("centralwidget")
        self.log_in_frame = QtWidgets.QFrame(self.centralwidget)
        self.log_in_frame.setGeometry(QtCore.QRect(180, 320, 390, 190))
        font = QtGui.QFont()
        font.setBold(False)
        font.setItalic(False)
        font.setWeight(50)
        self.log_in_frame.setFont(font)
        self.log_in_frame.setFrameShape(QtWidgets.QFrame.NoFrame)
        self.log_in_frame.setFrameShadow(QtWidgets.QFrame.Raised)
        self.log_in_frame.setLineWidth(0)
        self.log_in_frame.setObjectName("log_in_frame")
        self.log_in_login_input = QtWidgets.QLineEdit(self.log_in_frame)
        self.log_in_login_input.setGeometry(QtCore.QRect(0, 0, 240, 35))
        self.log_in_login_input.setInputMask("")
        self.log_in_login_input.setText("")
        self.log_in_login_input.setMaxLength(100)
        self.log_in_login_input.setObjectName("log_in_login_input")
        self.log_in_password_input = QtWidgets.QLineEdit(self.log_in_frame)
        self.log_in_password_input.setGeometry(QtCore.QRect(0, 50, 240, 35))
        self.log_in_password_input.setInputMask("")
        self.log_in_password_input.setText("")
        self.log_in_password_input.setMaxLength(1000)
        self.log_in_password_input.setEchoMode(QtWidgets.QLineEdit.Password)
        self.log_in_password_input.setCursorPosition(0)
        self.log_in_password_input.setObjectName("log_in_password_input")
        self.log_in_log_in_button = QtWidgets.QPushButton(self.log_in_frame)
        self.log_in_log_in_button.setGeometry(QtCore.QRect(30, 100, 180, 35))
        self.log_in_log_in_button.setObjectName("log_in_log_in_button")
        self.log_in_to_registration_button = QtWidgets.QPushButton(
            self.log_in_frame)
        self.log_in_to_registration_button.setGeometry(
            QtCore.QRect(30, 150, 180, 35))
        self.log_in_to_registration_button.setObjectName(
            "log_in_to_registration_button")
        self.log_in_show_password_checkbox = QtWidgets.QCheckBox(
            self.log_in_frame)
        self.log_in_show_password_checkbox.setGeometry(
            QtCore.QRect(250, 60, 140, 25))
        font = QtGui.QFont()
        font.setBold(True)
        font.setItalic(False)
        font.setWeight(75)
        self.log_in_show_password_checkbox.setFont(font)
        self.log_in_show_password_checkbox.setObjectName(
            "log_in_show_password_checkbox")
        self.log_in_password_input.raise_()
        self.log_in_show_password_checkbox.raise_()
        self.log_in_to_registration_button.raise_()
        self.log_in_log_in_button.raise_()
        self.log_in_login_input.raise_()
        self.registration_frame = QtWidgets.QFrame(self.centralwidget)
        self.registration_frame.setEnabled(True)
        self.registration_frame.setGeometry(QtCore.QRect(10, 20, 580, 535))
        self.registration_frame.setFrameShape(QtWidgets.QFrame.NoFrame)
        self.registration_frame.setFrameShadow(QtWidgets.QFrame.Raised)
        self.registration_frame.setLineWidth(1)
        self.registration_frame.setObjectName("registration_frame")
        self.registration_login_input = QtWidgets.QLineEdit(
            self.registration_frame)
        self.registration_login_input.setGeometry(
            QtCore.QRect(20, 250, 240, 35))
        self.registration_login_input.setInputMask("")
        self.registration_login_input.setText("")
        self.registration_login_input.setMaxLength(100)
        self.registration_login_input.setObjectName("registration_login_input")
        self.registration_password_input = QtWidgets.QLineEdit(
            self.registration_frame)
        self.registration_password_input.setGeometry(
            QtCore.QRect(20, 300, 240, 35))
        self.registration_password_input.setInputMask("")
        self.registration_password_input.setText("")
        self.registration_password_input.setMaxLength(1000)
        self.registration_password_input.setEchoMode(
            QtWidgets.QLineEdit.Password)
        self.registration_password_input.setCursorPosition(0)
        self.registration_password_input.setObjectName(
            "registration_password_input")
        self.registration_password_validation_input = QtWidgets.QLineEdit(
            self.registration_frame)
        self.registration_password_validation_input.setGeometry(
            QtCore.QRect(20, 350, 240, 35))
        self.registration_password_validation_input.setInputMask("")
        self.registration_password_validation_input.setText("")
        self.registration_password_validation_input.setMaxLength(1000)
        self.registration_password_validation_input.setEchoMode(
            QtWidgets.QLineEdit.Password)
        self.registration_password_validation_input.setCursorPosition(0)
        self.registration_password_validation_input.setObjectName(
            "registration_password_validation_input")
        self.registration_name_input = QtWidgets.QLineEdit(
            self.registration_frame)
        self.registration_name_input.setGeometry(
            QtCore.QRect(320, 250, 240, 35))
        self.registration_name_input.setMaxLength(100)
        self.registration_name_input.setObjectName("registration_name_input")
        self.registration_last_name_input = QtWidgets.QLineEdit(
            self.registration_frame)
        self.registration_last_name_input.setGeometry(
            QtCore.QRect(320, 300, 240, 35))
        self.registration_last_name_input.setMaxLength(100)
        self.registration_last_name_input.setObjectName(
            "registration_last_name_input")
        self.registration_email_input = QtWidgets.QLineEdit(
            self.registration_frame)
        self.registration_email_input.setGeometry(
            QtCore.QRect(320, 350, 240, 35))
        self.registration_email_input.setMaxLength(255)
        self.registration_email_input.setObjectName("registration_email_input")
        self.registration_register_button = QtWidgets.QPushButton(
            self.registration_frame)
        self.registration_register_button.setGeometry(
            QtCore.QRect(200, 400, 180, 35))
        self.registration_register_button.setObjectName(
            "registration_register_button")
        self.registration_to_log_in_button = QtWidgets.QPushButton(
            self.registration_frame)
        self.registration_to_log_in_button.setGeometry(
            QtCore.QRect(200, 450, 180, 35))
        self.registration_to_log_in_button.setAutoFillBackground(True)
        self.registration_to_log_in_button.setObjectName(
            "registration_to_log_in_button")
        self.user_frame = QtWidgets.QFrame(self.centralwidget)
        self.user_frame.setGeometry(QtCore.QRect(10, 20, 580, 535))
        self.user_frame.setFrameShape(QtWidgets.QFrame.NoFrame)
        self.user_frame.setFrameShadow(QtWidgets.QFrame.Plain)
        self.user_frame.setObjectName("user_frame")
        self.user_log_out_button = QtWidgets.QPushButton(self.user_frame)
        self.user_log_out_button.setGeometry(QtCore.QRect(200, 400, 180, 35))
        self.user_log_out_button.setObjectName("user_log_out_button")
        self.user_text = QtWidgets.QLabel(self.user_frame)
        self.user_text.setGeometry(QtCore.QRect(10, 10, 560, 100))
        font = QtGui.QFont()
        font.setPointSize(20)
        font.setBold(True)
        font.setWeight(75)
        self.user_text.setFont(font)
        self.user_text.setFrameShape(QtWidgets.QFrame.NoFrame)
        self.user_text.setFrameShadow(QtWidgets.QFrame.Plain)
        self.user_text.setLineWidth(1)
        self.user_text.setScaledContents(False)
        self.user_text.setAlignment(QtCore.Qt.AlignLeading
                                    | QtCore.Qt.AlignLeft | QtCore.Qt.AlignTop)
        self.user_text.setObjectName("user_text")
        self.admin_frame = QtWidgets.QFrame(self.centralwidget)
        self.admin_frame.setGeometry(QtCore.QRect(10, 20, 580, 535))
        self.admin_frame.setFrameShape(QtWidgets.QFrame.NoFrame)
        self.admin_frame.setFrameShadow(QtWidgets.QFrame.Raised)
        self.admin_frame.setObjectName("admin_frame")
        self.admin_log_out_button = QtWidgets.QPushButton(self.admin_frame)
        self.admin_log_out_button.setGeometry(QtCore.QRect(200, 400, 180, 35))
        self.admin_log_out_button.setObjectName("admin_log_out_button")
        self.admin_table = QtWidgets.QTreeWidget(self.admin_frame)
        self.admin_table.setGeometry(QtCore.QRect(10, 10, 560, 350))
        self.admin_table.setColumnCount(8)
        self.admin_table.setObjectName("admin_table")
        MainWindow.setCentralWidget(self.centralwidget)
        self.statusbar = QtWidgets.QStatusBar(MainWindow)
        self.statusbar.setObjectName("statusbar")
        MainWindow.setStatusBar(self.statusbar)

        self.retranslateUi(MainWindow)

        #
        try:
            self.db = DB()
        except:
            print("Can't connect to database:")
            self.create_popup_window("Error!", "Can't connect to database!")
            exit()

        self.log_in_to_registration_button.clicked.connect(
            self.registration_menu)
        self.registration_to_log_in_button.clicked.connect(self.log_in_menu)
        self.log_in_log_in_button.clicked.connect(self.log_in)
        self.registration_register_button.clicked.connect(self.register)
        self.log_in_show_password_checkbox.stateChanged.connect(
            self.show_or_hide_password)
        self.user_log_out_button.clicked.connect(self.log_out)
        self.admin_log_out_button.clicked.connect(self.log_out)

        self.registration_frame.hide()
        self.admin_frame.hide()
        self.user_frame.hide()

        self.registration = Registration(self.db)
        self.log_in_object = LogIn(self.db)
        self.user = None
        #
        QtCore.QMetaObject.connectSlotsByName(MainWindow)
Ejemplo n.º 7
0
from Registration import Registration

foo = Registration('2016_Tritonman_DL', 10)
from Registration import Registration
import numpy as np
filepath = "../testbeelden/"  # path to images
from skimage.feature import (match_descriptors, corner_harris, corner_peaks,
                             ORB, plot_matches)
from matplotlib import pyplot as plt
from random import sample
from skimage.measure import ransac
from skimage.transform import AffineTransform

import cv2

reg = Registration(filepath)
index1 = 0  # index van eerste foto
index2 = 1  # index van derde foto

src = np.asarray([[1082, 541], [716, 1883], [1222, 3047], [1837, 2881],
                  [2454, 623], [2784, 1197], [2501, 2891], [2453, 622]])
dst = np.asarray([[1114, 732], [740, 2046], [1295, 3218], [1940, 3044],
                  [2488, 757], [2861, 1311], [2619, 3052], [2490, 755]])

img1 = reg.get_image(index1, gray=False)
img2 = reg.get_image(index2, gray=False)
row, col, chan = img1.shape

transform = cv2.findHomography(src, dst, cv2.RANSAC)
reg.show_matches(img1, img2, src, dst, transform[1] == 1)

img2_warped = cv2.warpPerspective(img2, np.linalg.inv(transform[0]),
                                  (col * 2, row * 2))
for i in range(img1.shape[0]):
Ejemplo n.º 9
0
    def setupUi(self, MainWindow):
        MainWindow.setObjectName("MainWindow")
        MainWindow.resize(615, 600)
        self.central_widget = QtWidgets.QWidget(MainWindow)
        self.central_widget.setObjectName("central_widget")
        self.log_in_frame = QtWidgets.QFrame(self.central_widget)
        self.log_in_frame.setGeometry(QtCore.QRect(170, 300, 390, 190))
        font = QtGui.QFont()
        font.setBold(False)
        font.setItalic(False)
        font.setWeight(50)
        self.log_in_frame.setFont(font)
        self.log_in_frame.setFrameShape(QtWidgets.QFrame.NoFrame)
        self.log_in_frame.setFrameShadow(QtWidgets.QFrame.Raised)
        self.log_in_frame.setLineWidth(0)
        self.log_in_frame.setObjectName("log_in_frame")
        self.log_in_password_input = QtWidgets.QLineEdit(self.log_in_frame)
        self.log_in_password_input.setGeometry(QtCore.QRect(0, 50, 240, 35))
        self.log_in_password_input.setInputMask("")
        self.log_in_password_input.setText("")
        self.log_in_password_input.setMaxLength(1000)
        self.log_in_password_input.setEchoMode(QtWidgets.QLineEdit.Password)
        self.log_in_password_input.setCursorPosition(0)
        self.log_in_password_input.setObjectName("log_in_password_input")
        self.log_in_show_password_checkbox = QtWidgets.QCheckBox(
            self.log_in_frame)
        self.log_in_show_password_checkbox.setGeometry(
            QtCore.QRect(250, 60, 140, 25))
        font = QtGui.QFont()
        font.setBold(True)
        font.setItalic(False)
        font.setWeight(75)
        self.log_in_show_password_checkbox.setFont(font)
        self.log_in_show_password_checkbox.setObjectName(
            "log_in_show_password_checkbox")
        self.log_in_log_in_button = QtWidgets.QPushButton(self.log_in_frame)
        self.log_in_log_in_button.setGeometry(QtCore.QRect(30, 100, 180, 35))
        self.log_in_log_in_button.setObjectName("log_in_log_in_button")
        self.log_in_to_registration_button = QtWidgets.QPushButton(
            self.log_in_frame)
        self.log_in_to_registration_button.setGeometry(
            QtCore.QRect(30, 150, 180, 35))
        self.log_in_to_registration_button.setObjectName(
            "log_in_to_registration_button")
        self.log_in_login_input = QtWidgets.QLineEdit(self.log_in_frame)
        self.log_in_login_input.setGeometry(QtCore.QRect(0, 0, 240, 35))
        self.log_in_login_input.setInputMask("")
        self.log_in_login_input.setText("")
        self.log_in_login_input.setMaxLength(100)
        self.log_in_login_input.setObjectName("log_in_login_input")
        self.log_in_password_input.raise_()
        self.log_in_show_password_checkbox.raise_()
        self.log_in_to_registration_button.raise_()
        self.log_in_log_in_button.raise_()
        self.log_in_login_input.raise_()
        self.registration_frame = QtWidgets.QFrame(self.central_widget)
        self.registration_frame.setEnabled(True)
        self.registration_frame.setGeometry(QtCore.QRect(0, 0, 580, 535))
        self.registration_frame.setFrameShape(QtWidgets.QFrame.NoFrame)
        self.registration_frame.setFrameShadow(QtWidgets.QFrame.Raised)
        self.registration_frame.setLineWidth(1)
        self.registration_frame.setObjectName("registration_frame")
        self.registration_password_input = QtWidgets.QLineEdit(
            self.registration_frame)
        self.registration_password_input.setGeometry(
            QtCore.QRect(20, 300, 240, 35))
        self.registration_password_input.setInputMask("")
        self.registration_password_input.setText("")
        self.registration_password_input.setMaxLength(1000)
        self.registration_password_input.setEchoMode(
            QtWidgets.QLineEdit.Password)
        self.registration_password_input.setCursorPosition(0)
        self.registration_password_input.setObjectName(
            "registration_password_input")
        self.registration_login_input = QtWidgets.QLineEdit(
            self.registration_frame)
        self.registration_login_input.setGeometry(
            QtCore.QRect(20, 250, 240, 35))
        self.registration_login_input.setInputMask("")
        self.registration_login_input.setText("")
        self.registration_login_input.setMaxLength(100)
        self.registration_login_input.setObjectName("registration_login_input")
        self.registration_password_validation_input = QtWidgets.QLineEdit(
            self.registration_frame)
        self.registration_password_validation_input.setGeometry(
            QtCore.QRect(20, 350, 240, 35))
        self.registration_password_validation_input.setInputMask("")
        self.registration_password_validation_input.setText("")
        self.registration_password_validation_input.setMaxLength(1000)
        self.registration_password_validation_input.setEchoMode(
            QtWidgets.QLineEdit.Password)
        self.registration_password_validation_input.setCursorPosition(0)
        self.registration_password_validation_input.setObjectName(
            "registration_password_validation_input")
        self.registration_name_input = QtWidgets.QLineEdit(
            self.registration_frame)
        self.registration_name_input.setGeometry(
            QtCore.QRect(320, 250, 240, 35))
        self.registration_name_input.setMaxLength(100)
        self.registration_name_input.setObjectName("registration_name_input")
        self.registration_last_name_input = QtWidgets.QLineEdit(
            self.registration_frame)
        self.registration_last_name_input.setGeometry(
            QtCore.QRect(320, 300, 240, 35))
        self.registration_last_name_input.setMaxLength(100)
        self.registration_last_name_input.setObjectName(
            "registration_last_name_input")
        self.registration_email_input = QtWidgets.QLineEdit(
            self.registration_frame)
        self.registration_email_input.setGeometry(
            QtCore.QRect(320, 350, 240, 35))
        self.registration_email_input.setMaxLength(255)
        self.registration_email_input.setObjectName("registration_email_input")
        self.registration_register_button = QtWidgets.QPushButton(
            self.registration_frame)
        self.registration_register_button.setGeometry(
            QtCore.QRect(200, 400, 180, 35))
        self.registration_register_button.setObjectName(
            "registration_register_button")
        self.registration_to_log_in_button = QtWidgets.QPushButton(
            self.registration_frame)
        self.registration_to_log_in_button.setGeometry(
            QtCore.QRect(200, 450, 180, 35))
        self.registration_to_log_in_button.setAutoFillBackground(True)
        self.registration_to_log_in_button.setObjectName(
            "registration_to_log_in_button")
        MainWindow.setCentralWidget(self.central_widget)
        self.statusbar = QtWidgets.QStatusBar(MainWindow)
        self.statusbar.setObjectName("statusbar")
        MainWindow.setStatusBar(self.statusbar)
        self.retranslateUi(MainWindow)
        self.parent = MainWindow
        #
        self.db = self.parent.db
        self.log_in_to_registration_button.clicked.connect(
            self.registration_menu)
        self.registration_to_log_in_button.clicked.connect(self.log_in_menu)
        self.log_in_log_in_button.clicked.connect(self.log_in)
        self.registration_register_button.clicked.connect(self.register)
        self.log_in_show_password_checkbox.stateChanged.connect(
            self.show_or_hide_password)

        self.registration_frame.hide()

        self.registration = Registration(self.db)
        self.log_in_object = LogIn(self.db)
        self.user = None
        #
        QtCore.QMetaObject.connectSlotsByName(self.parent)
Ejemplo n.º 10
0
class LoginRegistrationView(object):
    def setupUi(self, MainWindow):
        MainWindow.setObjectName("MainWindow")
        MainWindow.resize(615, 600)
        self.central_widget = QtWidgets.QWidget(MainWindow)
        self.central_widget.setObjectName("central_widget")
        self.log_in_frame = QtWidgets.QFrame(self.central_widget)
        self.log_in_frame.setGeometry(QtCore.QRect(170, 300, 390, 190))
        font = QtGui.QFont()
        font.setBold(False)
        font.setItalic(False)
        font.setWeight(50)
        self.log_in_frame.setFont(font)
        self.log_in_frame.setFrameShape(QtWidgets.QFrame.NoFrame)
        self.log_in_frame.setFrameShadow(QtWidgets.QFrame.Raised)
        self.log_in_frame.setLineWidth(0)
        self.log_in_frame.setObjectName("log_in_frame")
        self.log_in_password_input = QtWidgets.QLineEdit(self.log_in_frame)
        self.log_in_password_input.setGeometry(QtCore.QRect(0, 50, 240, 35))
        self.log_in_password_input.setInputMask("")
        self.log_in_password_input.setText("")
        self.log_in_password_input.setMaxLength(1000)
        self.log_in_password_input.setEchoMode(QtWidgets.QLineEdit.Password)
        self.log_in_password_input.setCursorPosition(0)
        self.log_in_password_input.setObjectName("log_in_password_input")
        self.log_in_show_password_checkbox = QtWidgets.QCheckBox(
            self.log_in_frame)
        self.log_in_show_password_checkbox.setGeometry(
            QtCore.QRect(250, 60, 140, 25))
        font = QtGui.QFont()
        font.setBold(True)
        font.setItalic(False)
        font.setWeight(75)
        self.log_in_show_password_checkbox.setFont(font)
        self.log_in_show_password_checkbox.setObjectName(
            "log_in_show_password_checkbox")
        self.log_in_log_in_button = QtWidgets.QPushButton(self.log_in_frame)
        self.log_in_log_in_button.setGeometry(QtCore.QRect(30, 100, 180, 35))
        self.log_in_log_in_button.setObjectName("log_in_log_in_button")
        self.log_in_to_registration_button = QtWidgets.QPushButton(
            self.log_in_frame)
        self.log_in_to_registration_button.setGeometry(
            QtCore.QRect(30, 150, 180, 35))
        self.log_in_to_registration_button.setObjectName(
            "log_in_to_registration_button")
        self.log_in_login_input = QtWidgets.QLineEdit(self.log_in_frame)
        self.log_in_login_input.setGeometry(QtCore.QRect(0, 0, 240, 35))
        self.log_in_login_input.setInputMask("")
        self.log_in_login_input.setText("")
        self.log_in_login_input.setMaxLength(100)
        self.log_in_login_input.setObjectName("log_in_login_input")
        self.log_in_password_input.raise_()
        self.log_in_show_password_checkbox.raise_()
        self.log_in_to_registration_button.raise_()
        self.log_in_log_in_button.raise_()
        self.log_in_login_input.raise_()
        self.registration_frame = QtWidgets.QFrame(self.central_widget)
        self.registration_frame.setEnabled(True)
        self.registration_frame.setGeometry(QtCore.QRect(0, 0, 580, 535))
        self.registration_frame.setFrameShape(QtWidgets.QFrame.NoFrame)
        self.registration_frame.setFrameShadow(QtWidgets.QFrame.Raised)
        self.registration_frame.setLineWidth(1)
        self.registration_frame.setObjectName("registration_frame")
        self.registration_password_input = QtWidgets.QLineEdit(
            self.registration_frame)
        self.registration_password_input.setGeometry(
            QtCore.QRect(20, 300, 240, 35))
        self.registration_password_input.setInputMask("")
        self.registration_password_input.setText("")
        self.registration_password_input.setMaxLength(1000)
        self.registration_password_input.setEchoMode(
            QtWidgets.QLineEdit.Password)
        self.registration_password_input.setCursorPosition(0)
        self.registration_password_input.setObjectName(
            "registration_password_input")
        self.registration_login_input = QtWidgets.QLineEdit(
            self.registration_frame)
        self.registration_login_input.setGeometry(
            QtCore.QRect(20, 250, 240, 35))
        self.registration_login_input.setInputMask("")
        self.registration_login_input.setText("")
        self.registration_login_input.setMaxLength(100)
        self.registration_login_input.setObjectName("registration_login_input")
        self.registration_password_validation_input = QtWidgets.QLineEdit(
            self.registration_frame)
        self.registration_password_validation_input.setGeometry(
            QtCore.QRect(20, 350, 240, 35))
        self.registration_password_validation_input.setInputMask("")
        self.registration_password_validation_input.setText("")
        self.registration_password_validation_input.setMaxLength(1000)
        self.registration_password_validation_input.setEchoMode(
            QtWidgets.QLineEdit.Password)
        self.registration_password_validation_input.setCursorPosition(0)
        self.registration_password_validation_input.setObjectName(
            "registration_password_validation_input")
        self.registration_name_input = QtWidgets.QLineEdit(
            self.registration_frame)
        self.registration_name_input.setGeometry(
            QtCore.QRect(320, 250, 240, 35))
        self.registration_name_input.setMaxLength(100)
        self.registration_name_input.setObjectName("registration_name_input")
        self.registration_last_name_input = QtWidgets.QLineEdit(
            self.registration_frame)
        self.registration_last_name_input.setGeometry(
            QtCore.QRect(320, 300, 240, 35))
        self.registration_last_name_input.setMaxLength(100)
        self.registration_last_name_input.setObjectName(
            "registration_last_name_input")
        self.registration_email_input = QtWidgets.QLineEdit(
            self.registration_frame)
        self.registration_email_input.setGeometry(
            QtCore.QRect(320, 350, 240, 35))
        self.registration_email_input.setMaxLength(255)
        self.registration_email_input.setObjectName("registration_email_input")
        self.registration_register_button = QtWidgets.QPushButton(
            self.registration_frame)
        self.registration_register_button.setGeometry(
            QtCore.QRect(200, 400, 180, 35))
        self.registration_register_button.setObjectName(
            "registration_register_button")
        self.registration_to_log_in_button = QtWidgets.QPushButton(
            self.registration_frame)
        self.registration_to_log_in_button.setGeometry(
            QtCore.QRect(200, 450, 180, 35))
        self.registration_to_log_in_button.setAutoFillBackground(True)
        self.registration_to_log_in_button.setObjectName(
            "registration_to_log_in_button")
        MainWindow.setCentralWidget(self.central_widget)
        self.statusbar = QtWidgets.QStatusBar(MainWindow)
        self.statusbar.setObjectName("statusbar")
        MainWindow.setStatusBar(self.statusbar)
        self.retranslateUi(MainWindow)
        self.parent = MainWindow
        #
        self.db = self.parent.db
        self.log_in_to_registration_button.clicked.connect(
            self.registration_menu)
        self.registration_to_log_in_button.clicked.connect(self.log_in_menu)
        self.log_in_log_in_button.clicked.connect(self.log_in)
        self.registration_register_button.clicked.connect(self.register)
        self.log_in_show_password_checkbox.stateChanged.connect(
            self.show_or_hide_password)

        self.registration_frame.hide()

        self.registration = Registration(self.db)
        self.log_in_object = LogIn(self.db)
        self.user = None
        #
        QtCore.QMetaObject.connectSlotsByName(self.parent)

    def retranslateUi(self, MainWindow):
        _translate = QtCore.QCoreApplication.translate
        MainWindow.setWindowTitle(_translate("MainWindow", "MainWindow"))
        self.log_in_password_input.setPlaceholderText(
            _translate("MainWindow", "Password"))
        self.log_in_show_password_checkbox.setText(
            _translate("MainWindow", "Show password"))
        self.log_in_log_in_button.setText(_translate("MainWindow", "Log in"))
        self.log_in_to_registration_button.setText(
            _translate("MainWindow", "I don\'t have an account"))
        self.log_in_login_input.setPlaceholderText(
            _translate("MainWindow", "Login"))
        self.registration_password_input.setPlaceholderText(
            _translate("MainWindow", "Password"))
        self.registration_login_input.setPlaceholderText(
            _translate("MainWindow", "Login"))
        self.registration_password_validation_input.setPlaceholderText(
            _translate("MainWindow", "Password"))
        self.registration_name_input.setPlaceholderText(
            _translate("MainWindow", "Name"))
        self.registration_last_name_input.setPlaceholderText(
            _translate("MainWindow", "Last name"))
        self.registration_email_input.setPlaceholderText(
            _translate("MainWindow", "E-mail"))
        self.registration_register_button.setText(
            _translate("MainWindow", "Register"))
        self.registration_to_log_in_button.setText(
            _translate("MainWindow", "I already have an account"))

    def clear_inputs(self):
        inputs = self.log_in_frame.findChildren(QtWidgets.QLineEdit)
        inputs += self.registration_frame.findChildren(QtWidgets.QLineEdit)
        for input in inputs:
            input.clear()
        self.log_in_show_password_checkbox.setChecked(False)

    def registration_menu(self):
        self.log_in_frame.hide()
        self.registration_frame.show()
        self.clear_inputs()

    def log_in_menu(self):
        self.registration_frame.hide()
        self.log_in_frame.show()
        self.clear_inputs()

    def log_out(self):
        self.user = None
        self.log_in_menu()

    def log_in(self):
        login = self.log_in_login_input.text()
        password = self.log_in_password_input.text()
        try:
            self.user = self.log_in_object.log_in(login, password)
            if self.user.is_admin():
                self.parent.show_admin_view()
            else:
                self.parent.show_user_view(self.user)
        except Exception as e:
            self.parent.create_popup_window("Error", str(e))

    def register(self):
        name = self.registration_name_input.text()
        last_name = self.registration_last_name_input.text()
        email = self.registration_email_input.text()
        login = self.registration_login_input.text()
        password = self.registration_password_input.text()
        password_validation = self.registration_password_validation_input.text(
        )

        try:
            message = self.registration.register(login, password,
                                                 password_validation, name,
                                                 last_name, email)
            self.clear_inputs()
            self.parent.create_popup_window(message[0], message[1])
        except Exception as e:
            self.parent.create_popup_window("Error", str(e))

    def show_or_hide_password(self):
        if self.log_in_show_password_checkbox.isChecked():
            self.log_in_password_input.setEchoMode(QtWidgets.QLineEdit.Normal)
        else:
            self.log_in_password_input.setEchoMode(
                QtWidgets.QLineEdit.Password)
Ejemplo n.º 11
0
 def Register(self):
     self.newWindow = tk.Toplevel(self.master)
     self.app = Registration(self.newWindow)
Ejemplo n.º 12
0
import tkinter as tk
from tkinter import *
from tkinter import ttk
from Registration import Registration
from Rot import *

app = Registration(master=root1)
app.mainloop()
Ejemplo n.º 13
0
    api_methods_get["TestReq"] = TestReq()
"""

api_methods_get, api_methods_post = {}, {}

api_methods_get["GetResult"] = GetResult()
api_methods_get["GetAddresse"] = GetAddresse()
api_methods_get["GetRoute"] = GetRoute()
api_methods_get["GetSegment"] = GetSegment()
api_methods_get["SetSegment"] = SetSegment()
api_methods_get["getAllWayPoints"] = GetAllWayPoints()
api_methods_get["addNewPoint"] = AddNewPoint()
api_methods_get["Authorization"] = Authorization()
api_methods_get["addNewLink"] = AddNewLink()
api_methods_get["getAllWaySegments"] = GetAllWaySegments()
api_methods_get["Registration"] = Registration()


class HttpServer(BaseHTTPRequestHandler):
    def _set_headers(self):
        self.send_response(200)
        self.send_header('Content-type', 'text/plain')
        self.send_header('Access-Control-Allow-Origin', '*')
        self.end_headers()

    def do_GET(self):
        self._set_headers()
        url = self.requestline[9:-9]
        dct = dict(parse_qsl(urlsplit(url).path))
        if dct.get('id', None) is not None:
            dct['id'] = int(dct['id'])
Ejemplo n.º 14
0
from flask import Blueprint, Response
from flask import request

accounts = Blueprint('accounts', __name__, template_folder='templates')

from Registration import Registration
from Authentication import Authentication
import ResponseHandler

registration = Registration()
authentication = Authentication()


@accounts.route('/register/', methods=['POST'])
def register():
    post_content = request.json
    http_code = registration.register_user(post_content)
    return ResponseHandler.construct_json_response({
        "http_code": http_code,
        "http_code_only": True,
    })


@accounts.route('/login/', methods=['POST'])
def login():
    post_content = request.json
    response = authentication.login(post_content)
    return ResponseHandler.construct_json_response({
        "http_code":
        response.get("http_code"),
        "data":
Ejemplo n.º 15
0
class InitialDisplay:

    __signUp = Registration()
    __toDo = TodoListHandle()

    def mainMenu(self):

        try:
            # remove file kegiatan.txt sebelumnya (jika ada)
            remove("kegiatan.txt")
        except FileNotFoundError:
            print("", end="")
        finally:
            # jika file tidak ada, maka tidak akan diremove dan hanya akan dibuatkan file baru
            file = open("kegiatan.txt", "w+")
            file.close()

        # melakukan registrasi terlebih dahulu
        self.__clearScreen()
        self.__signUp.registration()
        self.__clearScreen()

        # setelah registrasi berhasil, maka akan muncul tampilan menu awal
        while True:
            self.__initialMenu()
            choice = int(input("> "))

            if choice == 1:
                self.__clearScreen()
                print("+-------------- To-Do-List Today -------------+\n")
                self.__toDo.showList()

            elif choice == 2:
                self.__clearScreen()
                print("+---------------- Adding List ----------------+\n")
                self.__toDo.showList()
                self.__toDo.addList()

            elif choice == 3:
                self.__clearScreen()
                print("+---------------- Delete List ----------------+\n")
                self.__toDo.showList()
                self.__toDo.deleteList()
            elif choice == 4:
                self.__clearScreen()
                print("+----------------- Edit List -----------------+\n")
                self.__toDo.showList()
                self.__toDo.editList()

            elif choice == 5:
                self.__clearScreen()
                print("+------------ Description List ---------------+\n")
                self.__toDo.showList()
                self.__toDo.descriptionList()

            elif choice == 6:
                self.__clearScreen()
                print("+------------------ Biodata ------------------+")
                print(self.__signUp.getBiodata())
                print("+{}+".format("-" * 45))

            elif choice == 0:
                break

            else:
                self.__clearScreen()

    # method clearScreen untuk menghapus screen pada terminal agar tidak penuh
    def __clearScreen(self):
        # for windows
        if name == "nt":
            _ = system("cls")
        # for linux and macOS
        elif name == "posix":
            _ = system("clear")

    # method initialMenu untuk menampilkan tampilan awal pilihan user
    def __initialMenu(self):
        print("\n+---------------- To-Do-List -----------------+")
        print("\nSelamat Datang {} ^_^\n".format(self.__signUp.getCallName()))
        self.__setTime()
        print("1. Lihat To-do-list Harian")
        print("2. Tambahkan kegiatan")
        print("3. Hapus kegiatan")
        print("4. Edit kegiatan")
        print("5. Lihat Deskripsi kegiatan")
        print("6. Lihat Biodata anda")
        print("0. Exit")

    # method setTime berguna untuk menampilkan jam, tanggal, dan hari saat ini.
    def __setTime(self):
        todayDate = date.today().strftime("%d %B %Y")
        timeNow = datetime.now().time().strftime("%H:%M:%S")
        print("Today is {}\nDate : {}\nIt's : {} o'clock\n".format(
            calendar.day_name[date.today().weekday()], todayDate, timeNow))
class InitialDisplay:
    # registrasi terlebih dahulu
    __signUp = Registration()
    __toDo = Tk()

    # main menu
    def mainMenu(self):
        try:
            # remove file kegiatan.txt sebelumnya (jika ada)
            remove("kegiatan.txt")
        except FileNotFoundError:
            print("", end="")
        finally:
            # jika file tidak ada, maka tidak akan diremove dan hanya akan dibuatkan file baru
            file = open("kegiatan.txt", "w+")
            file.close()
        # jika proses registrasi berhasil, maka method initial menu berjalan
        if self.__signUp.getCondition() == 1:
            self.__initialMenu(self.__toDo)

    # method initialMenu untuk menampilkan tampilan awal pilihan user
    def __initialMenu(self, master):
        photo_1 = PhotoImage(file="title_1.png")

        label_1 = Label(master, image=photo_1,
                        background="#134f5c").pack(pady=0)

        label_2 = Label(
            master,
            text="Tekan 'esc' untuk keluar dari aplikasi",
            font=("calibri 14 bold"),
            background="#134f5c",
            foreground="red",
        ).pack(pady=0)

        label_3 = Label(
            master,
            text="Selamat datang {} ^_^\n{}".format(
                self.__signUp.getCallName(), self.__setTime()),
            font=("Trebuchet MS", 13, "bold"),
            background="#134f5c",
            foreground="white",
        ).pack(pady=0)

        main_frame = tk.Frame(master, bg="#134f5c")
        main_frame.configure(width=100, height=100)
        main_frame.pack(pady=0)

        # button untuk melihat kegiatan
        button_choice_1 = Button(
            main_frame,
            text="Lihat To-Do List",
            font=("arial", 13, "bold"),
            width=15,
            background="#e6a817",
            foreground="#2b2b2b",
            borderwidth=3,
            relief=GROOVE,
            command=lambda: ShowList(),
        ).grid(row=0, pady=5)

        # button untuk menambahkan kegiatan
        button_choice_2 = Button(
            main_frame,
            text="Tambah kegiatan",
            font=("arial", 13, "bold"),
            width=15,
            background="#e6a817",
            foreground="#2b2b2b",
            borderwidth=3,
            relief=GROOVE,
            command=lambda: AddList(),
        ).grid(row=0, column=1, pady=10, padx=25)

        # button untuk menghapus kegiatan
        button_choice_3 = Button(
            main_frame,
            text="Hapus kegiatan",
            font=("arial", 13, "bold"),
            width=15,
            background="#e6a817",
            foreground="#2b2b2b",
            borderwidth=3,
            relief=GROOVE,
            command=lambda: DeleteList(),
        ).grid(row=1, pady=5)

        # button untuk melihat deskripsi
        button_choice_4 = Button(
            main_frame,
            text="Lihat deskripsi",
            font=("arial", 13, "bold"),
            width=15,
            background="#e6a817",
            foreground="#2b2b2b",
            borderwidth=3,
            relief=GROOVE,
            command=lambda: DescriptionList(),
        ).grid(row=1, column=1, pady=10, padx=25)

        label_bio = Label(
            main_frame,
            text="Biodata Anda",
            font=("arial", 13, "bold"),
            background="#134f5c",
            foreground="white",
        ).grid(row=2, pady=5, columnspan=2)

        # menampilkan biodata user
        biodataUser = self.biodata(main_frame)
        # mengatur judul, background, editable, dan menambahkan shortcut esc untuk exit program
        self.__centerWindow(master, 840, 680)
        master.title("To-Do-List Application")
        master.configure(background="#134f5c")
        master.overrideredirect(True)
        master.resizable(0, 0)
        master.bind("<Escape>", lambda event: master.destroy())
        master.mainloop()

    # buat window GUI tepat ditengah layar
    def __centerWindow(self, master, width, height):
        widthScreen = master.winfo_screenwidth()
        heightScreen = master.winfo_screenheight()
        x = (widthScreen / 2) - (width / 2)
        y = (heightScreen / 2) - ((height / 2) + 20)
        return master.geometry("%dx%d+%d+%d" % (width, height, x, y))

    # method setTime berguna untuk menampilkan jam, tanggal, dan hari saat ini.
    def __setTime(self):
        todayDate = date.today().strftime("%d %B %Y")
        timeNow = datetime.now().time().strftime("%H:%M:%S")
        return "Today is {}\nDate : {}\nIt's : {} o'clock\n".format(
            calendar.day_name[date.today().weekday()], todayDate, timeNow)

    # tampilan label biodata user
    def biodata(self, frame):
        biodata = Label(
            frame,
            text="{}\n{}\n{}".format(
                "+" +
                (len(self.__signUp.getBiodata().split("\n")[7]) + 10) * "-" +
                "+",
                self.__signUp.getBiodata(),
                "+" +
                (len(self.__signUp.getBiodata().split("\n")[7]) + 10) * "-" +
                "+",
            ),
            font=("calibri", 12, "bold"),
            background="#134f5c",
            foreground="white",
        )
        biodata.configure(justify=LEFT)
        biodata.grid(row=4, columnspan=2, pady=0)
        return biodata