def __init__(self, parent=None): QWidget.__init__(self, parent) self.idle_list = [] # self.resize(800, 600) self.setWindowFlags(Qt.Window) self.main_frame = GameLobbyFrame(self) self.main_frame.setGeometry(0, 0, 800, 600) # Controller self.user_controller = UserController() self.chat_controller = ChatController() # UI self.login_widget = LoginDialog(self) if not self.user_controller.is_login(): self.login_widget.open() # signal self.connect(self.user_controller, SIGNAL("login_callback(int,QString)"), self.login_callback) self.connect(self.login_widget, SIGNAL("close"), self.close_login_dialog) self.connect(self.login_widget, SIGNAL("login(QString,int,QString)"), self.login) self.connect(self.chat_controller, SIGNAL("error_msg(QString)"), self.error_msg) self.connect(GameListWidget(), SIGNAL("enter_room(QString, QString)"), self.enter_room) self.msg_box = QMessageBox()
def dispatch(self): if self.msg_type == "text": return self.text_msg_patch() elif self.msg_type == "image": pass elif self.msg_type == "voice": pass elif self.msg_type == "video": pass elif self.msg_type == "shortvideo": pass elif self.msg_type == "location": pass elif self.msg_type == "link": pass elif self.msg_type == "event": if self.event == "subscribe": UserController().create_user(self.from_user_name) self.msg_type = "music" self.title = "佛系少女-冯提莫" self.music_url = "https://api.mlwei.com/music/api/?key=523077333&type=url&id=004Mkw5K1oI9K9&size=m4a" self.thumb_media_id = get_media_id() res = Message.re_msg(self) return res pass
def login(): if request.is_json: email = request.json['email'] password = request.json['password'] else: email = request.form['email'] password = request.form['password'] return UserController.login(email, password)
def __init__(self, parent=None): QWidget.__init__(self, parent) self.input_box = ChatInput(self) self.chat_view = ChatView(self) # print(self.geometry()) # self.chat_view.setGeometry(520, 10, 260, 250) # self.input_box.setGeometry(520, 260, 260, 40) self.chat_controller = ChatController() self.user_controller = UserController() self.cid = parent.rid # room id uid = self.user_controller.current_user_id if uid: self.chat_controller.add_polling_msg_task(self.cid, uid)
def create_app(test_config=None): app = Flask(__name__) auth = HTTPBasicAuth() app.config.from_mapping(DATABASE='database.db') if test_config: app.config.from_mapping(test_config) db = init_db(app) user_ctrl = UserController(db) task_ctrl = TaskController(db, user_ctrl) app = UserRouter.router(user_ctrl, app, auth) app = TaskRouter.router(task_ctrl, app, auth) return app
def __init__(self, parent=None): QListView.__init__(self, parent) self.setStyleSheet(''' border-image: url(:btn_bg); background-repeat: no-repeat; ''') self.model = QStandardItemModel() self.setModel(self.model) self.setWordWrap(True) self.setUniformItemSizes(True) self.setGridSize(QSize(self.rect().width(), 30)) self.setFont(QFont("Microsoft YaHei", 10)) self.setEditTriggers(QAbstractItemView.NoEditTriggers) self.setFocusPolicy(Qt.NoFocus) self.setSelectionMode(QAbstractItemView.NoSelection) self.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff) self.setAcceptDrops(True) self.user_controller = UserController() self.user_controller.connector.connect( SIGNAL("add_rank_item(QString, int)"), self.add_rank_item) self.user_controller.connector.connect(SIGNAL("clear"), self.clear)
def _create_user_controller(): return UserController(DatabaseEngine(url='sqlite:///bds.db'))
class GameLobby(QWidget): def __init__(self, parent=None): QWidget.__init__(self, parent) self.idle_list = [] # self.resize(800, 600) self.setWindowFlags(Qt.Window) self.main_frame = GameLobbyFrame(self) self.main_frame.setGeometry(0, 0, 800, 600) # Controller self.user_controller = UserController() self.chat_controller = ChatController() # UI self.login_widget = LoginDialog(self) if not self.user_controller.is_login(): self.login_widget.open() # signal self.connect(self.user_controller, SIGNAL("login_callback(int,QString)"), self.login_callback) self.connect(self.login_widget, SIGNAL("close"), self.close_login_dialog) self.connect(self.login_widget, SIGNAL("login(QString,int,QString)"), self.login) self.connect(self.chat_controller, SIGNAL("error_msg(QString)"), self.error_msg) self.connect(GameListWidget(), SIGNAL("enter_room(QString, QString)"), self.enter_room) self.msg_box = QMessageBox() def close_login_dialog(self): if self.user_controller.is_login(): self.login_widget.canClose = True self.login_widget.close() def login_callback(self, code, username): logging.debug('widget login callback%d %s', code, username) if code == 200: self.msg_box.setIcon(QMessageBox.Information) self.msg_box.setText( "Login Successfully: Welcome {}".format(username)) logging.debug("Login Successfully: Welcome {}".format(username)) # try to join the lobby chat room uid = self.user_controller.current_user_id self.chat_controller.join_chat_room(cid=LOBBY_ROOM_ID, uid=uid) else: self.msg_box.setIcon(QMessageBox.Warning) self.msg_box.setText("Login Failed: code {}".format(code)) ret = self.msg_box.exec_() if ret == 1024: self.close_login_dialog() self.msg_box.close() def login(self, addr, port, username): if isinstance(username, QString): username = unicode(username) if isinstance(addr, QString): addr = unicode(addr) if not (self.user_controller.is_connecting or self.user_controller.is_connected): self.user_controller.connect_client(addr, port) self.user_controller.login(username) else: self.msg_box.setIcon(QMessageBox.Warning) self.msg_box.setText("Network is busy") self.msg_box.exec_() def error_msg(self, msg): self.msg_box.setText(msg) self.msg_box.exec_() def enter_room(self, rid, title): self.room_window = GameWindow(self) self.room_window.setWindowTitle(title) self.roomWindow.show()
def userController(self): UserController(self.__usuarios).iniciar()
from flask import Flask, request, jsonify from BDD.bdd import BDD from controller.aeroport_controller import AeroportController from controller.vol_controller import VolController from controller.user_controller import UserController from controller.billet_controller import BilletController from flask_cors import CORS bdd = BDD() aeroport_controller = AeroportController(bdd) vol_controller = VolController(bdd) billet_controller = BilletController(bdd) user_controller = UserController(bdd) app = Flask(__name__) CORS(app) @app.route("/aeroport/all", methods=["GET"]) def get_all_aeroports(): return aeroport_controller.get_all(), 200 @app.route("/vol/all", methods=["GET"]) def get_all_vols(): return vol_controller.get_all(), 200 @app.route("/vol/<id_vol>", methods=["GET"]) def get_vol_by_id(id_vol): return vol_controller.get_by_id(id_vol), 200
from controller.admin_controller import AdminController login_manager = LoginManager() login_manager.init_app(app) GOOGLE_DISCOVERY_URL = "https://accounts.google.com/.well-known/openid-configuration" init_db() init_data_factory( get_client_factory().get_drive_client(), get_client_factory().get_sheets_client() ) song_factory = ControllerFactory(SongController, log_helper, get_data_factory().get_songs_dao()) user_controller = UserController(log_helper, get_data_factory().get_user_dao()) service_factory = ControllerFactory(ServiceController, log_helper, {'gmail_client': get_client_factory().get_gmail_client(), 'service_dao': get_data_factory().get_service_dao(), 'songs_dao': get_data_factory().get_songs_dao(), 'slides_helper': SlidesHelper(get_data_factory().get_songs_dao()), 'recipients_dao': get_data_factory().get_recipient_dao(), 'band_dao': get_data_factory().get_band_dao()}) recipients_factory = ControllerFactory(RecipientsController, log_helper, get_data_factory().get_recipient_dao()) admin_factory = ControllerFactory(AdminController, log_helper, get_data_factory().get_user_dao()) @app.route('/favicon.ico', methods=['GET']) def favicon(): path = os.path.join(app.root_path, '../res') return send_from_directory(path, 'favicon.ico', mimetype='image/vnd.microsoft.icon')
def retrieve_password(email): # won't work return UserController.retrieve_password(email)
def register(): email = request.form['email'] first_name = request.form['first_name'] last_name = request.form['last_name'] password = request.form['password'] return UserController.register(email, first_name, last_name, password)
from controller.expense_controller import ExpenseController from controller.user_controller import UserController from model.expenses import Expenses from model.users import Users from view.login_window import * from view.main_window import * if __name__ == "__main__": # Create databases users = Users() expenses = Expenses() # Load database content from file load_database_from_file(users, expenses) # Create controller instances user_controller = UserController(users) expense_controller = ExpenseController(expenses) # Create login windows, other windows are created from there login_window = LoginWindow(user_controller, expense_controller) login_window.execute()