コード例 #1
0
    def get(self, request):
        # checking if cart contain items for condition statements in home
        cart = request.session.get('cart')
        if not cart:
            request.session['cart'] = {}

        prds = None
        categ = Category.get_all_categories()
        categoryId = request.GET.get('category')
        if categoryId:
            prds = Product.get_all_products_by_category(categoryId)
        else:
            prds = Product.get_all_products()

        # Getiing user detail from session
        currentCustomer = None
        mail = request.session.get('customer_email')
        if mail:
            currentCustomer = Customer.get_customer_by_mail(mail)

        #--------------------------------
        data = {}
        data['products'] = prds
        data['categories'] = categ
        data['currentCustomer'] = currentCustomer

        # return render(request,'orders.html')
        return render(request, 'index.html', data)
コード例 #2
0
    def get(self, request):

        products = None
        cart=request.session.get("cart")
        if not cart:
            request.session.cart={}
        categories = Category.get_all_categories()
        messages = Message.get_all_message()
        categoryID = request.GET.get('category')
        if categoryID:
            products = Product.get_all_products_by_id(categoryID)
        else:
            products = Product.get_all_products()
        welcome = str(request.session.get('name'))
        data = {}
        data['products'] = products
        data['categories'] = categories
        data['messages'] = messages
        data['name'] = name
        data['welcome'] = welcome
        print("your pnone is " + str(request.session.get("phone")))
        print("your id is " + str(request.session.get("id")))
        print("your id is " + str(request.session.get("name")))

        return render(request, 'home.html', data)
コード例 #3
0
ファイル: home.py プロジェクト: Sameerpraz/E-Store
    def get(self, request):
        # print('------')
        # print(request.session.get('firstname'))
        cart = request.session.get('cart')
        if not cart:
            request.session['cart'] = {}
        total = []
        products = None
        categories = Category.objects.all()
        categoryID = request.GET.get('category')

        if categoryID:
            products = Product.get_all_products_by_categoryid(categoryID)
        else:
            products = Product.get_all_products()

        for category in categories:
            cat_id = category.id
            value = Product.objects.filter(category=cat_id).count()
            total.append(value)
        # we can use zip only when size of list is same
        data = zip(categories, total)
        return render(request, 'store/index.html', {
            'products': products,
            'data': data
        })
コード例 #4
0
ファイル: home.py プロジェクト: shikha2235/Shopping-App
    def get(self, request):
        cart = request.session.get('cart')
        if not cart:
            request.session['cart'] = {}
        products = None
        categories = Category.get_all_categories()
        categoryID = request.GET.get('category')
        if categoryID:
            request.session['category'] = categoryID
        elif not categoryID:
            request.session['category'] = None
        # print(request.session['category'])
        name = None
        if categoryID:
            for cat in categories:
                if cat.id == int(categoryID):
                    name = cat.name

        if categoryID:
            products = Product.get_all_products_by_categoryid(categoryID)
        else:
            products = Product.get_all_products()

        data = {}
        data['products'] = products
        data['categories'] = categories
        data['name'] = name

        # print(name)
        return render(request, 'index.html', data)
コード例 #5
0
ファイル: home.py プロジェクト: avayaadhikari4u/myapp
def emptycart(request):
    categories = Category.get_all_categories()
    products = Product.get_all_products()
    dec = {}
    dec['categories'] = categories
    #dec['products']=products
    print(categories)
    return render(request, 'empty.html', dec)
コード例 #6
0
ファイル: home.py プロジェクト: SaadFurqhan/Dukaan_Heroku
def store(request):
    categoryID = None
    categoryNameforDisplay = None
    search = request.POST.get('search')
    cart = request.session.get('cart')
    filtervalue = request.POST.get('filtering')
    categoryName = request.POST.get('categoryBtn')
    currentCategory = request.POST.get('currentCategory')

    if categoryName:
        getcategoryID = Category.get_categoryid(categoryName)
        for category in getcategoryID:
            categoryID = category.id
    if not cart:
        request.session['cart'] = {}
    products = None
    categories = Category.get_all_categories()
    #categoryID = request.GET.get('category')
    if currentCategory != "None" and filtervalue == "price":
        products = Product.get_all_products_by_pricefilterWithCategory(
            currentCategory)
        categoryNameforDisplay = categoryName
    elif currentCategory != "None" and filtervalue == "rating":
        products = Product.get_all_products_by_ratingfilterWithCategory(
            currentCategory)
        categoryNameforDisplay = categoryName
    elif categoryID:
        products = Product.get_all_products_by_categoryid(categoryID)
        currentCategory = categoryID
        categoryNameforDisplay = categoryName
    elif filtervalue == "price":
        products = Product.get_all_products_by_pricefilter()
        currentCategory = categoryID
        categoryNameforDisplay = categoryName
    elif filtervalue == "rating":
        products = Product.get_all_products_by_ratingfilter()
        currentCategory = categoryID
        categoryNameforDisplay = categoryName
    elif search != None:
        products = Product.get_all_products_by_search(search)
        currentCategory = categoryID
        categoryNameforDisplay = categoryName
    elif filtervalue == "price":
        products = Product.get_all_products_by_pricefilter()
    else:
        products = Product.get_all_products()

    data = {}
    data['products'] = products
    data['categories'] = categories
    data['currentCategory'] = currentCategory
    data['categoryNameforDisplay'] = categoryNameforDisplay
    return render(request, 'index.html', data)
