def create_admins(): users = User.query() for user in users: admin = Admin(id=user.key.id(), admin_id=user.key.id()) admin.put() return "Admin Created"
def find_user(self,username,password): if not username or not self.usernameregex.match(username) or not password or not self.passwordregex.match(password): return None query_result = User.query(User.username == username).fetch(1) if len(query_result)==0: return None user = query_result[0] password_input = hashlib.sha256(password).hexdigest() if not user.hashed_password == password_input: return None return user.key.id()
def post(self): self.response.headers['Content-Type'] = 'application/json; charset=utf-8' counter = 0 userlist = json.loads(self.request.body, object_hook=as_user) self.response.write('[') for u in userlist: for p in u.phones: usr = User.query(User.hash == p).get() if usr is not None: if counter > 0: self.response.write(',') self.response.write(print_user(u.lookup_key, usr)) counter += 1 self.response.write(']')
def get(self, phoneHash): self.response.write('Requested phone hash is :\"'+ escape(phoneHash) +'\"\n') user = User.query(User.hash == escape(phoneHash)).get() self.response.headers['Content-Type'] = 'application/json; charset=utf-8' self.response.write(user.to_json())