def test_get_team_by_id_or_url_code_bad_url_code_raises_404(self): """ If there is no team with the given url_code, return a 404. """ kwargs = {'url_code': ''} with self.assertRaises(Http404): TaskTeam.get_team_by_id_or_url_code(kwargs)
def test_get_team_by_id_or_url_code_with_url_code(self): """ get_team_by_id_or_url_code should return a team given a url_code """ team = TaskTeamFactory.create() kwargs = {'url_code': team.url_code} eq_(TaskTeam.get_team_by_id_or_url_code(kwargs), team)
def get_queryset(self, *args, **kwargs): qs = super(TeamView, self).get_queryset(*args, **kwargs) return qs.filter(team=TaskTeam.get_team_by_id_or_url_code(self.kwargs))
def get_context_data(self, *args, **kwargs): ctx = super(TeamView, self).get_context_data(*args, **kwargs) ctx['team'] = TaskTeam.get_team_by_id_or_url_code(self.kwargs) ctx['task_list_heading'] = _('%s Tasks' % ctx['team'].name) return ctx