コード例 #7
0
ファイル: home.py プロジェクト: dhmpanchal/eshop_gjango
 def get(self, request):
     cart = request.session.get('cart')
     if not cart:
         request.session['cart'] = {}
     categoryId = request.GET.get('cat_id')
     if categoryId:
         products = Product.get_products_by_category(categoryId)
     else:
         products = Product.get_all_products()
     categories = Category.get_all_categories()
     data = {'products': products, 'categories': categories}
     return render(request, 'index.html', data)
コード例 #8
0
def collection(request):
    products = None
    categories = Category.get_all_categories()
    categoryID = request.GET.get('Category')
    if categoryID:
        products = Product.get_all_products_by_categoryid(catagoty_id)
    else:
        products = Product.get_all_products()
    data = {}
    data['products'] = products
    data['categories'] = categories
    return render(request, 'collection.html', data)
コード例 #9
0
ファイル: home.py プロジェクト: ankusnayak/Django-Project
def index(request):
    # return HttpResponse('<h1>Index Page</h1>')
    products = None
    categories = Category.get_all_categories()
    categoryId = request.GET.get('category')
    if categoryId:
        products = Product.get_all_product_by_id(categoryId)
    else:
        products = Product.get_all_products()
    data = {}
    data['products'] = products
    data['categories'] = categories
    return render(request, 'index.html', data)
コード例 #10
0
 def get(self, request):
     categories = Category.get_all_category()
     if request.GET.get("category"):
         products = Product.get_all_products_by_category_id(
             request.GET.get("category"))
     else:
         products = Product.get_all_products()
     cart_size = Cart.get_all_products_by_user(request.user.id)
     data = {}
     data['products'] = products
     data['categories'] = categories
     data['cart_size'] = len(cart_size)
     return render(request, "index.html", data)
コード例 #11
0
ファイル: home.py プロジェクト: suvitandale/sept16092020
def index(request):
    prods = None
    catergory = Category.get_all_categories()
    categoryID = request.GET.get('category')
    if categoryID:
        prods = Product.get_all_products_by_categoryid(categoryID)
    else:
        prods = Product.get_all_products()
    data = {}
    data['product'] = prods
    data['categories'] = catergory
    print(request.session.get('customer_email'))
    return render(request, 'index.html', data)
コード例 #12
0
ファイル: home.py プロジェクト: avayaadhikari4u/myapp
def Subcategory(request):
    categories = Category.get_all_categories()
    subcategories = Sub_Category.get_all_subcategories()
    dec = {}
    categoryID = request.GET.get('category')
    if categoryID:
        subcategories = Sub_Category.get_all_subCategory_by_categoryid(
            categoryID)
        #products=Product.get_all_products_by_categoryid(categoryID)
    else:
        products = Product.get_all_products()
    dec['categories'] = categories
    dec['subcategories'] = subcategories
    return render(request, 'subcategory.html', dec)
コード例 #13
0
 def get(self, request):
     cart = request.session.get('cart')
     if not cart:
         request.session['cart'] = {}
     products = None
     categories = Category.get_all_categories()
     categoryID = request.GET.get('category')
     if categoryID:
         products = Product.get_all_products_by_category_id(categoryID)
     else:
         products = Product.get_all_products()
     data = {'products': products, 'categories': categories}
     # print('You are', request.session.get('email'))
     return render(request, "index.html", data)
コード例 #14
0
ファイル: home.py プロジェクト: daman9999/ecommerce-django-
 def get(self,request):
     cart = request.session.get('cart')
     if not cart:
         request.session['cart'] = {}
     products= None
     categoryID = request.GET.get('category')
     categories=Category.get_all_categories()
     if categoryID:
         products=Product.get_all_products_by_categoryId(categoryID)
     else:
         products=Product.get_all_products()
     data={}
     data['products'] = products
     data['category'] = categories
     return render(request,'index.html',data)
