def retailers_store(request, rid): context = StoreAccount.objects.filter(sChain__id=get_real_id(rid)) q = request.GET.get('q', None) if q: context = context.filter( Q(sChain__sChain__icontains=q) | Q(sState__icontains=q) | Q(sCity__icontains=q)) page = request.GET.get('page', 1) paginator = Paginator(context, 4) try: context = paginator.page(page) except PageNotAnInteger: context = paginator.page(1) except EmptyPage: context = paginator.page(paginator.num_pages) return render(request, 'core/store_detail.html', context={ 'context': context, 'q': q })
def retailer_detail(request, rid=None): if rid: context = RetailerAccount.objects.filter(id=get_real_id(rid)) else: context = RetailerAccount.objects.all() q = request.GET.get('q', None) if q: context = context.filter(Q(sChain__icontains=q)) page = request.GET.get('page', 1) paginator = Paginator(context, 4) try: context = paginator.page(page) except PageNotAnInteger: context = paginator.page(1) except EmptyPage: context = paginator.page(paginator.num_pages) return render(request, 'core/retailer_detail.html', context={ 'context': context, 'q': q })
def brand_account_detail(request, bid=None): if bid: context = [BrandAccount.objects.filter(id=get_real_id(bid))] else: context = BrandAccount.objects.all() q = request.GET.get('q', None) if q: context = context.filter( Q(bran__name__icontains=q) | Q(name__icontains=q) | Q(website__icontains=q) | Q(email__icontains=q) | Q(title__icontains=q)) page = request.GET.get('page', 1) paginator = Paginator(context, 4) try: context = paginator.page(page) except PageNotAnInteger: context = paginator.page(1) except EmptyPage: context = paginator.page(paginator.num_pages) return render(request, 'product/brand_account_detail.html', context={ 'context': context, 'q': q })
def type_add(request, rid=None): if rid: retailer = get_object_or_404(Type, id=get_real_id(rid)) else: retailer = None if request.method == "POST": form = TypeForm(request.POST, request.FILES, instance=retailer) if form.is_valid(): form.save() return redirect(reverse("core:type-detail")) else: form = TypeForm(instance=retailer) return render(request, "core/type_create.html", context={'form': form})
def store_add(request, sid=None): if sid: store = get_object_or_404(StoreAccount, id=get_real_id(sid)) else: store = None if request.method == "POST": form = StoreAccountForm(request.POST, instance=store) if form.is_valid(): form.save() return redirect(reverse("core:store-detail")) else: form = StoreAccountForm(instance=store) return render(request, "core/create_account.html", context={'form': form})
def brand_create(request, bid=None): if bid: brand = get_object_or_404(BrandAccount, id=get_real_id(bid)) else: brand = None if request.method == "POST": form = BrandForm(request.POST, instance=brand) if form.is_valid(): form.save() return redirect(reverse("product:brand-detail")) else: form = BrandForm(instance=brand) return render(request, 'product/brand_create.html', context={'form': form})
def retailer_add(request, rid=None): if rid: retailer = get_object_or_404(RetailerAccount, id=get_real_id(rid)) else: retailer = None if request.method == "POST": form = RetailerAccountForm(request.POST, request.FILES, instance=retailer) if form.is_valid(): form.save(commit=False) form.save() return redirect(reverse("core:retailer-detail")) else: form = RetailerAccountForm(instance=retailer) return render(request, "core/retailer_account.html", context={'form': form})