Skip to content

Commit cbd4aa2

Browse files
Aiq0gardenerik
andcommitted
fix: competition creation
Co-authored-by: Adam Zahradník <[email protected]>
1 parent 1be1230 commit cbd4aa2

File tree

3 files changed

+24
-6
lines changed

3 files changed

+24
-6
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,12 @@
33
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
44
and this project uses the `YYYY.N` version format.
55

6+
## 2025.18 - 2025-07-10
7+
8+
### Fixed
9+
10+
- Fixed competition creation.
11+
612
## 2025.17 - 2025-06-18
713

814
### Fixed

bullet/bullet_admin/forms/competition.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,14 @@ class Meta:
3838
"competition_start": forms.DateTimeInput(attrs={"type": "datetime"}),
3939
}
4040

41+
def __init__(self, branch, **kwargs):
42+
self.branch = branch
43+
super().__init__(**kwargs)
44+
4145
def save(self, commit: bool = True):
42-
obj = super().save(commit=True)
46+
obj = super()
47+
obj.branch = self.branch
48+
obj.save(commit=True)
4349

4450
current_problems = Problem.objects.filter(competition=obj)
4551
current_count = current_problems.count()

bullet/bullet_admin/views/competition.py

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,17 +35,23 @@ def get_object(self, queryset=None):
3535
def get_success_url(self):
3636
return reverse("badmin:competition_switch")
3737

38+
def get_form_kwargs(self):
39+
kwargs = super().get_form_kwargs()
40+
kwargs["branch"] = self.request.BRANCH
41+
return kwargs
42+
3843

3944
class CompetitionCreateView(BranchAdminAccess, GenericForm, CreateView):
4045
form_class = CompetitionForm
4146
form_title = "New competition"
4247

43-
def form_valid(self, form):
44-
competition: Competition = form.save(commit=False)
45-
competition.branch = self.request.BRANCH
46-
competition.save()
48+
def get_success_url(self):
49+
return reverse("badmin:competition_switch")
4750

48-
return redirect("badmin:competition_switch")
51+
def get_form_kwargs(self):
52+
kwargs = super().get_form_kwargs()
53+
kwargs["branch"] = self.request.BRANCH
54+
return kwargs
4955

5056

5157
class CompetitionFinalizeView(UnlockedCompetitionMixin, BranchAdminAccess, FormView):

0 commit comments

Comments
 (0)