def musicStorePendingList (request): pendingList = MusicStoreData.objects.select_related('userID').filter(userID__status="AdminPending", userID__verified_at__isnull= False)[:8] if pendingList: paginator = Paginator(pendingList,8) page_number = request.GET.get('page', 1) getReviewListByPage = paginator.get_page(page_number) if getReviewListByPage.has_next(): next_url = f'?page={getReviewListByPage.next_page_number()}' else: next_url = '' if getReviewListByPage.has_previous(): prev_url = f'?page={getReviewListByPage.previous_page_number()}' else: prev_url = '' else: getReviewListByPage = pendingList.none() next_url = '' prev_url = '' context = { 'obj': getReviewListByPage, 'userPending': countUserPending(request), 'reportUser': countReport(request), 'next_page_url': next_url, 'prev_page_url': prev_url, } return render(request,'userApproveList.html', context)
def brandControl(request): getAllBrand = brandFilters(request.GET, Brand.objects.order_by('brandName').all()) getAllBrandByPage = None if getAllBrand: paginator = Paginator(getAllBrand.qs, 4) page_number = request.GET.get('page', 1) getAllBrandByPage = paginator.get_page(page_number) if getAllBrandByPage.has_next(): next_url = getAllBrandByPage.next_page_number() else: next_url = '' if getAllBrandByPage.has_previous(): prev_url = getAllBrandByPage.previous_page_number() else: prev_url = '' else: getAllUsersByPage = Brand.objects.none() next_url = '' prev_url = '' context = { 'filter': getAllBrand, 'obj': getAllBrandByPage, 'userPending': countUserPending(request), 'reportUser': countReport(request), 'next_page_url': next_url, 'prev_page_url': prev_url } return render(request, 'brandcontrol.html', context)
def reportListView(request, user_select, brand, productName): try: getProduct = Product.objects.select_related('brandId').get( productName=productName, brandId__brandName=brand) obj = Review.objects.select_related('userID').get( productId=getProduct.productId, userID__userName=user_select) getReportReason = Report.objects.select_related('reviewId').filter( reviewId__reviewId=obj.reviewId).values('reason').distinct() getReportData = Report.objects.select_related( 'reviewId', 'userID').filter(reviewId__reviewId=obj.reviewId) context = { 'obj': obj, 'brand': brand, 'productName': productName, 'reportReasonList': getReportReason, 'reportData': getReportData, 'reportUser': countReport(request), 'userPending': countUserPending(request) } return render(request, 'reportListView.html', context) except Exception as e: print(e) context = {'message': 'error'} return render(request, 'error.html', context)
def viewProductByCategory(request, categoryName): isLogin = request.POST.get('isLogin') isForgotPass = request.POST.get('isForgotPassword') if request.method == 'POST' and isLogin == "1": loginAccount(request) elif request.method == 'POST' and isForgotPass == "1": forgotPassword(request) productList = None sort = request.GET.get('sort', 'rate') if sort == 'rate': productList = Product.objects.order_by('-avgScore').select_related( 'categoryId', 'brandId').filter(categoryId__categoryName=categoryName) else: productList = Product.objects.order_by('-dtm_crt').select_related( 'categoryId', 'brandId').filter(categoryId__categoryName=categoryName) getProductListByPage = None if productList: paginator = Paginator(productList, 12) page_number = request.GET.get('page', 1) getProductListByPage = paginator.get_page(page_number) if getProductListByPage.has_next(): next_url = getProductListByPage.next_page_number() else: next_url = '' if getProductListByPage.has_previous(): prev_url = getProductListByPage.previous_page_number() else: prev_url = '' else: getProductListByPage = Product.objects.none() next_url = '' prev_url = '' try: Category.objects.get(categoryName=categoryName) except: context = { 'message': "There is no category \"" + categoryName + "\" available" } return render(request, 'error.html', context) context = { 'productList': getProductListByPage, 'categoryName': categoryName, 'userPending': countUserPending(request), 'reportUser': countReport(request), 'next_page_url': next_url, 'prev_page_url': prev_url } return render(request, 'productListByCategory.html', context)
def reportList(request): reportUserList = [] with connection.cursor() as cursor: raw_sql = """ select u.userName, rev.title, p.productName, b.brandName, rev.dtm_crt, rev.rating from review_report as rep join review_review as rev on rev.reviewId = rep.reviewId_id join product_product as p on rev.productId_id = p.productId join product_brand as b on p.brandId_id = b.brandId join register_user as u on rev.userID_id = u.userID group by rep.reviewId_id """ cursor.execute(raw_sql) for qux in cursor.fetchall(): reportUserList.append({ 'userName': qux[0], 'reviewTitle': qux[1], 'productName': qux[2], 'productBrand': qux[3], 'dtm_crt': qux[4], 'ratingReview': qux[5] }) getReportListByPage = None if reportUserList: paginator = Paginator(reportUserList, 4) page_number = request.GET.get('page', 1) getReportListByPage = paginator.get_page(page_number) if getReportListByPage.has_next(): next_url = f'?page={getReportListByPage.next_page_number()}' else: next_url = '' if getReportListByPage.has_previous(): prev_url = f'?page={getReportListByPage.previous_page_number()}' else: prev_url = '' else: getReportListByPage = None next_url = '' prev_url = '' context = { 'obj': getReportListByPage, 'userPending': countUserPending(request), 'reportUser': countReport(request), 'next_page_url': next_url, 'prev_page_url': prev_url } return render(request, 'reportList.html', context)
def advanceSearch(request): isLogin = request.POST.get('isLogin') isForgotPass = request.POST.get('isForgotPassword') # isFilter = request.POST.get('IsFilter') resultFilter = None new_var = None if request.method == 'POST' and isLogin == "1": loginAccount(request) elif request.method == 'POST' and isForgotPass == "1": forgotPassword(request) new_var = productFilters(request.GET, Product.objects.all()) productName = None if 'productName' in request.GET: productName = request.GET['productName'] else: productName = '' if new_var: paginator = Paginator(new_var.qs, 8) page_number = request.GET.get('page', 1) getProductListByPage = paginator.get_page(page_number) if getProductListByPage.has_next(): next_url = getProductListByPage.next_page_number() else: next_url = '' if getProductListByPage.has_previous(): prev_url = getProductListByPage.previous_page_number() else: prev_url = '' else: getProductListByPage = Product.objects.none() next_url = '' prev_url = '' context = { 'productName': productName, 'filter': new_var, 'productList': getProductListByPage, 'userPending': countUserPending(request), 'reportUser': countReport(request), 'next_page_url': next_url, 'prev_page_url': prev_url } return render(request, 'productList.html', context)
def editorChoice(request): if request.method != 'POST': topList = [] with connection.cursor() as cursor: raw_sql = """ SELECT r.productId_id, FORMAT(AVG(r.rating), 1)'avg_score' FROM review_review as r GROUP BY r.productId_id ORDER BY avg_score DESC; """ cursor.execute(raw_sql) for qux in cursor.fetchall(): topList.append(qux[0]) productList = Product.objects.select_related('brandId').filter( productId__in=topList)[:10] precontext = [] for i in range(len(productList)): precontext.append([ productList[i], EditorForm( initial={'imageActive': productList[i].editorChoice}, prefix=productList[i].productId) ]) context = { 'data': precontext, 'userPending': countUserPending(request), 'reportUser': countReport(request) } return render(request, 'editorChoice.html', context) else: oldChoice = Product.objects.filter(editorChoice=True) for choice in oldChoice: choice.editorChoice = False choice.save() for key, value in request.POST.items(): if key == 'csrfmiddlewaretoken': continue id = key.split('-') product = Product.objects.get(productId=int(id[0])) product.editorChoice = True product.save() messages.success(request, 'Editor choice(s) successfully saved!') return redirect('editorchoice')
def hotItems(request): isLogin = request.POST.get('isLogin') isForgotPass = request.POST.get('isForgotPassword') if request.method == 'POST' and isLogin == "1": loginAccount(request) elif request.method == 'POST' and isForgotPass == "1": forgotPassword(request) productList = Product.objects.select_related('brandId').order_by( '-visitCount')[:8] getProductListByPage = None if productList: paginator = Paginator(productList, 12) page_number = request.GET.get('page', 1) getProductListByPage = paginator.get_page(page_number) if getProductListByPage.has_next(): next_url = f'?page={getProductListByPage.next_page_number()}' else: next_url = '' if getProductListByPage.has_previous(): prev_url = f'?page={getProductListByPage.previous_page_number()}' else: prev_url = '' else: getProductListByPage = Product.objects.none() next_url = '' prev_url = '' context = { 'productList': getProductListByPage, 'userPending': countUserPending(request), 'reportUser': countReport(request), 'next_page_url': next_url, 'prev_page_url': prev_url } return render(request, 'hotProducts.html', context)
def brandPage(request, brandName, sort): isLogin = request.POST.get('isLogin') isForgotPass = request.POST.get('isForgotPassword') if request.method == 'POST' and isLogin == "1": loginAccount(request) elif request.method == 'POST' and isForgotPass == "1": forgotPassword(request) error = 0 try: getBrand = Brand.objects.get(brandName=brandName) brandStatsData = [] error = 1 with connection.cursor() as cursor: raw_sql = """ with stats as( select ( select count(*) from product_product as p join product_brand as b on p.brandId_id = b.brandId where b.brandId = """ + str( getBrand.brandId) + """ and p.avgScore <= 10 and p.avgScore >=8 ) as positive, ( select count(*) from product_product as p join product_brand as b on p.brandId_id = b.brandId where b.brandId = """ + str( getBrand.brandId ) + """ and p.avgScore < 8 and p.avgScore >=5 ) as mixed, ( select count(*) from product_product as p join product_brand as b on p.brandId_id = b.brandId where b.brandId = """ + str( getBrand.brandId ) + """ and p.avgScore < 5 and p.avgScore > 0 ) as negative , b.brandName from product_product as p join product_brand as b on p.brandId_id = b.brandId where b.brandId = """ + str(getBrand.brandId) + """ ), maxMin as( select (select max(p.avgScore) from product_product as p join product_brand as b on p.brandId_id = b.brandId where b.brandId = """ + str( getBrand.brandId) + """ having max(p.avgScore) > 0 order by p.dtm_upd desc) as highRate, ( select p.productName from product_product as p join product_brand as b on p.brandId_id = b.brandId where p.avgScore = ( select max(p.avgScore) from product_product as p join product_brand as b on p.brandId_id = b.brandId where b.brandId = """ + str(getBrand.brandId) + """ having max(p.avgScore) > 0 ) and b.brandId = """ + str( getBrand.brandId) + """ order by p.dtm_upd desc limit 1 ) as highRateName, (select min(p.avgScore) from product_product as p join product_brand as b on p.brandId_id = b.brandId where b.brandId = """ + str( getBrand.brandId) + """ having min(p.avgScore) > 0 order by p.dtm_upd desc ) as minRate, ( select p.productName from product_product as p join product_brand as b on p.brandId_id = b.brandId where p.avgScore = ( select min(p.avgScore) from product_product as p join product_brand as b on p.brandId_id = b.brandId where b.brandId = """ + str(getBrand.brandId) + """ having min(p.avgScore) > 0 ) and b.brandId = """ + str( getBrand.brandId) + """ order by p.dtm_upd desc limit 1 ) as minRateName, b.brandName as brandName from product_product as p join product_brand as b on p.brandId_id = b.brandId where b.brandId = """ + str(getBrand.brandId) + """ ) select distinct (positive), mixed, negative, highRate, highRateName, minRate, minRateName from stats join maxMin using (brandName) """ cursor.execute(raw_sql) for qux in cursor.fetchall(): brandStatsData.append({ "positive": qux[0], "mixed": qux[1], "negative": qux[2], "highestRate": numIndicator(str(qux[3])), "highestRateName": qux[4], "lowestRate": numIndicator(str(qux[5])), "lowestRateName": qux[6] }) categoryList = [] categoryList.append({"category": "By Date"}) categoryList.append({"category": "By Rate"}) error = 1 with connection.cursor() as cursor: raw_sql = """ select distinct(c.categoryName) from product_product as p join product_brand as b on p.brandId_id = b.brandId join product_category as c on p.categoryId_id = c.categoryId where b.brandId = """ + str(getBrand.brandId) + """ """ cursor.execute(raw_sql) for qux in cursor.fetchall(): categoryList.append({"category": qux[0]}) getProductFromSort = None if sort == "By Date": getProductFromSort = Product.objects.order_by('-dtm_crt').filter( brandId=getBrand) elif sort == "By Rate": getProductFromSort = Product.objects.order_by('-avgScore').filter( brandId=getBrand) else: getCategory = Category.objects.get(categoryName=sort) getProductFromSort = Product.objects.order_by( 'productName').filter(brandId=getBrand, categoryId=getCategory) getProductByPage = None if getProductFromSort: paginator = Paginator(getProductFromSort, 5) page_number = request.GET.get('page', 1) getProductByPage = paginator.get_page(page_number) if getProductByPage.has_next(): next_url = f'?page={getProductByPage.next_page_number()}' else: next_url = '' if getProductByPage.has_previous(): prev_url = f'?page={getProductByPage.previous_page_number()}' else: prev_url = '' else: getProductByPage = Product.objects.none() next_url = '' prev_url = '' context = { 'brandData': brandStatsData, 'brand': getBrand, 'userPending': countUserPending(request), 'reportUser': countReport(request), 'sortObj': getProductByPage, 'categoryList': categoryList, 'sort': sort, 'next_page_url': next_url, 'prev_page_url': prev_url } return render(request, 'brandPage.html', context) except Exception as e: print(e) context = None if error == 0: context = {'message': "Brand " + brandName + " Not Found"} else: context = {'message': 'error'} return render(request, 'error.html', context)
def viewProductBySubCategory(request, categoryName, subCategoryName): error = 0 try: productList = None sort = request.GET.get('sort', 'rate') if sort == 'rate': productList = Product.objects.order_by('-avgScore').select_related( 'subCategoryId', 'brandId').filter( subCategoryId__subCategoryName=subCategoryName, categoryId__categoryName=categoryName) else: productList = Product.objects.order_by('-dtm_crt').select_related( 'subCategoryId', 'brandId').filter( subCategoryId__subCategoryName=subCategoryName, categoryId__categoryName=categoryName) SubCategory.objects.select_related('categoryId').get( subCategoryName=subCategoryName, categoryId__categoryName=categoryName) error = 1 getProductListByPage = None if productList: paginator = Paginator(productList, 12) page_number = request.GET.get('page', 1) getProductListByPage = paginator.get_page(page_number) if getProductListByPage.has_next(): next_url = getProductListByPage.next_page_number() else: next_url = '' if getProductListByPage.has_previous(): prev_url = getProductListByPage.previous_page_number() else: prev_url = '' else: getProductListByPage = Product.objects.none() next_url = '' prev_url = '' context = { 'productList': getProductListByPage, 'categoryName': categoryName, 'subCategoryName': subCategoryName, 'userPending': countUserPending(request), 'reportUser': countReport(request), 'next_page_url': next_url, 'prev_page_url': prev_url } except: context = None if error == 0: context = { 'message': "There is no category \"" + categoryName + "\" or subcategory \"" + subCategoryName + "\" available" } else: context = {'message': 'error'} return render(request, 'error.html', context) return render(request, 'productListByCategory.html', context)
def showProduct(request, productName, brand): isLogin = request.POST.get('isLogin') isForgotPass = request.POST.get('isForgotPassword') if request.method == 'POST' and isLogin == "1": loginAccount(request) elif request.method == 'POST' and isForgotPass == "1": forgotPassword(request) try: user_review = Review.objects.select_related( 'userID', 'productId').filter(userID__roleId="Reg_User", productId__productName=productName)[:5] ms_review = Review.objects.select_related( 'userID', 'productId').filter(userID__roleId="Mus_Store", productId__productName=productName)[:5] obj = Product.objects.select_related('brandId').get( productName=productName, brandId__brandName=brand) ratingUserScore = [] ratingMusicStore = [] userAvg = None musStoreAvg = None with connection.cursor() as cursor: raw_sql = """ with statsUser as ( select FORMAT(( (select count(*) from review_review as r join register_user as u on r.userID_id = u.userID where u.roleId like "%Reg_User%" and productId_id = """ + str( obj.productId) + """ and r.rating <= 10 and r.rating >=8) /(count(u.userID)) *100 ),0) as positive_user, FORMAT(( (select count(*) from review_review as r join register_user as u on r.userID_id = u.userID where u.roleId like "%Reg_User%" and productId_id = """ + str( obj.productId) + """ and r.rating < 8 and r.rating >=5) /(count(u.userID)) *100 ),0) as mixed_user, FORMAT(( (select count(*) from review_review as r join register_user as u on r.userID_id = u.userID where u.roleId like "%Reg_User%" and productId_id = """ + str( obj.productId) + """ and r.rating < 5 and r.rating >=0) /(count(u.userID)) *100 ),0) as negative_user, p.productId as productId from review_review as r join register_user as u on r.userID_id = u.userID join product_product as p on r.productId_id = p.productId where u.roleId like "%Reg_User%" and p.productId = """ + str( obj.productId) + """ ) select positive_user, mixed_user, negative_user from statsUser """ cursor.execute(raw_sql) for qux in cursor.fetchall(): ratingUserScore.append({ "positive_user": qux[0], "mixed_user": qux[1], "negative_user": qux[2] }) with connection.cursor() as cursor: raw_sql = """ with statsMusStore as ( select FORMAT(( (select count(*) from review_review as r join register_user as u on r.userID_id = u.userID where u.roleId like "%Mus_Store%" and productId_id = """ + str( obj.productId) + """ and r.rating <= 10 and r.rating >=8) /(count(u.userID)) *100 ),0) as positive_ms, FORMAT(( (select count(*) from review_review as r join register_user as u on r.userID_id = u.userID where u.roleId like "%Mus_Store%" and productId_id = """ + str( obj.productId) + """ and r.rating < 8 and r.rating >=5) /(count(u.userID)) *100 ),0) as mixed_ms, FORMAT(( (select count(*) from review_review as r join register_user as u on r.userID_id = u.userID where u.roleId like "%Mus_Store%" and productId_id = """ + str( obj.productId) + """ and r.rating < 5 and r.rating >=0) /(count(u.userID)) *100 ),0) as negative_ms, p.productId as productId from review_review as r join register_user as u on r.userID_id = u.userID join product_product as p on r.productId_id = p.productId where u.roleId like "%Mus_Store%" and p.productId = """ + str( obj.productId) + """ ) select positive_ms, mixed_ms, negative_ms from statsMusStore """ cursor.execute(raw_sql) for qux in cursor.fetchall(): ratingMusicStore.append({ "positive_music": qux[0], "mixed_music": qux[1], "negative_music": qux[2] }) with connection.cursor() as cursor: raw_sql = """ select FORMAT (avg(r.rating), 1) as user_avg from review_review as r join register_user as u on r.userID_id = u.userID join product_product as p on r.productId_id = p.productId where u.roleId like "%Reg_User%" and p.productId=""" + str( obj.productId) + """ """ cursor.execute(raw_sql) for qux in cursor.fetchall(): userAvg = numIndicator(qux[0]) with connection.cursor() as cursor: raw_sql = """ select FORMAT (avg(r.rating), 1) as Mus_store_avg from review_review as r join register_user as u on r.userID_id = u.userID join product_product as p on r.productId_id = p.productId where u.roleId like "%Mus_Store%" and p.productId=""" + str( obj.productId) + """ """ cursor.execute(raw_sql) for qux in cursor.fetchall(): musStoreAvg = numIndicator(qux[0]) username = None review_available = None messages = None getUser = request.user.username if getUser != '': username = request.user.username adminRoleCheck = request.user.groups.filter(name='Admin').exists() if adminRoleCheck == False: obj.visitCount = obj.visitCount + 1 obj.save() checkReview = Review.objects.select_related( 'userID', 'productId').filter(userID__userName=username, productId__productName=productName) if not checkReview: review_available = "enabled" else: review_available = "disabled" messages = "You cannot submit another review again" else: review_available = "disabled" messages = "You Need To Login First" otherProduct = Product.objects.order_by('-avgScore')[:10] context = { 'obj': obj, 'user_review': user_review, 'ms_review': ms_review, 'ratingUserScore': ratingUserScore, 'ratingMusicStore': ratingMusicStore, 'userAvg': userAvg, 'musStoreAvg': musStoreAvg, 'reviewStatus': review_available, 'messageModal': messages, 'userPending': countUserPending(request), 'reportUser': countReport(request), 'otherProduct': otherProduct, 'showMore': '' } return render(request, 'rating.html', context) except Exception as e: print(e) context = None context = { 'message': "Product \"" + productName + "\" from brand \"" + brand + "\" Not Found" } return render(request, 'error.html', context)
def profilePage(request, userName): isLogin = request.POST.get('isLogin') isForgotPass = request.POST.get('isForgotPassword') if request.method == 'POST' and isLogin == "1": loginAccount(request) elif request.method == 'POST' and isForgotPass == "1": forgotPassword(request) error = 0 try: getUser = User.objects.get(userName=userName) reviewList = Review.objects.select_related( 'productId', 'userID').order_by('-dtm_crt').filter( userID__userName=getUser.userName) error = 1 userStatsData = [] with connection.cursor() as cursor: raw_sql = """ with stats as( select (select count(*) from review_review as r join register_user as u on u.userID = r.userID_id where u.userID = """ + str( getUser.userID) + """ and r.rating <= 10 and r.rating >=8 ) as positive, ( select count(*) from review_review as r join register_user as u on u.userID = r.userID_id where u.userID = """ + str( getUser.userID) + """ and r.rating < 8 and r.rating >=5 ) as mixed, ( select count(*) from review_review as r join register_user as u on u.userID = r.userID_id where u.userID = """ + str( getUser.userID) + """ and r.rating < 5 and r.rating >=0 ) as negative , u.userID as UserID from review_review as r join register_user as u on r.userID_id = u.userID where u.userID = """ + str( getUser.userID) + """ ), maxMin as( select (select max(r.rating) from review_review as r join register_user as u on u.userID = r.userID_id join product_product as p on p.productId = r.productId_id where u.userID = """ + str( getUser.userID) + """ order by r.dtm_crt desc) as highRate, ( select b.brandName from review_review as r join register_user as u on u.userID = r.userID_id join product_product as p on p.productId = r.productId_id join product_brand as b on p.brandId_id = b.brandId where r.rating = ( select max(r.rating) from review_review as r join register_user as u on u.userID = r.userID_id join product_product as p on p.productId = r.productId_id where u.userID = """ + str( getUser.userID) + """ ) and u.userID = """ + str( getUser.userID) + """ order by r.dtm_crt desc limit 1 ) as highRateBrand, ( select p.productName from review_review as r join register_user as u on u.userID = r.userID_id join product_product as p on p.productId = r.productId_id where r.rating = ( select max(r.rating) from review_review as r join register_user as u on u.userID = r.userID_id join product_product as p on p.productId = r.productId_id where u.userID = """ + str( getUser.userID) + """ ) and u.userID = """ + str( getUser.userID) + """ order by r.dtm_crt desc limit 1 ) as highRateName, ( select min(r.rating) from review_review as r join register_user as u on u.userID = r.userID_id join product_product as p on p.productId = r.productId_id where u.userID = """ + str( getUser.userID) + """ order by r.dtm_crt desc) as minRate, ( select b.brandName from review_review as r join register_user as u on u.userID = r.userID_id join product_product as p on p.productId = r.productId_id join product_brand as b on p.brandId_id = b.brandId where r.rating = ( select min(r.rating) from review_review as r join register_user as u on u.userID = r.userID_id join product_product as p on p.productId = r.productId_id where u.userID = """ + str( getUser.userID) + """ ) and u.userID = """ + str( getUser.userID ) + """ order by r.dtm_crt desc limit 1 ) as minRateBrand, ( select p.productName from review_review as r join register_user as u on u.userID = r.userID_id join product_product as p on p.productId = r.productId_id where r.rating = ( select min(r.rating) from review_review as r join register_user as u on u.userID = r.userID_id join product_product as p on p.productId = r.productId_id where u.userID = """ + str( getUser.userID ) + """ ) and u.userID = """ + str( getUser.userID ) + """ order by r.dtm_crt desc limit 1 ) as minRateName, u.userID as UserID from review_review as r join register_user as u on r.userID_id = u.userID where u.userID = """ + str(getUser.userID ) + """ ) select distinct (positive), mixed, negative, highRate, highRateBrand, highRateName, minRate, minRateBrand, minRateName from stats join maxMin using (UserID) """ cursor.execute(raw_sql) for qux in cursor.fetchall(): userStatsData.append({ "positive": qux[0], "mixed": qux[1], "negative": qux[2], "highestRate": numIndicator(qux[3]), "highRateBrand": qux[4], "highestRateName": qux[5], "lowestRate": numIndicator(qux[6]), "lowestRateBrand": qux[7], "lowestRateName": qux[8] }) getReviewListByPage = None if reviewList: paginator = Paginator(reviewList, 4) page_number = request.GET.get('page', 1) getReviewListByPage = paginator.get_page(page_number) if getReviewListByPage.has_next(): next_url = f'?page={getReviewListByPage.next_page_number()}' else: next_url = '' if getReviewListByPage.has_previous(): prev_url = f'?page={getReviewListByPage.previous_page_number()}' else: prev_url = '' else: getReviewListByPage = Review.objects.none() next_url = '' prev_url = '' if getUser.roleId == 'Mus_Store': getUser = MusicStoreData.objects.select_related('userID').get( userID__userName=userName) context = { 'userData': userStatsData, 'obj': getReviewListByPage, 'User': getUser, 'userPending': countUserPending(request), 'reportUser': countReport(request), 'next_page_url': next_url, 'prev_page_url': prev_url } return render(request, 'profile.html', context) except Exception as e: print(e) context = None if error == 0: context = {'message': "User " + userName + " Not Found"} else: context = {'message': 'error'} return render(request, 'error.html', context)