示例#1
0
 def get(self, request):
     if request.user.is_authenticated:
         if not request.user.is_superuser:
             return render(request, 'coupon.html')
         else:
             service.logout(request)
     return HttpResponseRedirect(reverse("shopping:login"))
示例#2
0
 def get(self, request):
     if request.user.is_authenticated:
         if not request.user.is_superuser:
             # 选出用户购物车中已经被选中的数据项
             user_id = request.user.user_id
             service.cancel_order_service(user_id)
             return HttpResponseRedirect(reverse("shopping:my_cart"))
         else:
             service.logout(request)
     return HttpResponseRedirect(reverse("shopping:login"))
示例#3
0
 def get(self, request):
     if request.user.is_authenticated:
         if not request.user.is_superuser:
             # 选出用户购物车中已经被选中的数据项
             user_id = request.user.user_id
             commit_cart_items, coupons = service.commit_order_page_service(
                 user_id)
             return render(request, 'order_commit_page.html', {
                 'cart_items': commit_cart_items,
                 'coupons': coupons
             })
         else:
             service.logout(request)
     return HttpResponseRedirect(reverse("shopping:login"))
示例#4
0
    def post(self, request):
        if request.user.is_authenticated:
            if not request.user.is_superuser:
                user_id = request.user.user_id
                coupon_id = request.POST.get('coupon_id', '')
                total_price = request.POST.get('total_price', '')
                discount_price = request.POST.get('discount_price', '')
                service.generate_order_service(user_id, coupon_id, total_price,
                                               discount_price)
                return HttpResponseRedirect(
                    reverse("shopping:order_commit_success"))
            else:
                service.logout(request)

        return HttpResponseRedirect(reverse("shopping:login"))
示例#5
0
    def get(self, request):
        """
        查看购物车
        :param request:
        :return:
        """

        data = dict()
        if request.user.is_authenticated():
            if not request.user.is_superuser:
                user_id = request.user.user_id
                cart_items = service.check_cart_record_service(user_id)
                data['cart_items'] = cart_items
                return render(request, 'my_cart.html', data)
            else:
                service.logout(request)
        return HttpResponseRedirect(reverse("shopping:login"))
示例#6
0
 def get(self, request):
     service.logout(request)
     return HttpResponseRedirect(reverse("shopping:commodity_list"))