def _team_creation(request): form = TeamForm(request.POST) if form.is_valid(): team = form.save() info_msg(request, u"Equipe ajoutée avec succès.") return redirect('team_index') else: return render(request, 'team/form.html', {'form': form})
def _team_creation(request): form = TeamForm(request.POST) if form.is_valid(): form.save() info_msg(request, u"Equipe ajoutée avec succès.") return redirect('team:index') else: return render(request, 'team/form.html',{ 'form': form })
def _team_update(request, team): form = TeamForm(instance = team, data = request.POST) if form.is_valid(): form.save() if "name" in form.changed_data: for budget in team.budget_set.filter(is_active = True): budget.update_budgetlines() # Will update bl.team info_msg(request, u"Equipe modifiée avec succès.") return redirect('team:index') else: return render(request, 'team/item.html',{ 'team': team, 'form': form })
def _team_update(request, team): form = TeamForm(instance=team, data=request.POST) name_before = team.name if form.is_valid(): team = form.save() if name_before != team.name: for budget in team.budget_set.all(): budget.update_budgetlines() # Will update bl.team for history in History.objects.filter(team=name_before): history.team = team.name history.save() info_msg(request, u"Equipe modifiée avec succès.") return redirect('team_index') else: return render(request, 'team/item.html', {'team': team, 'form': form})
def _team_update(request, team): form = TeamForm(instance = team, data = request.POST) name_before = team.name if form.is_valid(): team = form.save() if name_before != team.name: for budget in team.budget_set.all(): budget.update_budgetlines() # Will update bl.team for history in History.objects.filter( team = name_before ): history.team = team.name history.save() info_msg( request, u"Equipe modifiée avec succès." ) return redirect( 'team_index' ) else: return render(request, 'team/item.html',{ 'team': team, 'form': form })
def _team_detail(request, team): form = TeamForm(instance=team) return render(request, 'team/item.html', {'team': team, 'form': form})
def new(request): return render(request, 'team/form.html', {'form': TeamForm()})
def test_form_validation_for_duplicate_team_names(self): Team.objects.create(team_name='Test') form = TeamForm({'team_name': 'Test'}) self.assertFalse(form.is_valid())