restore quantity display on expanded card_badges and add limits to all trade offer creation (currently 20 unique cards per side, 20 max quantity per card), fixes #3 and fixes #17
This commit is contained in:
parent
1cdeaa9bba
commit
b5db5af185
4 changed files with 49 additions and 10 deletions
|
|
@ -610,7 +610,7 @@ class TradeOfferCreateConfirmView(LoginRequiredMixin, View):
|
|||
}
|
||||
return render(request, "trades/trade_offer_create.html", context)
|
||||
messages.success(request, "Trade offer created successfully!")
|
||||
return HttpResponseRedirect(reverse_lazy("trade_offer_list"))
|
||||
return HttpResponseRedirect(reverse_lazy("trade_offer_detail", kwargs={"pk": trade_offer.pk}))
|
||||
else:
|
||||
# When the form is not valid, update its initial data as well:
|
||||
form.initial = {
|
||||
|
|
@ -641,14 +641,24 @@ class TradeOfferCreateConfirmView(LoginRequiredMixin, View):
|
|||
return HttpResponseRedirect(url_with_params)
|
||||
|
||||
def _preview_offer(self, request):
|
||||
"""
|
||||
Processes the preview action (existing logic remains unchanged).
|
||||
"""
|
||||
form = TradeOfferCreateForm(request.POST)
|
||||
form.fields["initiated_by"].queryset = request.user.friend_codes.all()
|
||||
if not form.is_valid():
|
||||
# Re-render the creation template with errors.
|
||||
return render(request, "trades/trade_offer_create.html", {"form": form})
|
||||
# Set initial values required by the template.
|
||||
form.initial = {
|
||||
"have_cards": request.POST.getlist("have_cards"),
|
||||
"want_cards": request.POST.getlist("want_cards"),
|
||||
"initiated_by": request.POST.get("initiated_by"),
|
||||
}
|
||||
from cards.models import Card
|
||||
context = {
|
||||
"form": form,
|
||||
"friend_codes": request.user.friend_codes.all(),
|
||||
"selected_friend_code": request.user.default_friend_code or request.user.friend_codes.first(),
|
||||
"cards": Card.objects.all().order_by("name", "rarity_level"),
|
||||
}
|
||||
return render(request, "trades/trade_offer_create.html", context)
|
||||
|
||||
|
||||
# Parse the card selections for "have" and "want" cards.
|
||||
have_selections = self._parse_card_selections("have_cards")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue