Skip to content

Commit

Permalink
[Fix] multiple category edit
Browse files Browse the repository at this point in the history
  • Loading branch information
Minigrim0 committed Apr 13, 2021
1 parent c165f9e commit b39cc1b
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions ctf/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,18 +32,15 @@ def challenges(request, ctf_id):

@login_required
def edit_chall(request, ctf_id, chall_id):

challenge = get_object_or_404(Challenge, id=chall_id)
if request.method == "POST":
form = ChallengeForm(request.POST)
form = ChallengeForm(request.POST, instance=challenge)
if form.is_valid:
challenge = Challenge.objects.get(id=chall_id)
challenge.name = request.POST['name']
challenge.points = request.POST['points']
challenge.description = request.POST['description']
challenge.category.set(request.POST['category'])
challenge.save()
challenge = form.save()
return HttpResponseRedirect(reverse("chal", kwargs={"ctf_id": ctf_id}))

form = ChallengeForm(instance=Challenge.objects.get(id=chall_id))
form = ChallengeForm(instance=challenge)
context = {
"EditChallenge": form,
"ctf_id": ctf_id,
Expand Down

0 comments on commit b39cc1b

Please sign in to comment.