Fix friend_code max length issues in tests, and fix in_game_name length issues, also update tests to fit more scenarios
This commit is contained in:
parent
0d4655bf80
commit
b9c4d7a61d
10 changed files with 558 additions and 66 deletions
|
|
@ -254,12 +254,12 @@ class TradeAcceptance(models.Model):
|
|||
def clean(self):
|
||||
# Validate that the requested and offered cards exist in the through tables.
|
||||
try:
|
||||
have_through_obj = self.trade_offer.trade_offer_have_cards.get(card=self.requested_card)
|
||||
have_through_obj = self.trade_offer.trade_offer_have_cards.get(card_id=self.requested_card_id)
|
||||
except TradeOfferHaveCard.DoesNotExist:
|
||||
raise ValidationError("The requested card must be one of the trade offer's available cards (have_cards).")
|
||||
|
||||
try:
|
||||
want_through_obj = self.trade_offer.trade_offer_want_cards.get(card=self.offered_card)
|
||||
want_through_obj = self.trade_offer.trade_offer_want_cards.get(card_id=self.offered_card_id)
|
||||
except TradeOfferWantCard.DoesNotExist:
|
||||
raise ValidationError("The offered card must be one of the trade offer's requested cards (want_cards).")
|
||||
|
||||
|
|
@ -279,11 +279,11 @@ class TradeAcceptance(models.Model):
|
|||
if self.pk:
|
||||
active_acceptances = active_acceptances.exclude(pk=self.pk)
|
||||
|
||||
requested_count = active_acceptances.filter(requested_card=self.requested_card).count()
|
||||
requested_count = active_acceptances.filter(requested_card_id=self.requested_card_id).count()
|
||||
if requested_count >= have_through_obj.quantity:
|
||||
raise ValidationError("This requested card has been fully accepted.")
|
||||
|
||||
offered_count = active_acceptances.filter(offered_card=self.offered_card).count()
|
||||
offered_count = active_acceptances.filter(offered_card_id=self.offered_card_id).count()
|
||||
if offered_count >= want_through_obj.quantity:
|
||||
raise ValidationError("This offered card has already been fully used.")
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue