def post(self): logging.info('newAchievement posted') #Get the current Cheever's profile so we can update their numContribs cheever_key = ndb.Key('Cheever', self.user.email()) cheever = cheever_key.get() if not cheever: #Profile doesn't yet exist, create a new Cheever with default values cheever = models.Cheever(key=ndb.Key("Cheever",self.user.email())) #Create new achievement with auto-generated key achievement = models.Achievement() achievement.populate( title=self.request.get('title'), description=self.request.get('description'), category=self.request.get('category'), score=int(self.request.get('score')), contributor=cheever.username, verified=True ) cheever.numContribs += 1 #Commit our updates to the datastore achievement.put() cheever.put() self.redirect('/profile')
def get(self): for x in range(1, 50): a = models.Achievement() a.populate(title='Test Achievement ' + str(x), description='Test Achievement ' + str(x), category='Test', score=random.randint(50, 250), contributor='Test' + str(x % 3), verified=True) a.put()