def put(self): """update update_type: 1 change: password: need verify password first 2 change other info: return: 1 success 2 failed """ update_type = int(self.json.update_type or 0) if 1 == update_type: old_password = self.json.old_password new_password = self.json.new_password if not (old_password and new_password): raise BadArgument('old_password and new_password is essential.') result = UserController.update_password( user=self.current_user, old_password=old_password, new_password=new_password ) elif 2 == update_type: result = UserController.update_user_info( user=self.current_user, json_info=self.json ) else: raise BadArgument('update_type should be 1 or 2.') self.finish({ 'code': 1 if result else 2 })
def get_user(session, currentUser, user_id): controller = UserController(session) try: res = flask.jsonify(controller.get_user(user_id)) except NoResultFound: res = flask.jsonify(status='error', errors=['could not find user']) res.status_code = 404 return res
def get_appointments_from_user(session, currentUser, user_id): controller = UserController(session) try: res = flask.jsonify({'appointments':controller.get_appointments_from_user(user_id)}) except UserNotFound: res = flask.jsonify(status='error', errors=['could not find user']) res.status_code = 404 return res
def get_appointments_from_user(session, currentUser, user_id): controller = UserController(session) try: res = flask.jsonify( {'appointments': controller.get_appointments_from_user(user_id)}) except UserNotFound: res = flask.jsonify(status='error', errors=['could not find user']) res.status_code = 404 return res
def add_appointments_to_user(session, currentUser, user_id): controller = UserController(session) data = flask.request.get_json() try: res = flask.jsonify(controller.add_appointments_to_user(user_id, data)) except UserNotFound: res = flask.jsonify(status='error', errors=['could not find user']) res.status_code = 404 except AppointmentNotFound: res = flask.jsonify(status='error', errors=['could not find appointment']) res.status_code = 404 return res
def updateUser(): usr = UserController() req = usr.updateUser(request) code = session['logged_code'] req = getUser(code) user = json.loads(req.text) name = user['first_name'] session['logged_name'] = name return render_template('profile.html', name=name, user=user)
def user_status(): try: user_id = session['user_id'] except KeyError: return '', 401 if type(user_id) is not int: return '', 401 u = UserController(user_id) return jsonify({'user': {'firstName': u.user.first_name, 'lastName': u.user.last_name}})
def user_login(): # Get the posted body as a dictionary body = request.get_json() if body is None: return jsonify({'message': 'Invalid request.'}), 400 # Bad request try: username = body['username'] except KeyError: return jsonify({'message': 'The username parameter is missing.'}), 400 # Bad request try: password = body['password'] except KeyError: return jsonify({'message': 'The password parameter is missing.'}), 400 # Bad request try: u = UserController.login(username, password) except UserNotFoundException: return jsonify({'message': 'The username or password is incorrect.'}), 401 # Unauthorized session['user_id'] = u.user.id return jsonify({'user': {'firstName': u.user.first_name, 'lastName': u.user.last_name}})
def post_user(session, currentUser): controller = UserController(session) data = flask.request.get_json() result = controller.post_user(data) return flask.jsonify(result)
def get_users(session, currentUser): controller = UserController(session) users = controller.get_users() return flask.jsonify({'users': users})
def get_users(session, currentUser): controller = UserController(session) users = controller.get_users() return flask.jsonify({'users':users})
def userDataList(): controller = UserController(request) return controller.ListUserData()
from view.user import UserView from controller.user import UserController from model.user import User from controller.persistence import PersistenceController from model.persistence import Persistence from controller.actions import ActionController from model.actions import Action persistence_model = Persistence() persistence = PersistenceController(persistence_model) actions_model = Action(persistence) actions_controller = ActionController(actions_model) user_model = User(persistence, actions_controller) user_controller = UserController(user_model) userview = UserView(user_controller) def welcome(): return input('''Bienvenido, escoje una opción: 1.- Log in 2.- Register s.- Salir ''') option = welcome() if option == '2': userview.register() if option == '1':
def addUserData(): controller = UserController(request) return controller.AddUserData()
from view.user import UserView from controller.user import UserController from model.user import User import json user = User(json) user_controller = UserController(user) user_view = UserView(user_controller) def main(user_view): user_view.show_welcome() main(user_view)
def updateUserData(id): controller = UserController(request) return controller.UpdateUserData(id)
def deleteUserData(id): controller = UserController(request) return controller.DeleteUserData(id)
def getUser(user_code): user = UserController() return user.getUser(user_code)
import cv2 from flask_login import LoginManager, login_user, logout_user, login_required app = Flask(__name__) app.secret_key = os.urandom(97) login_manager = LoginManager() login_manager.init_app(app) db = DataBase(data_base='/home/pi/prod/s-config/config.db') cameraController = CameraController(db=db) communicationController = CommunicationController(db=db) projectController = ProjectController(db=db) userController = UserController(db=db) wifiController = WifiController(db=db) def read_qr(frame): text = '' image = pyzbar.decode(frame) for data in image: text = data.data.decode('utf-8') text = '{}'.format(text) return text