Example #1
0
        def auth(**kwargs):
            self.session = Session()
            if 'POST' in methods:
                if request.method == 'POST':
                    response = Response(request_type)

                    data = self._read(request)
                    if data is not None:
                        authentication = None
                        try:
                            if self.__auth_require__:
                                authentication = Auth.log_in(**data['user'])

                            result = self.post(data=data.get('data'),
                                               auth=authentication,
                                               **kwargs)

                            response.set_data(result)
                        except Exception as e:
                            response.set_error(f'{str(type(e))}: {str(e)}')
                        finally:
                            if authentication is not None:
                                authentication.user.session().close()
                    else:
                        response.set_error("you send no data: {}".format(
                            request.value))

                    return response()
            if 'GET' in methods:
                pass
Example #2
0
    def on_auth_success(self, auth):
        from DataBase2 import Auth
        from Client.Debug.WrongId import debug
        auth = Auth.log_in(**auth)
        professor = auth.user

        SettingsAPI.synch(professor)

        Settings.load(professor)
        debug(auth.user)
        # не смотря на то, что окно аутентификации больше не нужно, создав локальную переменную,
        # мы заставим сборщик мусора удалить python wrapper of MainWindow поле выхода из функции,
        # что поломает почти всё
        self.window = MainWindow(professor=professor)
        self.window.show()

        self.close()
Example #3
0
    def auth(self, *args):
        def on_error(msg):
            raise BisitorException(msg)

        from DataBase2 import Auth
        from Client.MyQt.Widgets.Network.Request import RequestWidget

        login = self.login_input.login()
        password = self.password_input.text()
        if login == '' or password == '':
            Message().information(self, 'Вход в систему', 'Укажите логин и пароль.')
        else:
            try:
                a = Auth.log_in(login, password)

                self.auth_success.emit(dict(login=login, password=password))
            except InvalidLoginException:
                self.loading = FirstLoad.load(Auth(login=login, password=password), self.auth, )
Example #4
0
        percent_vertical_model = PercentVerticalModel(lessons, students)
        percent_vertical_model.mimic(self.view.model())
        self.view_show_color_rate.connect(
            percent_vertical_model.view_show_color_rate)
        self.percent_vertical_view.setModel(percent_vertical_model)

        percent_horizontal_model = PercentHorizontalModel(lessons, students)
        percent_horizontal_model.mimic(self.view.model())
        self.percent_horizontal_view.setModel(percent_horizontal_model)

        model.item_changed.connect(percent_horizontal_model.data_updated)
        model.item_changed.connect(percent_vertical_model.data_updated)
        self.view.select_row.connect(model.select_row)
        # self.view.select_row.connect(percent_vertical_model.select_row)


if __name__ == '__main__':
    app = QApplication(sys.argv)

    auth = Auth.log_in('VAE', '123456')
    group = Group.of(auth.user)[0]

    v = VisitTableWidget()
    v.setData(Lesson.of(group), Student.of(group))

    v.view.selectColumn(2)

    v.show()

    sys.exit(app.exec_())