def password(request): username = request.session.get('ID', default=None) res = functions.checkLogin(username) if(res == 0): status = "Normal" if(res == -1): status = "Overtime" if(res == -2): status = "Frozen" return render(request, 'TransactionClient_password.html', {'username': username, 'status': status})
def possessed(request): username = request.session.get('ID', default=None) resf = functions.checkLogin(username) if(resf == 0): status = "Normal" if(resf == -1): status = "Overtime" if(resf == -2): status = "Frozen" PossessedList = functions.checkPossessedStock(username) return render(request, 'TransactionClient_possessed.html',{'PossessedList': PossessedList, 'username': username, 'status': status})
def capital(request): username = request.session.get('ID', default=None) resf = functions.checkLogin(username) if(resf == 0): status = "Normal" if(resf == -1): status = "Overtime" if(resf == -2): status = "Frozen" response = HttpResponse() res = functions.checkCapitalInfo(username) if(res[0] == -1): stock_value = "Error" balance = "Error" if(res[0] != -1): stock_value = res[0] balance = res[1] return render(request, 'TransactionClient_capital.html',{'stock_value':stock_value, 'balance': balance, 'username': username, 'status': status})
def transaction(request): username = request.session.get('ID', default=None) resf = functions.checkLogin(username) if(resf == 0): status = "Normal" if(resf == -1): status = "Overtime" if(resf == -2): status = "Frozen" if not request.POST.has_key("search"): return render(request, 'TransactionClient_transaction.html', {'username': username, 'status': status}) search_method = request.POST["search"] if(search_method == "date"): startYear = request.POST["begin_year"] startMonth = request.POST["begin_month"] startDay = request.POST["begin_day"] endYear = request.POST["end_year"] endMonth = request.POST["end_month"] endDay = request.POST["end_day"] if(startYear==u'' or startMonth==u'' or startDay==u'' or endDay==u'' or endYear==u'' or endMonth==u''): return render(request, 'TransactionClient_transaction.html', {'username': username, 'status': status}) startDate = datetime.date(int(startYear), int(startMonth), int(startDay)) endDate = datetime.date(int(endYear), int(endMonth), int(endDay)) TransactionList = functions.getRecordByDate(startDate, endDate, username) return render(request, 'TransactionClient_transaction.html', {'username': username, 'status': status, 'TransactionList': TransactionList}) if(search_method == "stock"): StockID = request.POST["ticker"] TransactionList = functions.getRecordByStock(StockID, username) response = HttpResponse({'TransactionList': TransactionList}) # print StockID # print TransactionList return render(request, 'TransactionClient_transaction.html', {'username': username, 'status': status, 'TransactionList': TransactionList}) reaponse = HttpResponse() response.write('<html><script type="text/javascript">;window.location="/TransactionClient/transaction/"</script></html>') return response