def post(self, team_id): ''' Validates and updates the team. Redirects to the new team if successful. :param team_id: int ''' team = Team.get(id_=team_id) if not team: self.error(404, 'Team not found') form = forms.Team(self.request.arguments) if form.validate(): Team.update( id_=team_id, name=form.name.data, ) self.redirect('/team/{}'.format(team.id)) return self.render( 'team.html', title='New team', form=form, edit=True, users=Users.get(), team=team, members=Users_team.get(team_id=team_id), )
def test_update(self): team = self.new_team() Team.update( id_=team.id, name='Test 2' ) team = Team.get(id_=team.id) self.assertEqual(team.name, u'Test 2')
def get(self, team_id): ''' Renders the edit team form. :param team_id: int ''' team = Team.get(id_=team_id) if not team: self.error(404, 'Team not found') form = forms.Team() form.name.data = team.name self.render( 'team.html', title=u'Team: {}'.format(team.name), form=form, edit=True, users=Users.get(), team=team, members=Users_team.get(team_id=team_id), )
def test_update(self): team = self.new_team() Team.update(id_=team.id, name='Test 2') team = Team.get(id_=team.id) self.assertEqual(team.name, u'Test 2')
def test_get(self): team = self.new_team() team = Team.get(id_=team.id) self.assertTeam(team)