def create_gym(handler, name): user = service_util.get_or_create_user(users.get_current_user()) gym = Gym(name=name) gym.put() membership = GymMembership(parent=gym, gym=gym, user=user, owner=True) membership.put() return dict(group=group)
def post(self): user = users.get_current_user() if user: climber = Climber.from_appengine_user(user) gym = Gym() gym.name = self.request.get('name') gym.put() membership = GymMembership() membership.climber = climber membership.user = user membership.gym = gym membership.owner = True membership.put() context = { 'gym_name': gym.name, 'error': False} else: context = {'error': 'log in to create a gym!'} tmpl = path.join(path.dirname(__file__), 'static/html/addgymresult.html') self.response.out.write(render(tmpl, context))