Make sure number of membership months is entered.

This commit is contained in:
Tanner Collin 2022-08-29 03:18:43 +00:00
parent 24a0f37faa
commit 6a3ce847d6

View File

@ -93,6 +93,9 @@ class TransactionSerializer(serializers.ModelSerializer):
if validated_data['category'] != 'Membership': if validated_data['category'] != 'Membership':
validated_data['number_of_membership_months'] = 0 validated_data['number_of_membership_months'] = 0
if validated_data['category'] == 'Membership' and not validated_data['number_of_membership_months']:
raise ValidationError(dict(number_of_membership_months='This field is required.'))
if validated_data['account_type'] == 'Protocoin' and validated_data['category'] == 'Exchange': if validated_data['account_type'] == 'Protocoin' and validated_data['category'] == 'Exchange':
raise ValidationError(dict(category='Can\'t purchase Protocoin with Protocoin.')) raise ValidationError(dict(category='Can\'t purchase Protocoin with Protocoin.'))