bank account existance exception
This commit is contained in:
@@ -5,7 +5,7 @@ from django.db.models import Q
|
||||
from rest_framework import serializers
|
||||
|
||||
from apps.authentication.exceptions import UserExistException, OrganizationNationalUniqueIDException, \
|
||||
OrganizationTypeRepeatableException
|
||||
OrganizationTypeRepeatableException, BankAccountExistException
|
||||
from apps.authentication.models import (
|
||||
User,
|
||||
City,
|
||||
@@ -51,6 +51,14 @@ class BankAccountSerializer(serializers.ModelSerializer):
|
||||
model = BankAccountInformation
|
||||
fields = '__all__'
|
||||
|
||||
def validate(self, attrs):
|
||||
account = attrs['account']
|
||||
card = attrs['card']
|
||||
sheba = attrs['sheba']
|
||||
|
||||
if self.Meta.model.objects.filter(Q(account=account) | Q(card=card) | Q(sheba=sheba)).exists():
|
||||
raise BankAccountExistException()
|
||||
|
||||
def update(self, instance, validated_data):
|
||||
""" update user bank account information """
|
||||
instance.name = validated_data.get('name', instance.name)
|
||||
|
||||
Reference in New Issue
Block a user