@login_required
def upgrade_account(request, acc_type):
 user = request.user
 bill = None
 try:
  bill = user.bill
 except:
  bill = Bill(user=user)
 bill.upgrade_type = acc_type
 bill.save()
 tn = bill.pk
 if (acc_type == 'bronze'):
  url = create_partner_trade_by_buyer(tn, u'ikindle\u6742\u5fd7\u8ba2\u9605(4\u4efd)', u'\u8ba2\u9605\u6742\u5fd7\u5230\u4f60\u7684Kindle\uff0c 2.99x6\u4e2a\u6708', '0.01')
  return HttpResponseRedirect(url)
 elif (acc_type == 'silver'):
  url = create_partner_trade_by_buyer(tn, u'ikindle\u6742\u5fd7\u8ba2\u9605(6\u4efd)', u'\u8ba2\u9605\u6742\u5fd7\u5230\u4f60\u7684Kindle\uff0c3.99x6\u4e2a\u6708', '0.01')
  return HttpResponseRedirect(url)
 elif (acc_type == 'gold'):
  url = create_partner_trade_by_buyer(tn, u'ikindle\u6742\u5fd7\u8ba2\u9605(\u65e0\u9650\u5236)', u'\u8ba2\u9605\u6742\u5fd7\u5230\u4f60\u7684Kindle\uff0c5.99x6\u4e2a\u6708', '0.01')
  return HttpResponseRedirect(url)
 else:
  return HttpResponseRedirect(reverse('payment_error'))

@ login_required def upgrade_account ( request , acc_type ) : user = request . user bill = None try : bill = user . bill except : bill = Bill ( user = user ) bill . upgrade_type = acc_type bill . save ( ) tn = bill . pk if ( acc_type == 'bronze' ) : url = create_partner_trade_by_buyer ( tn , u'ikindle\u6742\u5fd7\u8ba2\u9605(4\u4efd)' , u'\u8ba2\u9605\u6742\u5fd7\u5230\u4f60\u7684Kindle\uff0c 2.99x6\u4e2a\u6708' , '0.01' ) return HttpResponseRedirect ( url ) elif ( acc_type == 'silver' ) : url = create_partner_trade_by_buyer ( tn , u'ikindle\u6742\u5fd7\u8ba2\u9605(6\u4efd)' , u'\u8ba2\u9605\u6742\u5fd7\u5230\u4f60\u7684Kindle\uff0c3.99x6\u4e2a\u6708' , '0.01' ) return HttpResponseRedirect ( url ) elif ( acc_type == 'gold' ) : url = create_partner_trade_by_buyer ( tn , u'ikindle\u6742\u5fd7\u8ba2\u9605(\u65e0\u9650\u5236)' , u'\u8ba2\u9605\u6742\u5fd7\u5230\u4f60\u7684Kindle\uff0c5.99x6\u4e2a\u6708' , '0.01' ) return HttpResponseRedirect ( url ) else : return HttpResponseRedirect ( reverse ( 'payment_error' ) )
request for upgrade account to acc_type .