Duplicate solutions from regional tournament to final tournament after selection
Signed-off-by: Emmy D'Anello <emmy.danello@animath.fr>
This commit is contained in:
parent
b4fc976197
commit
7073f64aa6
|
@ -1561,7 +1561,7 @@ class Tweak(models.Model):
|
||||||
|
|
||||||
def get_solution_filename(instance, filename):
|
def get_solution_filename(instance, filename):
|
||||||
return f"solutions/{instance.participation.team.trigram}_{instance.problem}" \
|
return f"solutions/{instance.participation.team.trigram}_{instance.problem}" \
|
||||||
+ ("final" if instance.final_solution else "")
|
+ ("_final" if instance.final_solution else "")
|
||||||
|
|
||||||
|
|
||||||
def get_synthesis_filename(instance, filename):
|
def get_synthesis_filename(instance, filename):
|
||||||
|
|
|
@ -850,6 +850,12 @@ class SelectTeamFinalView(VolunteerMixin, DetailView):
|
||||||
tournament = self.get_object()
|
tournament = self.get_object()
|
||||||
self.participation.final = True
|
self.participation.final = True
|
||||||
self.participation.save()
|
self.participation.save()
|
||||||
|
for regional_sol in self.participation.solutions.filter(final_solution=False).all():
|
||||||
|
final_sol, _created = Solution.objects.get_or_create(participation=self.participation, final_solution=True,
|
||||||
|
problem=regional_sol.problem)
|
||||||
|
final_sol: Solution
|
||||||
|
with open(regional_sol.file.path, 'rb') as f:
|
||||||
|
final_sol.file.save(regional_sol.file.name, f)
|
||||||
return redirect(reverse_lazy("participation:tournament_detail", args=(tournament.pk,)))
|
return redirect(reverse_lazy("participation:tournament_detail", args=(tournament.pk,)))
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -129,7 +129,7 @@ class VolunteerRegistrationAdmin(PolymorphicChildModelAdmin):
|
||||||
|
|
||||||
@admin.register(Payment)
|
@admin.register(Payment)
|
||||||
class PaymentAdmin(ModelAdmin):
|
class PaymentAdmin(ModelAdmin):
|
||||||
list_display = ('concerned_people', 'tournament', 'team', 'grouped', 'type', 'amount', 'valid', )
|
list_display = ('concerned_people', 'tournament', 'team', 'grouped', 'type', 'amount', 'final', 'valid', )
|
||||||
search_fields = ('registrations__user__last_name', 'registrations__user__first_name', 'registrations__user__email',
|
search_fields = ('registrations__user__last_name', 'registrations__user__first_name', 'registrations__user__email',
|
||||||
'registrations__team__name', 'registrations__team__participation__team__trigram',)
|
'registrations__team__name', 'registrations__team__participation__team__trigram',)
|
||||||
list_filter = ('registrations__team__participation__valid', 'type',
|
list_filter = ('registrations__team__participation__valid', 'type',
|
||||||
|
|
Loading…
Reference in New Issue