コード例 #1
0
ファイル: views.py プロジェクト: nnmware/nnmware
 def form_valid(self, form):
     if not self.request.user.is_authenticated():
         return super(RegisterUserAddOrderView, self).form_invalid(form)
     basket = get_basket(self.request)
     if basket.count() < 1:
         return super(RegisterUserAddOrderView, self).form_invalid(form)
     addr = self.request.POST.get('addr')
     address = DeliveryAddress.objects.get(user=self.request.user, pk=int(addr))
     self.object = form.save(commit=False)
     self.object.address = str(address)
     self.object.ip = self.request.META['REMOTE_ADDR']
     self.object.user_agent = self.request.META['HTTP_USER_AGENT']
     self.object.status = STATUS_WAIT
     self.object.lite = False
     self.object.first_name = address.first_name
     self.object.middle_name = address.middle_name
     self.object.last_name = address.last_name
     self.object.phone = address.phone
     self.object.email = self.request.user.email
     self.object.user = self.request.user
     self.object.save()
     success_add_items = make_order_from_basket(self.object, basket)
     if success_add_items is not True:
         self.object.delete()
         return super(RegisterUserAddOrderView, self).form_invalid(form)
     send_new_order_seller(self.object)
     send_new_order_buyer(self.object, [self.request.user.email])
     return super(RegisterUserAddOrderView, self).form_valid(form)
コード例 #2
0
 def form_valid(self, form):
     if not self.request.user.is_authenticated():
         return super(RegisterUserAddOrderView, self).form_invalid(form)
     basket = get_basket(self.request)
     if basket.count() < 1:
         return super(RegisterUserAddOrderView, self).form_invalid(form)
     addr = self.request.POST.get('addr')
     address = DeliveryAddress.objects.get(user=self.request.user,
                                           pk=int(addr))
     self.object = form.save(commit=False)
     self.object.address = str(address)
     self.object.ip = self.request.META['REMOTE_ADDR']
     self.object.user_agent = self.request.META['HTTP_USER_AGENT']
     self.object.status = STATUS_WAIT
     self.object.lite = False
     self.object.first_name = address.first_name
     self.object.middle_name = address.middle_name
     self.object.last_name = address.last_name
     self.object.phone = address.phone
     self.object.email = self.request.user.email
     self.object.user = self.request.user
     self.object.save()
     success_add_items = make_order_from_basket(self.object, basket)
     if success_add_items is not True:
         self.object.delete()
         return super(RegisterUserAddOrderView, self).form_invalid(form)
     send_new_order_seller(self.object)
     send_new_order_buyer(self.object, [self.request.user.email])
     return super(RegisterUserAddOrderView, self).form_valid(form)
コード例 #3
0
ファイル: views.py プロジェクト: nnmware/nnmware
 def form_valid(self, form):
     if not self.request.user.is_authenticated() and not settings.MARKET_ANONYMOUS_ORDERS:
         return super(AnonymousUserAddOrderView, self).form_invalid(form)
     basket = get_basket(self.request)
     if basket.count() < 1:
         return super(AnonymousUserAddOrderView, self).form_invalid(form)
     self.object = form.save(commit=False)
     self.object.ip = self.request.META['REMOTE_ADDR']
     self.object.user_agent = self.request.META['HTTP_USER_AGENT']
     self.object.status = STATUS_WAIT
     self.object.lite = True
     self.object.session_key = get_session_from_request(self.request)
     self.object.save()
     success_add_items = make_order_from_basket(self.object, basket)
     if success_add_items is not True:
         self.object.delete()
         return super(AnonymousUserAddOrderView, self).form_invalid(form)
     send_new_order_seller(self.object)
     send_new_order_buyer(self.object, [self.object.email])
     return super(AnonymousUserAddOrderView, self).form_valid(form)
コード例 #4
0
 def form_valid(self, form):
     if not self.request.user.is_authenticated and not settings.MARKET_ANONYMOUS_ORDERS:
         return super(AnonymousUserAddOrderView, self).form_invalid(form)
     basket = get_basket(self.request)
     if basket.count() < 1:
         return super(AnonymousUserAddOrderView, self).form_invalid(form)
     self.object = form.save(commit=False)
     self.object.ip = self.request.META['REMOTE_ADDR']
     self.object.user_agent = self.request.META['HTTP_USER_AGENT']
     self.object.status = STATUS_WAIT
     self.object.lite = True
     self.object.session_key = get_session_from_request(self.request)
     self.object.save()
     success_add_items = make_order_from_basket(self.object, basket)
     if success_add_items is not True:
         self.object.delete()
         return super(AnonymousUserAddOrderView, self).form_invalid(form)
     send_new_order_seller(self.object)
     send_new_order_buyer(self.object, [self.object.email])
     return super(AnonymousUserAddOrderView, self).form_valid(form)