コード例 #15
0
    def get(self, request):
        products = None
        categories = Category.get_all_categories()

        categoryID = request.GET.get('category')
        if categoryID:
            products = Product.get_all_products_by_categoryid(categoryID)
        else:
            products = Product.get_all_products()

        data = {}
        data['products'] = products
        data['categories'] = categories
        print('You are : ', request.session.get('email'))
        return render(request, 'index.html', data)
コード例 #16
0
 def get(self,request):
     cart = request.session.get('cart')
     if not cart:
         request.session['cart'] = {}
     products = ''
     # request.session.get('cart').clear()
     cate = Category.objects.all()
     categoryID = request.GET.get('category')
     if categoryID:
         products = Product.get_all_products_by_categoryid(categoryID)
     else:
         products = Product.get_all_products()
     context = {'products': products, 'category': cate}
     print('get user : '******'email'))
     return render(request,'index.html',context)
コード例 #17
0
ファイル: home.py プロジェクト: adityagound6/Ecommerce_Django
    def get(self, request):

        cart = request.session.get('cart')

        if not cart:
            request.session.cart = {}
        products = None
        categories = Category.get_all_category()
        categoryID = request.GET.get('category')
        if categoryID:
            products = Product.get_all_products_by_id(categoryID)
        else:
            products = Product.get_all_products()

        data = {'products': products, 'categories': categories}
        return render(request, 'index.html', data)
コード例 #18
0
ファイル: home.py プロジェクト: imarnab10/eshop
def store(request):
    cart = request.session.get('cart')
    if not cart:
        request.session['cart'] = {}
    categories = Category.get_all_categories()

    categoryID = request.GET.get('category')

    if categoryID:
        products = Product.get_all_products_by_category_id(categoryID)
    else:
        products = Product.get_all_products()

    data = {'products': products, 'categories': categories}
    print('you are :', request.session.get('email'))
    return render(request, 'index.html', data)
コード例 #19
0
ファイル: home.py プロジェクト: rohitc1818/E-commerse
    def get(self,request):
        cart = request.session.get('cart')
        if not cart:
            request.session.cart = {}
        products = None
        categories = Category.get_all_categories()
        category_id = request.GET.get('category')
        if category_id:
            products = Product.get_all_products_by_categoryid(category_id)
        else:
            products = Product.get_all_products()

        data = {}
        data['products'] = products
        data['categories'] = categories
        return render(request, 'home.html', data)
コード例 #20
0
ファイル: home.py プロジェクト: ak463010/eshop
    def get(self, request):
        cart = request.session.get('cart')
        if not cart:
            request.session['cart'] = {}
        products = None
        categoryies = Category.get_all_categories()
        category_id = request.GET.get('category')
        if category_id:
            products = Product.get_all_products_by_category_id(category_id)
        else:
            products = Product.get_all_products()

        context = {}
        context['products'] = products
        context['categories'] = categoryies
        return render(request, 'store/index.html', context)
コード例 #21
0
 def get(self, request):
     cart = request.session.get("cart")
     if not cart:
         request.session.cart = {}
     products = None
     categories = Category.get_all_categories()
     categoryid = request.GET.get("category")
     if categoryid:
         products = Product.get_all_product_by_categoryid(categoryid)
     else:
         products = Product.get_all_products()
     data = {}
     data["products"] = products
     data["categories"] = categories
     print("your email", request.session.get("email"))
     print("your id", request.session.get("customer_id"))
     return render(request, 'index.html', data)
コード例 #22
0
 def get(self, request):
     print("inside get")
     cart = request.session.get('cart')
     if not cart:
         request.session.cart = {}
     products = None
     categories = Category.get_all_categories()
     category_id = request.GET.get('category')
     if category_id:
         products = Product.get_all_products_by_categoryid(category_id)
     else:
         products = Product.get_all_products()
     data = {}
     data['products'] = products
     data['categories'] = categories
     print("You are - > ", request.session.get('email'))
     return render(request, "index.html", data)
コード例 #23
0
 def get(self, request, id):
     product = Product.objects.filter(id=id)
     return render(request, 'particular.html', {'products': product})
     cart = request.session.get('cart')
     if not cart:
         request.session['cart'] = {}
     products = None
     categories = Category.get_all_categories()
     categoryID = request.GET.get('category')
     if categoryID:
         products = Product.get_all_products_by_categoryid(categoryID)
     else:
         products = Product.get_all_products()
     data = {}
     data['products'] = products
     data['categories'] = categories
     return render(request, 'particular.html', data)
