class Controller: def __init__(self, model, config): self._model = model self._config = config pass def show_login(self): self.login = Login(self._model, self._config) #self.login.switch_window.connect(self.show_main) self.login.switch_window.connect(self.show_item_view) self.login.show() def show_item_view(self): self.itemsview = ItemsView(self._model, self._config) self.itemsview.cellselected.connect(self.show_item_sub) self.itemsview.ui.CreateItem.clicked.connect( lambda: self.show_item_sub()) self.login.close() self.itemsview.show() def show_item_sub(self, *args): if len(args) == 1: selected = args[0] dialog = ItemForm(self.itemsview, ccode="%s" % selected) dialog.setWindowTitle('Modify Record') else: dialog = ItemForm(self.itemsview) dialog.setWindowTitle('New Record') dialog.finished.connect(lambda: self.update_item_view()) dialog.open() def update_item_view(self): self.itemsview.readDB() self.itemsview.show()
def __init__(self, route): self.signup = Signup() self.login = Login() self.home = Home() self.instruction = Instruction() # self.loading = Loading() self.createParty = CreateParty() self.session = None self.party = None self.route = route self.uiManager = self.login.getManager()
def POST(self): """ Renders an authorization page to be scanned by google authorizer app :return: """ session = web.ctx.session session.auth = False data = web.input(key="") inp = web.input() if not ('csrf_token' in inp and inp.csrf_token == session.pop('csrf_token', None)): raise web.badrequest() # Check if inputted is correct validated = validate_key(session.unauth_username, data.key) if not validated: log("TWO-FACTOR", web.ctx['ip'], [('Username',session.unauth_username), ("Key", data.key), ("Response: ", "Login failed, auth key is wrong")]) session.csrf_token = uuid4().hex return render.qr_verify(session.auth_url, qr_verify_form, "Wrong authenticator code", session.csrf_token) if validated: log("TWO-FACTOR", web.ctx['ip'], [('Username',session.unauth_username), ("Key", data.key), ("Response: ", "Login OK, auth key correct")]) Login.login(session.unauth_userid, session.unauth_username, session.unauth_remember) raise web.seeother("/")
def show_login(self): self.login = Login(self._model, self._config) #self.login.switch_window.connect(self.show_main) self.login.switch_window.connect(self.show_item_view) self.login.show()
from views.index import Index from views.registration import Register from views.login import Login from views.logout import LogOut from views.create_feedback import CreateFeedback from config import Config app = Flask(__name__) app.config.from_object(Config) db.init_app(app) socketio = SocketIO(app=app) with app.app_context(): db.create_all(app=app) app.add_url_rule('/', view_func=Index.as_view('index')) app.add_url_rule('/register', view_func=Register.as_view('register')) app.add_url_rule('/login', view_func=Login.as_view('login')) app.add_url_rule('/logout', view_func=LogOut.as_view('logout')) app.add_url_rule('/create_feedback', view_func=CreateFeedback.as_view('create_feedback')) app.add_url_rule('/feedback/<int:feedback_id>', view_func=FeedbackDetails.as_view('feedback')) @socketio.on('feedback') def feedback(response): feedback_listing = Feedback.query.filter_by(id=response['feedbackId']).first() feedback_response = {'feedback_id': feedback_listing.id, 'views':feedback_listing.views,} emit('feedbackResponse' + str(feedback_response['feedback_id']), feedback_response, broadcast=True) if __name__ == '__main__': socketio.run(app=app, host='localhost')
return results def NopFunc(ignored): print("Faced NOP in router") pass def ParseHash(hash): g1 = hash.split('?') return g1[0] # Anything before ? def hashchange(): dlh = document.location.hash or '?#' print(dlh) parsedhash = ParseHash(dlh.split('#')[1]) hparams = ParseHParams(dlh) f = window.routes.get(parsedhash, window.routes['login']) f(hparams) pass window.routes = { 'login': Login().do, } window.psh = ParseHParams window.addEventListener("hashchange", hashchange, False) # On website load time, this is fired hashchange() # Runtime
class Route(): def __init__(self, route): self.signup = Signup() self.login = Login() self.home = Home() self.instruction = Instruction() # self.loading = Loading() self.createParty = CreateParty() self.session = None self.party = None self.route = route self.uiManager = self.login.getManager() def getRoute(self): return self.route def setRoute(self, route): self.route = route def homeRoute(self, event): if self.home.getView(event) != self.home: if self.home.getView(event) == 'login': self.uiManager = self.login.getManager() self.setRoute('login') elif self.home.getView(event) == 'creating': # self.uiManager = self.createParty.getManager() # self.setRoute('creating') self.game = Game(self.session) self.uiManager = self.game.getManager() self.setRoute('game') elif self.home.getView(event) == 'instruction': self.uiManager = self.instruction.getManager() self.setRoute('instruction') elif self.home.getView(event) == 'loading': # self.uiManager = self.createParty.getManager() # self.setRoute('creating') self.game = Game(self.session) self.game.score = self.session.score self.game.setLabelScore() self.uiManager = self.game.getManager() self.setRoute('game') def loginRoute(self, event): # if self.getRoute() == 'login': if self.login.getView(event) != self.login: if self.login.getView(event) == 'home': pseudo = self.login.getPseudo().get_text() password = self.login.getPassword().get_text() self.session = Auth().login(pseudo, password) if self.session: self.uiManager = self.home.getManager() self.setRoute('home') elif self.login.getView(event) == 'signup': self.uiManager = self.signup.getManager() self.setRoute('signup') def signupRoute(self, event): # if self.getRoute() == 'signup': if self.signup.getView(event) != self.signup: if self.signup.getView(event) == 'home': pseudo = self.signup.getPseudo().get_text() password = self.signup.getPassword().get_text() self.session = Auth().register(pseudo, password) # print(self.session.credit) if self.session: self.uiManager = self.home.getManager() self.setRoute('home') elif self.signup.getView(event) == 'login': self.uiManager = self.login.getManager() self.setRoute('login') # def loadingRoute(self, event): # # if self.getRoute() == 'loading': # if self.loading.getView(event) != self.loading: # if self.loading.getView(event) == 'signup': # self.uiManager = self.signup.getManager() # self.setRoute('signup') # elif self.home.getView(event) == 'creating': # self.uiManager = self.createParty.getManager() # self.setRoute('creating') # def CreatePartyRoute(self, event): # if self.getRoute() == 'creating': # if self.createParty.getView(event) != self.createParty: # if self.createParty.getView(event) == 'game': # name = self.createParty.getParty().get_text() # self.party = Part().createParty(name) # print(self.session) # if self.party: # self.game = Game(self.session) # self.uiManager = self.game.getManager() # self.setRoute('game') def gameRoute(self, event): e = self.game.getEvent(event) if e == 'restart': print(self.session.credit) self.game = Game(self.session) self.uiManager = self.game.getManager() self.pressed() def instructionRoute(self, event): if self.instruction.getView(event) != self.instruction: if self.instruction.getView(event) == 'login': self.uiManager = self.login.getManager() self.setRoute('login') elif self.instruction.getView(event) == 'home': self.uiManager = self.home.getManager() self.setRoute('home') def pressed(self): if self.game.pressed.get(pygame.K_RIGHT): self.game.player.move("right") elif self.game.pressed.get(pygame.K_LEFT): self.game.player.move("left") self.game.updatePosPlayer() def getAllEnemy(self): return self.game.allEnemy