def post(self): args = parser.parse_args() password = args.get('password') username = args.get('username') name = args.get('name') logging.debug("sign up {}".format(username)) people = People.getbyusername(username) if people: logging.debug("username already taken") raise UserAlreadyExistsError else: people = People.create(name, username) people.get().genpass(password) user = User.get(username) if user is None: user = User.get(username) logging.warning("User get retry") if user is not None: login_user(user, remember=True) else: logging.warning("Still not found") return { 'id': people.id(), "username": username, "name": name, "admin": False }
def post(self): logging.debug("creating people") args = parser.parse_args() people_details = args if People.getbyusername(args.get('username')): logging.warning("Username already taken") raise UserAlreadyExistsError else: people = People.create(args.get('name'), args.get('username')) people.get().genpass(args.get('password')) people_details['id'] = people.id() return {'people': people_details}
def get(self): people = People.getall() for person in people: person.__setattr__('id', person.key.id()) logging.debug(people) return {"people": people}
def get(self, match_id, people_id): match = Match.getone(match_id) if match is None: raise MatchNotExistsError people = People.getone(people_id) if people.key in match.registerdPeople: return {"in": True} else: return {"in": False}
def post(self): args = password_parser.parse_args() password = args.get('password') username = args.get('email') people = People.getbyusername(username) if people: people.genpass(password) else: raise PeopleNotExistsError return True
def __init__(self, username): logging.debug("Login {}".format(username)) people = People.getbyusername(username) if not people: raise UserNotFoundError self.username = username self.name = people.name self.id = people.username self.key_id = people.key.id() self.password = people.password
def post(self): args = parser.parse_args() password = args.get('password') username = args.get('username') name = args.get('name') logging.debug("sign up {}".format(username)) people = People.getbyusername(username) if people: logging.debug("username already taken") raise UserAlreadyExistsError else: people = People.create(name, username) people.get().genpass(password) user = User.get(username) if user is None: user = User.get(username) logging.warning("User get retry") if user is not None: login_user(user, remember=True) else: logging.warning("Still not found") return {'id': people.id(), "username": username, "name": name, "admin": False}
def askforleave(cls, match_id, status): match = Match.getone(match_id) people = People.getone(current_user.key_id) if people and people.key in match.registerdPeople: logging.debug("You have already signed up! Now switch leave") play = Play.getbyMatchPeople(match_id, current_user.key_id) if play: play.leave = status play.put() elif people and people.key: match.signup(current_user.key_id) Play.create(current_user.key_id, match_id, leave=status) memcache.flush_all() return True
def signup(cls, match_id, code): match = Match.getone(match_id) people = People.getone(current_user.key_id) if people and people.key in match.registerdPeople: logging.debug("You have already signed up") return True if match and code == match.signupCode: logging.debug("Sign up user {}".format(current_user.key_id)) match.signup(current_user.key_id) Play.create(current_user.key_id, match_id) memcache.flush_all() return True return False
def post(self): args = update_parser.parse_args() name = args.get('name') password = args.get('password') position = args.get('position') logging.debug("update name {} and password {}".format(name.encode('utf-8'), password)) if name: me = People.getone(current_user.key_id) me.name = name me.position = position if password != 'itissecret': me.genpass(password) me.put() return {"status": True}
def post(self): args = update_parser.parse_args() name = args.get('name') password = args.get('password') position = args.get('position') logging.debug("update name {} and password {}".format( name.encode('utf-8'), password)) if name: me = People.getone(current_user.key_id) me.name = name me.position = position if password != 'itissecret': me.genpass(password) me.put() return {"status": True}
def post(self): args = parser.parse_args() password = args.get('password') username = args.get('username') login_status = False people = None if username and password: people = People.getbyusername(username) login_status = True if people and people.validpassword(password) else False if login_status: login_user(User.get(username), remember=True) if not login_status: raise InvalidLoginError return {"username": username, "name": people.name, "position": people.position,"admin": people.admin, "id": people.key.id()}
def signin(cls, match_id, code): match = Match.getone(match_id) if datetime.now() < match.signinEarliest: logging.debug("You are too early for sign in") return {"status": False, "reason": "You are too early for sign in", "code": -1} if datetime.now() > match.signinLatest: logging.debug("You are too late for sign in") logging.debug("Sign in user {}".format(current_user.key_id)) match.signin(current_user.key_id) play = Play.getbyMatchPeople(match_id, current_user.key_id) if play is None: logging.debug("this guy didn't sign up, but is sign-in now") match.signup(current_user.key_id) Play.create(current_user.key_id, match_id, missing=True) else: play.signinTime = datetime.now() play.put() memcache.flush_all() return {"status": False, "reason": "You are too late for sign in", "code": 1} people = People.getone(current_user.key_id) if people and people.key in match.participatedPeople: logging.debug("You have already signed in") return {"status": False, "reason": "You have already signed in", "code": 0} if match and code == match.signinCode: logging.debug("Sign in user {}".format(current_user.key_id)) match.signin(current_user.key_id) play = Play.getbyMatchPeople(match_id, current_user.key_id) if play is None: logging.debug("this guy didn't sign up, but is sign-in now") match.signup(current_user.key_id) Play.create(current_user.key_id, match_id, missing=True) else: play.signinTime = datetime.now() play.put() memcache.flush_all() return {"status": True} return {"status": False}
def post(self): args = parser.parse_args() password = args.get('password') username = args.get('username') login_status = False people = None if username and password: people = People.getbyusername(username) login_status = True if people and people.validpassword( password) else False if login_status: login_user(User.get(username), remember=True) if not login_status: raise InvalidLoginError return { "username": username, "name": people.name, "position": people.position, "admin": people.admin, "id": people.key.id() }
def get(self): me = People.getone(current_user.key_id) me.password = '******' return me
def get(self, people_id): people = People.getone(people_id) people.__setattr__('id', people_id) return {"people": people}