def do_sign_up(self): user_name = self.get_argument("user") password = self.get_argument("password") password1 = self.get_argument("password1") if password != password1: self.redirect(self.url) # dont create a user if len(User.all() ) == 0: # automatically activate the first user who registers auto_activate = True else: auto_activate = False user = User(name=user_name, password=hash_password(password)) if auto_activate: user.activation_timestamp = time.time() user.save() self.redirect(self.url) # to login
def get( self ): ## Make sure the user is logged in if not self.user: self.redirect( "/login" ) return ## Query out the other users all_users = User.all().order( "-name" ).fetch( limit = 100 ) all_users = list( all_users ) ## Define a UserItem as a name and id UserItem = namedtuple( "UserItem", [ "name", "id" ] ) users = [] for user in all_users: if user.name != self.user.name: users.append( UserItem( user.name, user.key().id() ) ) self.render( "new-challenge.html", users = users )