Exemplo n.º 1
0
 def get(self, *args, **kwargs):
     self.init_args()
     if self.team_name:
         self.formset = TeamDaterangeFormSet(
             queryset=self.team.dateranges.order_by('start'),
         )
     return super(Teams, self).get(*args, **kwargs)
Exemplo n.º 2
0
 def post(self, *args, **kwargs):
     self.init_args()
     if self.team:
         self.formset = TeamDaterangeFormSet(
             self.request.POST,
             queryset=self.team.dateranges.order_by('start'),
         )
         for form in self.formset.extra_forms:
             if form.has_changed():
                 form.instance.team = self.team
         if self.formset.is_valid():
             self.formset.save()
             messages.success(self.request, "Teams dateranges updated.")
             return HttpResponseRedirect(self.request.path)
         else:
             messages.error(self.request, "Please fix the errors.")
     return super(Teams, self).get(*args, **kwargs)