コード例 #24
0
 def get(self, request):
     products = None
     cart = request.session.get('cart')
     if not cart:
         request.session['cart'] = {}
     categories = Category.get_all_categories()
     categoryID = request.GET.get('category')
     if (categoryID):
         products = Product.get_all_products_by_Categoryid(categoryID)
     else:
         products = Product.get_all_products()
     data = {}
     data['products'] = products
     data['categories'] = categories
     print('you are : ', request.session.get("email"))
     print('email' in request.session)
     return render(request, 'index.html', data)
コード例 #25
0
ファイル: index.py プロジェクト: dpuman/eshop
    def get(self, request):
        products = None
        category = Category.get_all_category()

        categoryid = request.GET.get('category')

        if categoryid:
            products = Product.get_all_products_by_categoryid(categoryid)
        else:
            products = Product.get_all_products()

        context = {
            'products': products,
            'category': category
        }

        print('email', request.session.get('customer_email'))
        return render(request, 'store/index.html', context)
コード例 #26
0
    def get(self, request):
        cart = request.session.get('cart')
        if not cart:
            request.session['cart'] = {}
        products = None
        categories = Category.get_all_categories()

        # print(request.GET)
        categoryID = request.GET.get('category')
        if categoryID:
            products = Product.get_all_product_by_categoryid(categoryID)
        else:
            products = Product.get_all_products()
        data = {}
        data['products'] = products
        data['category'] = categories
        # print('guegsdkvb  :  ', request.session.get('customer_email'))
        return render(request, 'index.html', {'products': data})
コード例 #27
0
ファイル: home.py プロジェクト: SaadFurqhan/Dukaan_Heroku
    def get(self, request):
        # print()
        #return HttpResponseRedirect(f'/store{request.get_full_path()[1:]}')
        cart = request.session.get('cart')
        if not cart:
            request.session['cart'] = {}
        products = None
        categories = Category.get_all_categories()
        categoryID = request.GET.get('category')
        if categoryID:
            products = Product.get_all_products_by_categoryid(categoryID)
        else:
            products = Product.get_all_products()

        data = {}
        data['products'] = products
        data['categories'] = categories

        return render(request, "home.html", data)
コード例 #28
0
ファイル: home.py プロジェクト: nilanshi27/EShop
    def get(self,request):
        cart=request.session.get('cart') #for deciding if cart is empty or not
        if not cart:
            request.session['cart']={}
        products = None
        # products = Product.get_all_products()
        # this is used to fetch product
        categories = categorie.get_all_categories()
        categoryID = request.GET.get('category')
        if categoryID:
            products = Product.get_all_products_by_categoryid(categoryID)
        else:
            products = Product.get_all_products()

        data = {}
        data['products'] = products
        data['categories'] = categories

        return render(request, 'index.html', data)
コード例 #29
0
ファイル: home.py プロジェクト: avayaadhikari4u/myapp
    def get(self, request):
        dec = {}
        cart = request.session.get('cart')

        if not cart:
            request.session.cart = {}
        products = None
        categories = Category.get_all_categories()
        subcategories = SubCategory.get_all_subcategories()
        brands = Brand.get_all_Brand()
        categoryID = request.GET.get('category')
        subcategoryID = request.GET.get('subcategory')
        brandID = request.GET.get('brand')
        print("id is:", brandID)

        if categoryID:

            subcategories = SubCategory.get_all_subCategory_by_categoryid(
                categoryID)
            dec['categories'] = categories
            dec['subcategories'] = subcategories
            return render(request, 'index.html', dec)
            #products=Product.get_all_products_by_categoryid(categoryID)

        elif subcategoryID:
            dec['categories'] = categories
            brands = Brand.get_all_Brands_by_subcategoryid(subcategoryID)
            dec['brands'] = brands
            return render(request, 'index.html', dec)

        elif brandID:
            dec['categories'] = categories
            products = Product.get_all_products_by_brandid(brandID)
            dec['products'] = products
            return render(request, 'index.html', dec)
        else:
            products = Product.get_all_products()
            print(products)
        dec['products'] = products
        dec['categories'] = categories
        #dec['brands']=brands
        return render(request, 'index.html', dec)
コード例 #30
0
ファイル: home.py プロジェクト: huneshkumar/E-store
    def get(self,request):
        cart=request.session.get('cart')
        if not cart:
            request.session.cart={}

        
        products = None
        categories = Category.get_all_Categories()
        # return render(request,'orders/orders.html')
        categoryId = request.GET.get('category')
        if categoryId:
            products = Product.get_all_Categories_by_categoryId(categoryId)
        else:
            products = Product.get_all_products();

        data = {}
        data['products'] = products
        data['categories'] = categories
        print('you are:', request.session.get('email'))
        return render(request, 'index.html', data)