def getAccountFormByGroup(request, group): # Get the user object user = request.user # Create different form w.r.t. different group if (group == AccountGroup.GROUP_FINANCIAL_INSTITUTION) or (group == AccountGroup.GROUP_DEPOSIT_MONEY): template = loader.get_template('client/profile_select_account_type_form.html') context = { 'form': AccountTypesForm(user=user, group=group), 'group': group, } content = template.render(context, request) return content
def showDepositAccountForm(request): if (request.method != 'POST') or (not request.is_ajax()): raise Http404("Page not found.") # Get the user object client = request.user group = getAccountGroup(request.session) print("showDepositAccountForm: ", request.POST) depositAccountGroupForm = AccountTypesForm(request.POST, user=client, group=group) if depositAccountGroupForm.is_valid(): # Get the account group type type = depositAccountGroupForm.cleaned_data['group_type'] typeObj = AccountType.objects.get(name=type) groupObj = AccountGroup.objects.get(name=group) groupType = AccountGroupType.objects.get(group=groupObj, type=typeObj) # Save account group type into current session setAccountType(session=request.session, type=type) setAccountGroupType(session=request.session, groupType=groupType) setAccountStep(session=request.session, step=ACCOUNT_STEP_ACCOUNT_GROUP_TYPE) accountForm = getAccountFormByGroupAndGroupType(request=request, group=group, groupType=groupType) # Prepare the JSON response for AJAX request data = {'status': 'success', 'form': accountForm} return JsonResponse(data) return JsonResponse({ 'status': 'error', })
def registration4(request): # Get the user object client = request.user print("step4,user------", client) group = getAccountGroup(request.session) print("showDepositAccountForm: ",request.POST) depositAccountGroupForm = AccountTypesForm(request.POST, user=client, group=group) if depositAccountGroupForm.is_valid(): # Get the account group type type = depositAccountGroupForm.cleaned_data['group_type'] typeObj = AccountType.objects.get(name=type) groupObj = AccountGroup.objects.get(name=group) groupType = AccountGroupType.objects.get(group=groupObj, type=typeObj) # Save account group type into current session setAccountType(session=request.session, type=type) setAccountGroupType(session=request.session, groupType=groupType) setAccountStep(session=request.session, step=ACCOUNT_STEP_ACCOUNT_GROUP_TYPE) accountForm = getAccountFormByGroupAndGroupType(request=request, group=group, groupType=groupType) # Prepare the JSON response for AJAX request data = { 'status': 'success', 'form': accountForm } print("the forth step is ok") return JsonResponse(data) return JsonResponse( { 'status': 'error', } )