Advertisement
Guest User

Untitled

a guest
May 27th, 2016
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.25 KB | None | 0 0
  1. def bankcreate( requset , info_id = 0 ):
  2.  
  3. print(' -----> id is ' + str(info_id))
  4. errors = []
  5. default = None
  6.  
  7. if info_id is not None and info_id > 0 :
  8. try:
  9. default = BankAccounts.objects.get(id=info_id , user_id=requset.user.id)
  10. except BankAccounts.DoesNotExist :
  11. default = None
  12.  
  13.  
  14. if requset.POST :
  15. VALIDATIONRULES = {} # some rules here
  16. data , errors = validation(requset , VALIDATIONRULES)
  17.  
  18. if not errors :
  19.  
  20. if info_id > 0 and default is not None:
  21. ba = default
  22. else :
  23. ba = BankAccounts()
  24.  
  25. ba.bank_accnumber = data['bank_accnumber']
  26. ba.bank_cartnumber = data['bank_cartnumber']
  27. ba.bank_shabanumber = data['bank_shabanumber']
  28. ba.bank_title = data['bank_title']
  29. ba.user_id = requset.user.id
  30. ba.save()
  31.  
  32. return redirect('account-bank')
  33. else:
  34. default = data
  35.  
  36. return render(requset , 'account/bankcreate-form.html' ,
  37. {'default':default , 'errors':errors} )
  38.  
  39. urlpatterns = [
  40. url(r'^$', views.index , name='account-home'),
  41. url(r'^edit$', views.edit , name='account-edit'),
  42. url(r'^bankinfo', views.bankinfo , name='account-bank'),
  43. url(r'^bankcreate/(?:/(?P<info_id>[1-9]+)/)?', views.bankcreate , name='account-bankcreate'),
  44.  
  45. ]
  46.  
  47. url(r'^bankcreate/(?:/(?P<info_id>[1-9]+)/)?', views.bankcreate , name='account-bankcreate'),
  48.  
  49. http://localhost:8000/account/bankcreate/1/
  50.  
  51. url(r'^bankcreate/(?:/(?P<info_id>[1-9]+)/)?/$'
  52.  
  53. url(r'^bankcreate/(?:/(?P<info_id>[1-9]+)/)?$'
  54.  
  55. Page not found (404)
  56. Request Method: GET
  57. Request URL: http://localhost:8000/account/bankcreate/1/
  58.  
  59. Using the URLconf defined in paypal.urls, Django tried these URL patterns, in this order:
  60.  
  61. ^$
  62. ^admin/
  63. ^account/ ^$ [name='account-home']
  64. ^account/ ^edit$ [name='account-edit']
  65. ^account/ ^email [name='account-email']
  66. ^account/ ^bankinfo [name='account-bank']
  67. ^account/ ^bankcreate/(?:/(?P<info_id>[1-9]+)/)?$ [name='account-bankcreate']
  68. ^account/ ^password [name='account-password']
  69. ^gateway/
  70. ^auth/
  71.  
  72. The current URL, account/bankcreate/1/, didn't match any of these.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement