diff --git a/Pipfile b/Pipfile index dec8868..6202070 100644 --- a/Pipfile +++ b/Pipfile @@ -20,6 +20,7 @@ daphne = "*" asgi-runserver = "*" uvloop = "*" httptools = "*" +uwsgi = "*" [dev-packages] diff --git a/Pipfile.lock b/Pipfile.lock index 8e2c29e..c0e0a20 100644 --- a/Pipfile.lock +++ b/Pipfile.lock @@ -1,7 +1,7 @@ { "_meta": { "hash": { - "sha256": "1fa3831d2b5ce829ace7a82c274f8660cc6713c2c7af57cefd3c5b3438f0ee59" + "sha256": "35d2d20b6270dad89f1d66e8215e3b9518585e80f62f5cead1a06e473e30979a" }, "pipfile-spec": 6, "requires": { @@ -543,6 +543,13 @@ "index": "pypi", "version": "==0.14.0" }, + "uwsgi": { + "hashes": [ + "sha256:faa85e053c0b1be4d5585b0858d3a511d2cd10201802e8676060fd0a109e5869" + ], + "index": "pypi", + "version": "==2.0.19.1" + }, "vine": { "hashes": [ "sha256:4c9dceab6f76ed92105027c49c823800dd33cacce13bdedc5b914e3514b7fb30", diff --git a/accounts/models.py b/accounts/models.py index 0dbf02a..838040a 100755 --- a/accounts/models.py +++ b/accounts/models.py @@ -9,10 +9,11 @@ def auto_prof_create(sender, instance: User, created, **kwargs): if created: Profile.objects.create(user=instance) - subject = "ThankYou Registering" + subject = "Welcome to Bookstore 🤩🤩" - print(instance.email) - body = f"Hey {instance.first_name} Welcome to BookStore. " + body = f"Hey {instance.first_name} Welcome to Bookstore 🤩🤩 \n\n" \ + f"Bookstore is your best source to buy cheap book online, make " \ + f"online book purchase, making us the best book website in India to read book online" send_email_to_user.delay([instance.email], subject, body) @@ -41,7 +42,6 @@ def __str__(self): def clean(self): if self.is_seller: if self.firm_name is None or self.bank_account_no is None or self.pan_number is None or self.IFSC is None: - print(vars(self)) raise ValidationError('firm name / account number / pan number / bank IFSC not found') def save(self, *args, **kwargs): @@ -61,12 +61,3 @@ class Meta: post_save.connect(auto_prof_create, sender=User) post_delete.connect(auto_user_delete, sender=Profile) - - -""" - -{'user': {'username': 'priyansh2001', 'first_name': 'Priyansh', 'last_name': 'Singh', 'password': 'Fiitjee13', 'fav_genres': ['Business', 'Crime Thriller', 'History', 'Pyschology', 'Self Help']}, 'address': '113 North City Pilibhit Road Bareilly', 'contact_number': '7618166335'} - -{'user': {'username': 'priyansh2001', 'first_name': 'Priyansh', 'last_name': 'Singh', 'password': 'Fiitjee13', 'fav_genres': ['Cooking', 'Historical Fiction', 'Physics']}, 'address': '113 North City Pilibhit Road Bareilly', 'contact_number': '7618166335'} - -""" \ No newline at end of file diff --git a/accounts/serializers.py b/accounts/serializers.py index 296c6fa..2655c4f 100755 --- a/accounts/serializers.py +++ b/accounts/serializers.py @@ -91,7 +91,6 @@ class Meta: fields = ['user', 'address', 'contact_number'] def create(self, validated_data): - print(validated_data) user_data = validated_data.pop('user') address = validated_data.pop('address') contact_number = validated_data.pop('contact_number') diff --git a/accounts/views.py b/accounts/views.py index c823b29..41be445 100755 --- a/accounts/views.py +++ b/accounts/views.py @@ -43,7 +43,7 @@ class Register(CreateAPIView): permission_classes = [~IsAuthenticated] def post(self, request, *args, **kwargs): - print(self.request.data) + # print(self.request.data) ret = super(Register, self).post(request, *args, **kwargs) return ret diff --git a/book_seling/settings.py b/book_seling/settings.py index 499246b..91583ae 100755 --- a/book_seling/settings.py +++ b/book_seling/settings.py @@ -33,7 +33,6 @@ INSTALLED_APPS = [ - 'asgi_runserver', 'django.contrib.admin', 'django.contrib.auth', @@ -52,7 +51,7 @@ 'orders' ] -ASGI_APPLICATION = 'book_seling.asgi.application' +# ASGI_APPLICATION = 'book_seling.asgi.application' LOGIN_URL = "/login" @@ -64,7 +63,7 @@ 'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.contrib.messages.middleware.MessageMiddleware', 'django.middleware.clickjacking.XFrameOptionsMiddleware', - 'debug_toolbar.middleware.DebugToolbarMiddleware', + # 'debug_toolbar.middleware.DebugToolbarMiddleware', ] ROOT_URLCONF = 'book_seling.urls' diff --git a/book_seling/urls.py b/book_seling/urls.py index da29ec4..8bc9104 100755 --- a/book_seling/urls.py +++ b/book_seling/urls.py @@ -13,7 +13,7 @@ 1. Import the include() function: from django.urls import include, path 2. Add a URL to urlpatterns: path('blog/', include('blog.urls')) """ -import debug_toolbar +# import debug_toolbar from django.conf import settings from django.conf.urls.static import static from django.contrib import admin @@ -22,6 +22,7 @@ from django.contrib.staticfiles.urls import staticfiles_urlpatterns from django.urls import path, include +from django.views.decorators.cache import cache_page, cache_control from django.views.generic import TemplateView from .decorators import AnonymousRequired, CheckoutValidation @@ -31,7 +32,7 @@ path('api/', include('books.urls')), path('api/accounts/', include('accounts.urls')), path('api/cart/', include('orders.urls')), - path('__debug__/', include(debug_toolbar.urls)), + # path('__debug__/', include(debug_toolbar.urls)), path('accounts/reset_password/', (auth_views.PasswordResetView.as_view(template_name='passwordReset.html')), @@ -52,10 +53,10 @@ ] urlpatterns += [ - path('login', AnonymousRequired(TemplateView.as_view(template_name='login.html'))), + path('login', (AnonymousRequired(TemplateView.as_view(template_name='login.html')))), path('signup', AnonymousRequired(TemplateView.as_view(template_name='signup.html'))), path('', TemplateView.as_view(template_name='index.html')), - path('author/', TemplateView.as_view(template_name='author.html')), + path('author/', TemplateView.as_view(template_name='author2.html')), path('book/', TemplateView.as_view(template_name='book.html')), path('genre//books', TemplateView.as_view(template_name='genre.html')), path('profile', login_required(TemplateView.as_view(template_name='profile.html'))), @@ -66,11 +67,9 @@ path('confirm-order', login_required(CheckoutValidation(TemplateView.as_view(template_name='confirmOrder.html')))), path('order-complete', login_required(TemplateView.as_view(template_name='orderComplete.html'))), path('your-orders', login_required(TemplateView.as_view(template_name='orders.html'))), + path('genre-list', TemplateView.as_view(template_name='genresList.html')) ] urlpatterns = urlpatterns + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT) # urlpatterns = urlpatterns + static(settings.STATIC_URL, document_root=settings.STATIC_ROOT) urlpatterns += staticfiles_urlpatterns() - -""" -""" diff --git a/books/urls.py b/books/urls.py index 467b318..cf39c40 100644 --- a/books/urls.py +++ b/books/urls.py @@ -1,35 +1,16 @@ -from asgiref.sync import sync_to_async from django.urls import path from . import views -# urlpatterns = [ -# path('books/all', views.BookListView.as_view()), -# path('authors/all', views.AuthorListView.as_view()), -# -# path('authors/', views.AuthorActionView.as_view()), -# # todo optimization -# path('books/recommended', views.GetRecommendedBooks.as_view()), -# path('books/best-sellers', views.BestSellerView.as_view()), -# path('authors/top', views.TopAuthors.as_view()), -# # todo optimization -# path('books/new', views.GetNewReleases.as_view()), -# path('books/popular', views.GetPopularBooks.as_view()), -# -# path('books//similar', views.SimilarBookView.as_view()), -# path('books/', views.BookActionView.as_view()), -# path('genre/', views.GenreRetrieveView.as_view()), -# ] - urlpatterns = [ - path('books/all', sync_to_async(views.BookListView.as_view())), + path('books/all', views.BookListView.as_view()), path('authors/all', views.AuthorListView.as_view()), path('authors/', views.AuthorActionView.as_view()), # todo optimization path('books/recommended', views.GetRecommendedBooks.as_view()), - path('books/best-sellers', sync_to_async(views.BestSellerView.as_view())), - path('authors/top', sync_to_async(views.TopAuthors.as_view())), + path('books/best-sellers', views.BestSellerView.as_view()), + path('authors/top', views.TopAuthors.as_view()), # todo optimization path('books/new', views.GetNewReleases.as_view()), path('books/popular', views.GetPopularBooks.as_view()), diff --git a/books/views.py b/books/views.py index 63e708c..39d8e5a 100755 --- a/books/views.py +++ b/books/views.py @@ -1,5 +1,5 @@ from django.core.cache import cache -from django.db.models import Count +from django.db.models import Count, Q from django.utils.decorators import method_decorator from django.views.decorators.cache import cache_page from django_filters.rest_framework import DjangoFilterBackend @@ -56,9 +56,9 @@ class GenreRetrieveView(RetrieveAPIView): serializer_class = GenreSerializer lookup_field = 'name' - # @method_decorator(cache_page(60 * 15)) - # def dispatch(self, request, *args, **kwargs): - # return super(GenreRetrieveView, self).dispatch(request, *args, **kwargs) + @method_decorator(cache_page(60 * 15)) + def dispatch(self, request, *args, **kwargs): + return super(GenreRetrieveView, self).dispatch(request, *args, **kwargs) class GetRecommendedBooks(APIView): @@ -72,23 +72,23 @@ def get(self, request): fav_genres = user.fav_genres.all() data = Book.objects.filter(genre__in=fav_genres).order_by('-sold_quantity').filter( - all_deals__isnull=False).order_by('-rating')[:9] + all_deals__isnull=False).order_by('-rating').distinct()[:9] data = BookIconSerializer(data, many=True).data cache.set(f'{user.id}', data, 60 * 5) # cache timeout=5 min - + # else: return Response(data=data, status=status.HTTP_200_OK) class BestSellerView(ListAPIView): serializer_class = BookIconSerializer - queryset = Book.objects.order_by('-date_created').filter(all_deals__isnull=False).order_by('-rating')[:9] + queryset = Book.objects.order_by('-released_date').filter(all_deals__isnull=False).distinct().order_by('-rating')[ + :9] - # @method_decorator(cache_page(60 * 60)) - # def list(self, request, *args, **kwargs): - # return super(BestSellerView, self).list(request, *args, **kwargs) - # + @method_decorator(cache_page(60 * 60)) + def list(self, request, *args, **kwargs): + return super(BestSellerView, self).list(request, *args, **kwargs) class TopAuthors(ListAPIView): @@ -97,9 +97,9 @@ class TopAuthors(ListAPIView): def get_serializer(self, *args, **kwargs): return AuthorSerializer(*args, **kwargs, remove_fields=['info']) - # @method_decorator(cache_page(60 * 60)) - # def list(self, request, *args, **kwargs): - # return super(TopAuthors, self).list(request, *args, **kwargs) + @method_decorator(cache_page(60 * 60)) + def list(self, request, *args, **kwargs): + return super(TopAuthors, self).list(request, *args, **kwargs) # class RegisterNewBook(APIView): @@ -129,21 +129,20 @@ def get_queryset(self): class GetNewReleases(ListAPIView): serializer_class = BookIconSerializer - queryset = Book.objects.order_by('-released_date')[:9] + queryset = Book.objects.filter(all_deals__isnull=False).distinct().order_by('-released_date')[:9] - # @method_decorator(cache_page(60 * 15)) - # def list(self, request, *args, **kwargs): - # return super(GetNewReleases, self).list(request, *args, **kwargs) - # + @method_decorator(cache_page(60 * 15)) + def list(self, request, *args, **kwargs): + return super(GetNewReleases, self).list(request, *args, **kwargs) class GetPopularBooks(ListAPIView): serializer_class = BookIconSerializer - queryset = Book.objects.all().order_by('-sold_quantity')[:9] + queryset = Book.objects.all().filter(all_deals__isnull=False).distinct().order_by('-sold_quantity')[:9] - # @method_decorator(cache_page(60 * 15)) - # def list(self, request, *args, **kwargs): - # return super(GetPopularBooks, self).list(request, *args, **kwargs) + @method_decorator(cache_page(60 * 15)) + def list(self, request, *args, **kwargs): + return super(GetPopularBooks, self).list(request, *args, **kwargs) class SimilarBookView(ListAPIView): @@ -152,3 +151,9 @@ class SimilarBookView(ListAPIView): def get_queryset(self): pk = self.kwargs.get('pk') return Book.objects.filter(genre__book__ISBN=pk) + +# +# from django.db import connection +# def timei(): +# for k in connection.queries: +# print(k['time']) diff --git a/orders/admin.py b/orders/admin.py index 0d820a3..65f4dc2 100644 --- a/orders/admin.py +++ b/orders/admin.py @@ -12,7 +12,7 @@ class Meta: class ProductOrderOrCartAdmin(admin.ModelAdmin): - list_display = ['__str__', 'quantity', 'available_stock', 'sold_quantity', 'deal_link'] + list_display = ['__str__', 'is_ordered', 'quantity', 'available_stock', 'sold_quantity', 'deal_link'] class Meta: model = models.ProductOrderOrCart @@ -25,6 +25,11 @@ def deal_link(self, obj: models.ProductOrderOrCart): deal_link.allow_tags = True deal_link.short_description = 'Deal' + def is_ordered(self, obj: models.ProductOrderOrCart): + if obj.order is not None: + return '✔' + return '❌' + def available_stock(self, obj: models.ProductOrderOrCart): return obj.deal.quantity @@ -49,4 +54,4 @@ def sold_quantity(self, obj: models.ProductOrderOrCart): admin.site.register( models.Order, OrderAdmin -) \ No newline at end of file +) diff --git a/orders/migrations/0006_auto_20210205_1339.py b/orders/migrations/0006_auto_20210205_1339.py new file mode 100644 index 0000000..c24fb82 --- /dev/null +++ b/orders/migrations/0006_auto_20210205_1339.py @@ -0,0 +1,27 @@ +# Generated by Django 3.1.6 on 2021-02-05 13:39 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('orders', '0005_auto_20210203_0658'), + ] + + operations = [ + migrations.AlterModelOptions( + name='order', + options={'ordering': ['-ordered_on']}, + ), + migrations.AddField( + model_name='productorderorcart', + name='is_ordered', + field=models.BooleanField(default=False), + ), + migrations.AlterField( + model_name='order', + name='status', + field=models.CharField(choices=[('Pending', 'Pending'), ('Dispatched', 'Dispatched'), ('Out For Delivery', 'Out For Delivery'), ('Delivered', 'Delivered')], default='Pending', max_length=20), + ), + ] diff --git a/orders/migrations/0007_auto_20210205_1347.py b/orders/migrations/0007_auto_20210205_1347.py new file mode 100644 index 0000000..62f6697 --- /dev/null +++ b/orders/migrations/0007_auto_20210205_1347.py @@ -0,0 +1,21 @@ +# Generated by Django 3.1.6 on 2021-02-05 13:47 + +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ('orders', '0006_auto_20210205_1339'), + ] + + operations = [ + migrations.AlterModelOptions( + name='order', + options={}, + ), + migrations.RemoveField( + model_name='productorderorcart', + name='is_ordered', + ), + ] diff --git a/orders/models.py b/orders/models.py index 43e1364..da85b66 100644 --- a/orders/models.py +++ b/orders/models.py @@ -18,6 +18,7 @@ class ProductOrderOrCart(models.Model): cart = models.ForeignKey('Cart', on_delete=models.CASCADE, null=True, blank=True) order = models.ForeignKey('Order', null=True, on_delete=models.CASCADE, blank=True) + # is_orderd = class Meta: unique_together = ('deal', 'cart') @@ -31,6 +32,7 @@ def save(self, *args, **kwargs): if self.order and self.cart: raise ValidationError('product cant be in order and cart at same time') + super(ProductOrderOrCart, self).save(*args, **kwargs) def __str__(self): @@ -70,6 +72,9 @@ class Order(models.Model): status = models.CharField(choices=order_status_choices, max_length=20, default='Pending') shipping_address = models.ForeignKey(ShippingAddress, null=True, on_delete=models.SET_NULL) + # class Meta: + # ordering = ['-ordered_on'] + class Promocode(models.Model): code = models.CharField(max_length=8, primary_key=True) diff --git a/orders/urls.py b/orders/urls.py index 6db0e9f..9d96e38 100644 --- a/orders/urls.py +++ b/orders/urls.py @@ -10,5 +10,6 @@ path('checkout', views.Checkout.as_view()), # path('deals/', views.GetDealOfBook.as_view()), path('deals/', views.GetDealOfBook.as_view()), - path('your-orders', views.OrderListView.as_view()) + path('your-orders', views.OrderListView.as_view()), + path('validate-promocode', views.ValidatePromocode.as_view()) ] diff --git a/orders/views.py b/orders/views.py index 7a67c7a..904ba52 100644 --- a/orders/views.py +++ b/orders/views.py @@ -1,3 +1,5 @@ +import time + from django.contrib.auth.models import User from django.db import transaction from django.db.models import * @@ -178,16 +180,17 @@ def post(self, request): cart__user=user.profile).annotate( available_stock=Sum('deal__quantity')) - # available_stock__gte => available_stock >= ProductOrderOrCart.qty try: with transaction.atomic(): in_stock: QuerySet[ProductOrderOrCart] = cart_products_qs.filter( available_stock__gte=F('quantity')) - in_stock.select_for_update() + in_stock.select_related('deal').select_for_update() if not in_stock.exists(): - return Response(status=status.HTTP_400_BAD_REQUEST) + return Response(data={ + 'message': 'Product went out of stock' + }, status=status.HTTP_400_BAD_REQUEST) total_cost = in_stock.aggregate(total_amount=Sum(F('quantity') * F('deal__price')))['total_amount'] total_cost = total_cost - (total_cost * discount_percent // 100) @@ -237,7 +240,7 @@ class OrderListView(ListAPIView): def get_queryset(self): user: User = self.request.user - return ProductOrderOrCart.objects.filter(order__user=user) + return ProductOrderOrCart.objects.filter(order__user=user).order_by('-order__ordered_on') # order_obj: QuerySet[Order] = Order.objects.filter(user=user) # return order_obj @@ -253,6 +256,18 @@ def get(self, request, *args, **kwargs): pending_orders.update(status=status) +class ValidatePromocode(APIView): + + def post(self, request): + code = request.data.get('code') + if code is None: + return Response(status=status.HTTP_400_BAD_REQUEST) + + obj = get_object_or_404(Promocode, code=code) + if obj: + return Response(status=status.HTTP_200_OK) + + # todo """ pswd change diff --git a/static/js/api handling/component.js b/static/js/api handling/component.js index 9f10153..93b84cc 100644 --- a/static/js/api handling/component.js +++ b/static/js/api handling/component.js @@ -152,7 +152,7 @@ export function constructHomepageTopBar(genreNames) { Self Help Science Fiction Young Adult - More.. + More.. diff --git a/static/js/api handling/constructAuthorPage.js b/static/js/api handling/constructAuthorPage.js deleted file mode 100644 index 96e8fbc..0000000 --- a/static/js/api handling/constructAuthorPage.js +++ /dev/null @@ -1,108 +0,0 @@ -import {constructSection} from "./constructSection.js"; -import {constructSidebar, constructTopBar} from "./component.js"; -import * as utility from "./utilities.js"; - -const rootElement = document.getElementById("rootElement"); -var loader = document.getElementById("loader"); -var contentWrapper; -var sectionBottom; -var authorName; -var authorImgUrl; - -const authorID = window.location.pathname.split('/')[2] -const baseURL = `${window.location.protocol}//${window.location.host}/api`; -const authorDataURL = `${baseURL}/authors/${authorID}`; -const authorBooksURL = `${baseURL}/books/all?name=&author__name=&genre__name=&ISBN=&author__id=${authorID}`; - -function constructAuthorDesc(data) { - // yha pe data nikalna - // NOTE : author ka name and author ki Img url line 9 and 10 pe jo global variable hai wha BHI store krna, - // dusri jgeh bhi istemal krna hai unko - // matlab yha teen variable nikalne, authorDesc, authorName, authorImgUrl - authorName = data.name; // abhi ke liye toh aise kr dia - authorImgUrl = data.image; - return ( - ` -
-
-
About
-
-

${data.info}

-
- - ` - ) -} - -function constructAuthorBooksSection(data) { - // Author books ki array ki length nikalana yha - var authorBooks = ""; - for (let i = 0; i < data.length; i++) { // ye 5 bs sample ke liye liya hai maine, array length ayega yha - let obj = { - // pichle section ki treh yha bhi data break krna, data[i].jsonKey - // uske baad niche html me ${obj.variableName} aise put krdena - // imageUrl = data[i].authorImg example - }; - authorBooks += ` -
-
- -
-

${data[i].name}

-
-
Rs ${data[i].lowest_price.price}
-
${data[i].rating}★
-
-
- `; - } - return (` -
-
-

Author's Books

-
-
${authorBooks}
- ` - ) -} - -let NameOfUser; -let isAuthenticated = false; - -async function constructAuthorPage(urlone, urlTwo) { - utility.enableLoader(rootElement, loader); - - try { - NameOfUser = await constructSection('/api/accounts/profile', utility.getUser); - isAuthenticated = true; - } catch (e) { - NameOfUser = 'Guest'; - } - - - let getAuthorDescHtml = await constructSection(urlone, constructAuthorDesc); - let getAuthorBooksHtml = await constructSection(urlTwo, constructAuthorBooksSection); - let mobilesidebarHtml = constructSidebar(isAuthenticated, NameOfUser); // is function ko phle component.js me check krle, tab arguements jo diye wo smj jayega - let topBarHtml = constructTopBar(authorName, "/", undefined); // jo bhi django ke according link ho wo daal diyo - let authorInfoContainer = `
` - sectionBottom = ` -
- ${getAuthorDescHtml} - ${getAuthorBooksHtml} -
- ` - contentWrapper = `
- ${topBarHtml} - ${authorInfoContainer} - ${sectionBottom} -
` - rootElement.innerHTML = mobilesidebarHtml + contentWrapper; - utility.disableLoader(rootElement, loader); - utility.addScrollEffect(); - utility.manageAboutSection(authorName); - utility.loadUtilityJs(); -} - -constructAuthorPage(authorDataURL, authorBooksURL, true) - .then(() => console.log("promise resolved")) - .catch((err) => console.log(err.message)); diff --git a/static/js/api handling/constructBookPage.js b/static/js/api handling/constructBookPage.js index 71c82b8..1e18d81 100644 --- a/static/js/api handling/constructBookPage.js +++ b/static/js/api handling/constructBookPage.js @@ -25,7 +25,7 @@ function constructItemAndDescSection(data) {

${data.name}

- ${data.author_details.map(author_detail => `

${author_detail.name}

`)} + ${data.author_details.map(author_detail => `

${author_detail.name}

`)}

Rs ${data.lowest_price.price} ( See All Offers )

@@ -61,6 +61,7 @@ function constructItemAndDescSection(data) { function constructSimilarBooksSection(data) { let similarBooks = ""; + data = data.filter(el => el.ISBN !== bookID) for (let i = 0; i < data.length; i++) { similarBooks += @@ -130,12 +131,14 @@ async function contsructBookPage(bookDataUrl, similarBooksUrl) { NameOfUser = 'Guest'; } - let booksInfoAndDescHtml = await constructSection(bookDataUrl, constructItemAndDescSection); - let similarBooksSectionHtml = await constructSection(similarBooksUrl, constructSimilarBooksSection); - let allOffersHtml = await constructSection(`/api/cart/deals/${bookID}`, constructAllOffers) + let booksInfoAndDescHtml = constructSection(bookDataUrl, constructItemAndDescSection); + let similarBooksSectionHtml = constructSection(similarBooksUrl, constructSimilarBooksSection); + let allOffersHtml = constructSection(`/api/cart/deals/${bookID}`, constructAllOffers) let mobilesidebarHtml = constructSidebar(isAuthenticated, NameOfUser); // is function ko phle component.js me check krle, tab arguements jo diye wo smj jayega let topBarHtml = constructTopBar("Book", "/", "/cart"); // jo bhi django ke according link ho wo daal diyo - let offersModal = ` + Promise.all([booksInfoAndDescHtml, similarBooksSectionHtml, allOffersHtml]) + .then(value => { + let offersModal = `
@@ -154,18 +157,19 @@ async function contsructBookPage(bookDataUrl, similarBooksUrl) {
` - contentWrapper = `
${topBarHtml} ${booksInfoAndDescHtml} ${similarBooksSectionHtml}
`; - rootElement.innerHTML = mobilesidebarHtml + contentWrapper + offersModal; + contentWrapper = `
${topBarHtml} ${value[0]} ${value[1]}
`; + rootElement.innerHTML = mobilesidebarHtml + contentWrapper + offersModal; - utility.disableLoader(rootElement, loader); + utility.disableLoader(rootElement, loader); - utility.loadUtilityJs(); - utility.manageBookNameLength() - utility.manageAboutSection(bookName); - utility.addDealToCart(); - utility.toggleButton("bookmark", "fa-bookmark", "fa-bookmark-o", "Bookmarked", "Bookmark"); - utility.toggleButton("addToCartBtn", "fa-check", "fa-cart-plus", "Added", "Add to Cart"); - utility.loadAccountModalJs(); + utility.loadUtilityJs(); + utility.manageBookNameLength() + utility.manageAboutSection(bookName); + utility.addDealToCart(); + utility.toggleButton("bookmark", "fa-bookmark", "fa-bookmark-o", "Bookmarked", "Bookmark"); + utility.toggleButton("addToCartBtn", "fa-check", "fa-cart-plus", "Added", "Add to Cart"); + utility.loadAccountModalJs(); + }) } contsructBookPage(bookDataURL, similarBookDataURL, true) diff --git a/static/js/api handling/constructBookmarkPage.js b/static/js/api handling/constructBookmarkPage.js index 7d5ad04..867a277 100644 --- a/static/js/api handling/constructBookmarkPage.js +++ b/static/js/api handling/constructBookmarkPage.js @@ -10,9 +10,7 @@ function constructBookmarkedList(data) { console.log(data) var bookmarkedBooks = ''; for (let i = 0; i < data.length; i++) { - let obj = { - // sb deta yha nikallene, uske baad obj.variableName Niche Html me kr dena - } + bookmarkedBooks += `
@@ -29,7 +27,7 @@ function constructBookmarkedList(data) {
-