Example #1
0
def credit_card(request):
    user = request.user
    if is_individual_customer(user) and has_credit_card(user):
        return render(request, 'external/credit_card.html',
                      {'credt_card': user.individualcustomer.credit_card})
    elif is_merchant_organization(user) and has_credit_card(user):
        return render(request, 'external/credit_card.html',
                      {'credt_card': user.merchantorganization.credit_card})
    else:
        return render(request, 'external/error.html')
Example #2
0
def savings_account(request):
    user = request.user
    if is_individual_customer(user) and has_savings_account(user):
        return render(
            request, 'external/savings_account.html',
            {'savings_account': user.individualcustomer.savings_account})
    elif is_merchant_organization(user) and has_savings_account(user):
        return render(
            request, 'external/savings_account.html',
            {'savings_account': user.merchantorganization.savings_account})
    else:
        return render(request, 'external/error.html')
Example #3
0
def debit_checking(request):
    user = request.user
    if is_individual_customer(user) and has_checking_account(user):
        return render(
            request, 'external/debit.html', {
                'checking_account': user.individualcustomer.checking_account,
                "account_type": "Checking"
            })
    elif is_merchant_organization(user) and has_checking_account(user):
        return render(
            request, 'external/debit.html', {
                'checking_account': user.merchantorganization.checking_account,
                "account_type": "Checking"
            })
    else:
        return render(request, 'external/error.html')
Example #4
0
def view_external_account(request, external_user_id):
    user = request.user
    permission_codename = 'internal.can_view_external_user_page_' + external_user_id
    permission = Permission.objects.get(
        codename='can_view_external_user_page_' + external_user_id)
    if user.has_perm(permission_codename):
        external_user = User.objects.get(id=int(external_user_id))
        if is_individual_customer(
                external_user) and not has_no_account(external_user):
            return_value = render(
                request, 'internal/view_external_account.html', {
                    'user_type': INDIVIDUAL_CUSTOMER,
                    'first_name': external_user.individualcustomer.first_name,
                    'last_name': external_user.individualcustomer.last_name,
                    'checkingaccount':
                    external_user.individualcustomer.checking_account,
                    'savingsaccount':
                    external_user.individualcustomer.savings_account,
                    'creditcard': external_user.individualcustomer.credit_card
                })
        elif is_merchant_organization(
                external_user) and not has_no_account(external_user):
            return_value = render(
                request, 'internal/view_external_account.html', {
                    'user_type': MERCHANT_ORGANIZATION,
                    'first_name':
                    external_user.merchantorganization.first_name,
                    'last_name': external_user.merchantorganization.last_name,
                    'checkingaccount':
                    external_user.merchantorganization.checking_account,
                    'savingsaccount':
                    external_user.merchantorganization.savings_account,
                    'creditcard':
                    external_user.merchantorganization.credit_card
                })
        else:
            return_value = render(
                request, 'internal/view_external_account.html',
                {'error_message': 'User is not an external user to be viewed'})
        user.user_permissions.remove(permission)
        return return_value
    else:
        return HttpResponseRedirect(reverse('internal:index'))
Example #5
0
def debit_savings_validate(request):
    user = request.user
    type_of_transaction = TRANSACTION_TYPE_DEBIT
    account_type = ACCOUNT_TYPE_SAVINGS
    error_redirect = 'external/error.html'
    success_redirect = 'external/debit.html'
    if is_individual_customer(user) and has_savings_account(user):
        success_payload = {
            'savings_account': user.individualcustomer.savings_account,
            'account_type': account_type
        }
    elif is_merchant_organization(user) and has_savings_account(user):
        success_payload = {
            'savings_account': user.merchantorganization.savings_account,
            'account_type': account_type
        }
    else:
        return render(request, error_redirect)
    return credit_or_debit_validate(request=request,
                                    type_of_transaction=type_of_transaction,
                                    account_type=account_type,
                                    success_payload=success_payload,
                                    success_redirect=success_redirect,
                                    error_redirect=error_redirect)
Example #6
0
def index(request):
    user = request.user
    if is_individual_customer(user) and not has_no_account(user):
        return render(
            request, 'external/index.html', {
                'user_type': INDIVIDUAL_CUSTOMER,
                'first_name': user.individualcustomer.first_name,
                'last_name': user.individualcustomer.last_name,
                'checkingaccount': user.individualcustomer.checking_account,
                'savingsaccount': user.individualcustomer.savings_account,
                'creditcard': user.individualcustomer.credit_card
            })
    elif is_merchant_organization(user) and not has_no_account(user):
        return render(
            request, 'external/index.html', {
                'user_type': MERCHANT_ORGANIZATION,
                'first_name': user.merchantorganization.first_name,
                'last_name': user.merchantorganization.last_name,
                'checkingaccount': user.merchantorganization.checking_account,
                'savingsaccount': user.merchantorganization.savings_account,
                'creditcard': user.merchantorganization.credit_card
            })
    else:
        return render(request, 'external/error.html')