def topic_articles_list(request, topic_name, topic_id): top_name = topic_name.replace('-', ' ') recent_articles = Articles.objects.raw( "SELECT A.*, AU.*, AI.image_url,AI.photopath FROM articles A LEFT JOIN article_author A_A ON A.article_id = A_A.article_id LEFT JOIN author AU ON A_A.author_id = AU.author_id LEFT JOIN article_images AI ON AI.article_id = A.article_id LEFT JOIN article_topics AT ON A.article_id = AT.article_id WHERE AT.topic_id = '" + topic_id + "' AND (AI.image_status='enabled' OR AI.image_status is null) GROUP BY A.article_id ORDER BY A.article_published_date DESC" ) paginator = Paginator(list(recent_articles), 6) # Show 6 articles per page page = request.GET.get('page') no_of_pages = range(1, paginator.num_pages + 1) try: articles = paginator.page(page) except PageNotAnInteger: # If page is not an integer, deliver first page. articles = paginator.page(1) except EmptyPage: # If page is out of range (e.g. 9999), deliver last page of results. articles = paginator.page(paginator.num_pages) sidebar_dta = sidebar_data() category_jumlist = category_jump_list() meta_title = top_name + ' - BW people - News about Indian Hotel Industry and Hospitality Business in India' meta_description = 'Follow the latest news about ' + top_name + ' in Indian Hospitality Sector' meta_keyword = top_name + ', BW people' og_title = 'BW pleople | ' + top_name og_url = '/topics/' + topic_name + '-' + topic_id og_image = settings.AWS_S3_BASE_URL + settings.BUCKET_PATH + 'static_bwhr/images/BW-people-logo.jpg' sidebar_zedo_ad = '' closeDbConnection() return render( request, 'article/listing.html', { "recent_articles": articles, 'sidebar_recent_articles': sidebar_dta['sidebar_recent_articles'], 'trending_now_topics': sidebar_dta['trending_now_topics'], 'bwtv_articles': sidebar_dta['bwtv_articles'], 'bwtv_cat_details': sidebar_dta['bwtv_cat_details'], 'no_of_pages': no_of_pages, 'page_title_h1': 'Latest Articles in ' + top_name, 'listing_page_url': '/topics-list/' + topic_id, 'view_page_url': '/topics/' + topic_name + '-' + topic_id, 'category_jumlist': category_jumlist, 'meta_title': meta_title, 'meta_description': meta_description, 'meta_keyword': meta_keyword, 'og_title': og_title, 'og_url': og_url, 'og_image': og_image, 'sidebar_zedo_ad': sidebar_zedo_ad, })
def exclusive_article(request): sidebar_zedo_ad = '' sidebar_dta = sidebar_data() category_jumlist = category_jump_list() recent_exclusive_article = Articles.objects.raw("SELECT A.*, AI.image_url, AI.photopath FROM articles A LEFT JOIN article_images AI ON A.article_id = AI.article_id WHERE A.is_exclusive = '1' GROUP BY A.article_id ORDER BY A.article_published_date DESC ") paginator = Paginator(list(recent_exclusive_article), 10) # Show 6 articles per page page = request.GET.get('page') no_of_pages = range(1, paginator.num_pages+1) pg_url = page try: recent_exclusive_article = paginator.page(page) page_no = int(page) except PageNotAnInteger: # If page is not an integer, deliver first page. recent_exclusive_article = paginator.page(1) pg_url = 1 page_no = 1 except EmptyPage: # If page is out of range (e.g. 9999), deliver last page of results. page_no = 1 recent_exclusive_article = paginator.page(paginator.num_pages) adjacent_pages = 5 #page_numbers = [n for n in \ range(paginator.num_pages - adjacent_pages, paginator.num_pages + adjacent_pages + 1) \ if n > 0 and n <= paginator.num_pages] page_numbers = [n for n in \ range(page_no - adjacent_pages, page_no + adjacent_pages + 1) \ if n > 0 and n <= page_no] meta_title = 'Web Exclusive Stories - BW wellness - Page '+str(page_no) meta_description = 'Web Exclusive stories from News and Updates for wellness in India from BW wellness. Page '+str(page_no)+' of the list.' og_title = 'Web Exclusive Stories - BW wellness - Page '+str(page_no) og_url = '/online-exclusive' og_image = settings.AWS_S3_BASE_URL + settings.BUCKET_PATH +'static_bwdiff/images/BW-wellness-logo.jpg' closeDbConnection() return render(request, 'webexclusive/webexclusivelisting.html', { 'recent_exclusive_article': recent_exclusive_article, 'category_jumlist': category_jumlist, 'quick_bytes_listing': sidebar_dta['quick_bytes_listing'], 'bwtv_cat_details': sidebar_dta['bwtv_cat_details'], 'sidebar_recent_articles': sidebar_dta['sidebar_recent_articles'], 'trending_now_topics': sidebar_dta['trending_now_topics'], 'sidebar_zedo_ad': sidebar_zedo_ad, 'meta_title': meta_title, 'meta_description': meta_description, 'og_title': og_title, 'og_url': og_url, 'og_image':og_image, 'page_numbers':page_numbers, 'show_first': 1 not in page_numbers, 'show_last': paginator.num_pages not in page_numbers, 'last_page': paginator.num_pages })
def get_newsletter_Subscriber_details(request): if request.method == 'POST': newsletter_type_id = request.POST['newsletter_type_id'] subscriber_email_id = request.POST['subscriber_email_id'] subscription_date = datetime.datetime.now().date() if (subscriber_email_id != ''): subscriber_details = NewsletterSubscriber.objects.raw( "SELECT newsletter_subscriber_id FROM newsletter_Subscriber WHERE newsletter_type_id = " + newsletter_type_id + " AND subscriber_email_id='" + subscriber_email_id + "'") closeDbConnection() if len(list(subscriber_details)) > 0: return HttpResponse(json.dumps( {"checkuser": "******"}), content_type="application/json") else: newsletter_Subscriber_details = NewsletterSubscriber( newsletter_type_id=newsletter_type_id, subscription_date=subscription_date, subscriber_email_id=subscriber_email_id, status='1') newsletter_Subscriber_details.save() closeDbConnection() return HttpResponse(json.dumps({"success": "this is happening"}), content_type="application/json") else: return HttpResponse(json.dumps({"error": "this isn't happening"}), content_type="application/json")
def recent_articles_listing_load(request): recent_articles = Articles.objects.raw("SELECT A.*, AU.*,AI.photopath, AI.image_url FROM articles A LEFT JOIN article_author A_A ON A.article_id = A_A.article_id LEFT JOIN author AU ON A_A.author_id = AU.author_id LEFT JOIN article_images AI ON AI.article_id = A.article_id WHERE (AI.image_status='enabled' OR AI.image_status is null) GROUP BY A.article_id ORDER BY A.article_published_date DESC") paginator = Paginator(list(recent_articles), 6) # Show 6 articles per page page = request.GET.get('page') no_of_pages = range(1, paginator.num_pages+1) try: articles = paginator.page(page) except PageNotAnInteger: # If page is not an integer, deliver first page. articles = paginator.page(1) except EmptyPage: # If page is out of range (e.g. 9999), deliver last page of results. articles = paginator.page(paginator.num_pages) sidebar_dta = sidebar_data() sidebar_zedo_ad = '' closeDbConnection() return render(request, 'article/listing_load.html', { "recent_articles": articles, 'sidebar_recent_articles': sidebar_dta['sidebar_recent_articles'], 'trending_now_topics': sidebar_dta['trending_now_topics'], 'quick_bytes_listing': sidebar_dta['quick_bytes_listing'], 'bwtv_cat_details': sidebar_dta['bwtv_cat_details'], 'no_of_pages': no_of_pages, 'sidebar_zedo_ad': sidebar_zedo_ad, })
def quickbytes_load(request, quick_byte_title, quick_byte_published_date, quick_byte_id): quickbytes_detail = QuickBytes.objects.raw( "SELECT * FROM quick_bytes WHERE quick_byte_id != " + quick_byte_id + " ") paginator = Paginator(list(quickbytes_detail), 1) # Show 6 articles per page page = request.GET.get('page') no_of_pages = range(1, paginator.num_pages + 1) try: quickbytes = paginator.page(page) except PageNotAnInteger: # If page is not an integer, deliver first page. quickbytes = paginator.page(1) except EmptyPage: # If page is out of range (e.g. 9999), deliver last page of results. articles = paginator.page(paginator.num_pages) sidebar_dta = sidebar_data() closeDbConnection() return render(request, 'article/quickbytes_load.html', { "recent_articles": quickbytes, 'no_of_pages': no_of_pages })
def sponserLanding(request, sponsoredposts_title, sponsoredposts_published_date, sponsoredposts_id): global art_description_output sponsoredposts_title = sponsoredposts_title.replace('-', ' ') sponsoredposts_detail = Sponsoredposts.objects.raw( "SELECT S.*, SI.image_url FROM sponsoredposts S LEFT JOIN sponsoredposts_images SI ON SI.sponsoredposts_id = S.sponsoredposts_id WHERE S.sponsoredposts_id = " + sponsoredposts_id + " AND S.sponsoredposts_title = '" + sponsoredposts_title + "' AND SI.image_status='enabled' GROUP BY S.sponsoredposts_id ORDER BY S.sponsoredposts_published_date DESC" ) #view count entry view_date = datetime.datetime.now().date() view_time = datetime.datetime.now().time() new_entry_sponsoredposts_view = SponsoredpostsView( sponsoredposts_id=sponsoredposts_id, view_date=view_date, view_time=view_time, sponsoredposts_published_date=sponsoredposts_detail[0]. sponsoredposts_published_date) new_entry_sponsoredposts_view.save() #end sponsoredposts_description = sponsoredposts_detail[ 0].sponsoredposts_description related_articles = Articles.objects.raw( "SELECT T.article_id ,COUNT(T.article_id), A.*, AI.image_url FROM articles A JOIN article_images AI ON AI.article_id = A.article_id LEFT JOIN article_tags T ON T.article_id = A.article_id GROUP BY T.article_id HAVING COUNT(T.article_id)<=(SELECT MAX(mycount) FROM (SELECT article_id, COUNT(article_id) mycount FROM article_tags GROUP BY article_id ) as temp ) " ) #maximum_used_tags = ChannelTags.objects.raw("SELECT T . * , COUNT( A.article_id ) AS count FROM channel_tags T LEFT JOIN article_tags AT ON AT.tag_id = T.tag_id LEFT JOIN articles A ON AT.article_id = A.article_id GROUP BY T.tag_id ORDER BY count DESC") sidebar_dta = sidebar_data() category_jumlist = category_jump_list() sponsored_detail = Sponsoredposts.objects.raw( "SELECT S.*, SI.image_url FROM sponsoredposts S LEFT JOIN sponsoredposts_images SI ON SI.sponsoredposts_id = S.sponsoredposts_id ORDER BY S.sponsoredposts_published_date DESC LIMIT 2" ) sidebar_zedo_ad = '' closeDbConnection() return render( request, 'sponsor/sponsor_landing_view.html', { 'sponsoredposts_detail': sponsoredposts_detail[0], 'sponsoredposts_description': sponsoredposts_description, 'quick_bytes_listing': sidebar_dta['quick_bytes_listing'], 'bwtv_cat_details': sidebar_dta['bwtv_cat_details'], 'sidebar_recent_articles': sidebar_dta['sidebar_recent_articles'], 'related_content': related_articles, 'trending_now_topics': sidebar_dta['trending_now_topics'], 'category_jumlist': category_jumlist, 'sponsored_detail': sponsored_detail, 'sidebar_zedo_ad': sidebar_zedo_ad, })
def photo_shoot(request): photoshoot_listing = PhotoShoot.objects.raw("SELECT count(*) as counts, ps.*,psp.photo_shoot_photo_url, psp.photo_shoot_image_id , psp.photo_shoot_photo_name FROM photo_shoot_photos psp join photo_shoot ps on psp.photo_shoot_id=ps.photo_shoot_id group by psp.photo_shoot_id ORDER BY ps.photo_shoot_id DESC LIMIT 0,5") closeDbConnection() return render(request, 'photoshoot/photo_shoot.html', { 'photoshoot_listing':photoshoot_listing })
def column_articles_list(request, column_name, column_id): column_details = Columns.objects.raw("SELECT C.*, AU.*, AAU.*, A.* FROM columns C LEFT JOIN author AU ON AU.column_id=C.column_id LEFT JOIN article_author AAU ON AAU.author_id=AU.author_id LEFT JOIN articles A ON A.article_id = AAU.article_id where AU.author_type = 4 AND C.column_id = "+column_id ) #column_author_image = Columns.objects.raw("SELECT C.*,AU.* FROM columns C LEFT JOIN author AU ON AU.column_id=C.column_id where AU.author_type = 4 AND C.column_id = "+column_id+" LIMIT 3 ") column_author_image = Author.objects.raw("SELECT C.*, AU.* FROM columns C LEFT JOIN author AU ON AU.column_id=C.column_id where AU.author_type = 4 AND C.column_id = "+column_id+" LIMIT 3 ") columnist = Author.objects.raw("SELECT * FROM (SELECT AU.*, AR.article_published_date FROM author AU INNER JOIN article_author ARU ON AU.author_id = ARU.author_id INNER JOIN articles AR ON ARU.article_id = AR.article_id WHERE AU.author_type='4' ORDER BY AR.article_published_date DESC) AS tem GROUP BY tem.author_id LIMIT 6") columinist_names = '' for c in columnist: columinist_names += c.author_name+', ' columnist_label = AuthorType.objects.filter(author_type_id = '4').first() author_label = columnist_label.author_type_for_url sidebar_dta = sidebar_data() category_jumlist = category_jump_list() meta_title = column_details[0].column_name+' - '+columinist_names+' - BW defence' meta_description = 'Column Name by '+columinist_names meta_keyword = column_details[0].column_name+', '+columinist_names+' BW defence' og_title= 'BW defence | '+column_details[0].column_name og_url= '/column/'+column_name+'-'+column_id og_image= settings.AWS_S3_BASE_URL + settings.BUCKET_PATH +'static_bwdiff/images/BW-defence-logo.jpg' sidebar_zedo_ad = '' closeDbConnection() return render(request, 'column/column_landing.html',{ 'column_details': column_details, 'column_author_image': column_author_image, 'sidebar_recent_articles': sidebar_dta['sidebar_recent_articles'], 'trending_now_topics': sidebar_dta['trending_now_topics'], 'quick_bytes_listing': sidebar_dta['quick_bytes_listing'], 'bwtv_cat_details': sidebar_dta['bwtv_cat_details'], 'category_jumlist': category_jumlist, 'columnist': columnist, 'author_label': author_label, 'meta_title': meta_title, 'meta_description': meta_description, 'meta_keyword': meta_keyword, 'og_title': og_title, 'og_url': og_url, 'og_image': og_image, 'sidebar_zedo_ad': sidebar_zedo_ad, })
def category_articles_list_load(request, category_id): #cat_name = ChannelCategory.objects.filter(category_id=category_id).first() recent_articles = Articles.objects.raw("SELECT A.*, AU.*, AI.image_url,AI.photopath FROM articles A LEFT JOIN article_author A_A ON A.article_id = A_A.article_id LEFT JOIN author AU ON A_A.author_id = AU.author_id LEFT JOIN article_images AI ON AI.article_id = A.article_id LEFT JOIN article_category AC ON A.article_id = AC.article_id WHERE AC.category_id = '"+category_id+"' AND (AI.image_status='enabled' OR AI.image_status is null) GROUP BY A.article_id ORDER BY A.article_published_date DESC") paginator = Paginator(list(recent_articles), 6) # Show 6 articles per page page = request.GET.get('page') no_of_pages = range(1, paginator.num_pages+1) category_details = ChannelCategory.objects.filter(category_id=category_id).first() cat_name = str(category_details.category_name) try: articles = paginator.page(page) except PageNotAnInteger: # If page is not an integer, deliver first page. articles = paginator.page(1) except EmptyPage: # If page is out of range (e.g. 9999), deliver last page of results. articles = paginator.page(paginator.num_pages) sidebar_dta = sidebar_data() meta_title = cat_name+' - BW defence - News about News and Updates for defence in India' meta_description = 'Follow the latest news about ' +cat_name+' in News and Updates for defence in India' meta_keyword = cat_name+', BW defence' og_title= 'BW defence | '+cat_name og_url= '/category/'+str(category_details.category_name_for_url)+'-'+category_id og_image= settings.AWS_S3_BASE_URL + settings.BUCKET_PATH +'static_bwdiff/images/BW-defence-logo.jpg' sidebar_zedo_ad = '' closeDbConnection() return render(request, 'article/listing_load.html', { "recent_articles": articles, 'sidebar_recent_articles': sidebar_dta['sidebar_recent_articles'], 'trending_now_topics': sidebar_dta['trending_now_topics'], 'quick_bytes_listing': sidebar_dta['quick_bytes_listing'], 'bwtv_articles': sidebar_dta['bwtv_articles'], 'bwtv_cat_details': sidebar_dta['bwtv_cat_details'], 'no_of_pages': no_of_pages, 'sidebar_zedo_ad': sidebar_zedo_ad, })
def business_entertainment(request): recent_entertainment_list = Articles.objects.raw( "SELECT A.*, AU.*,AI.photopath, AI.image_url FROM articles A LEFT JOIN article_author A_A ON A.article_id = A_A.article_id LEFT JOIN author AU ON A_A.author_id = AU.author_id LEFT JOIN article_images AI ON A.article_id = AI.article_id LEFT JOIN article_category AC ON A.article_id = AC.article_id WHERE AC.category_id = '64' GROUP BY A.article_id ORDER BY A.article_published_date DESC LIMIT 1, 6" ) recent_entertainment = Articles.objects.raw( "SELECT A.*, AU.*, AI.photopath,AI.image_url FROM articles A LEFT JOIN article_author A_A ON A.article_id = A_A.article_id LEFT JOIN author AU ON A_A.author_id = AU.author_id LEFT JOIN article_images AI ON A.article_id = AI.article_id LEFT JOIN article_category AC ON A.article_id = AC.article_id WHERE AC.category_id = '64' GROUP BY A.article_id ORDER BY A.article_published_date DESC LIMIT 1" ) closeDbConnection() return render( request, 'businessentertainment/business-of-entertainment.html', { 'recent_entertainment_list': recent_entertainment_list, 'recent_entertainment': recent_entertainment })
def article_list_time_wise(request,article_published_date): sidebar_zedo_ad = '' sidebar_dta = sidebar_data() category_jumlist = category_jump_list() today = datetime.datetime.strptime(article_published_date, "%d-%B-%Y") todays =str(today)[:10] article_list_time = Articles.objects.raw("SELECT A.*, AI.image_url, AI.photopath FROM articles A LEFT JOIN article_images AI ON A.article_id = AI.article_id WHERE DATE_FORMAT(article_published_date, '%%Y-%%m-%%d')= '"+str(todays)+"' GROUP BY A.article_id ORDER BY A.article_published_date DESC") paginator = Paginator(list(article_list_time), 10) # Show 6 articles per page page = request.GET.get('page') no_of_pages = range(1, paginator.num_pages+1) pg_url = page try: article_list_time = paginator.page(page) page_no = int(page) except PageNotAnInteger: # If page is not an integer, deliver first page. article_list_time = paginator.page(1) pg_url = 1 page_no = 1 except EmptyPage: # If page is out of range (e.g. 9999), deliver last page of results. page_no = 1 article_list_time = paginator.page(paginator.num_pages) adjacent_pages = 5 #page_numbers = [n for n in \ range(paginator.num_pages - adjacent_pages, paginator.num_pages + adjacent_pages + 1) \ if n > 0 and n <= paginator.num_pages] page_numbers = [n for n in \ range(page_no - adjacent_pages, page_no + adjacent_pages + 1) \ if n > 0 and n <= page_no] meta_title = 'News and Updates for wellness Business in India on' +todays meta_description = 'List of news, opinion and analysis stories published on '+todays+' on BW wellness. Page 1 of list' og_image = settings.AWS_S3_BASE_URL + settings.BUCKET_PATH +'static_bwhr/images/BW-wellness-logo.jpg' og_title = 'News and Updates for wellness in India Business in India on'+todays og_url = '/date/ '+str(today) closeDbConnection() return render(request, 'article/article_listing_time_wise.html', { 'article_list_time': article_list_time, 'category_jumlist': category_jumlist, 'quick_bytes_listing': sidebar_dta['quick_bytes_listing'], 'bwtv_cat_details': sidebar_dta['bwtv_cat_details'], 'sidebar_recent_articles': sidebar_dta['sidebar_recent_articles'], 'trending_now_topics': sidebar_dta['trending_now_topics'], 'sidebar_zedo_ad': sidebar_zedo_ad, 'meta_title': meta_title, 'meta_description': meta_description, 'og_image':og_image, 'og_title': og_title, 'og_url': og_url, 'today':today, 'page_numbers':page_numbers, 'show_first': 1 not in page_numbers, 'show_last': paginator.num_pages not in page_numbers, 'last_page': paginator.num_pages })
def quickbyteslanding(request, quick_byte_title, quick_byte_published_date, quick_byte_id): sidebar_dta = sidebar_data() category_jumlist = category_jump_list() sidebar_zedo_ad = '<!-- Javascript tag --><!-- begin ZEDO for channel: Quick Bytes LP , publisher: bwhr , Ad Dimension: Medium Rectangle-300x250-QB-LP - 300 x 250 --><script language="JavaScript">var zflag_nid="3336"; var zflag_cid="3"; var zflag_sid="1"; var zflag_width="300"; var zflag_height="250"; var zflag_sz="20";</script><script language="JavaScript" src="http://xp2.zedo.com/jsc/xp2/fo.js"></script><!-- end ZEDO for channel: Quick Bytes LP , publisher: bwhr , Ad Dimension: Medium Rectangle-300x250-QB-LP - 300 x 250 -->' #quickbytes_detail = QuickBytes.objects.raw("SELECT * FROM quick_bytes WHERE quick_byte_id = "+quick_byte_id+" ") quickbytes_detail = QuickBytes.objects.filter( quick_byte_id=quick_byte_id).first() if quickbytes_detail: author_details = Author.objects.raw( "SELECT AU.*, AUTYPE.* FROM author AU INNER JOIN quick_bytes QB ON QB.quick_byte_author_id = AU.author_id JOIN author_type AUTYPE ON AU.author_type = AUTYPE.author_type_id WHERE QB.quick_byte_id = " + quick_byte_id) if len(list(author_details)) > 0: author_label = author_details[0].label.replace(' ', '-') else: author_label = '' quickbytes_tags = ChannelTags.objects.raw( "SELECT t.* FROM channel_tags t INNER JOIN quick_bytes_tags qt ON t.tag_id = qt.tag_id WHERE qt.quick_byte_id = " + quick_byte_id) tag_names = '' for tag in quickbytes_tags: tag_names = tag_names + ', ' + tag.tag_name '''quickbytes_topics = ChannelTopics.objects.raw("SELECT t.* FROM channel_topics t INNER JOIN quick_bytes_topic qt ON t.topic_id = qt.topic_id WHERE qt.quick_byte_id = "+quick_byte_id) topic_names = '' for topic in quickbytes_topics: topic_names = topic_names+', '+topic.topic_name''' #related_articles = QuickBytes.objects.raw("SELECT ar.*, ia.quick_byte_photo_url, ia.quick_byte_photo_name, COUNT(*) AS tagcount FROM (SELECT tag_id AS id FROM quick_bytes_tags WHERE quick_byte_id="+quick_byte_id+") AS t1 JOIN quick_bytes_tags t2 ON t1.id=t2.tag_id JOIN quick_bytes_photos ia ON t2.quick_byte_id=ia.quick_byte_id JOIN quick_bytes ar ON t2.quick_byte_id=ar.quick_byte_id GROUP BY t2.quick_byte_id HAVING t2.quick_byte_id!="+quick_byte_id+" ORDER BY tagcount DESC") next_quick_byte = quickbytes_detail.get_next() prev_quick_byte = quickbytes_detail.get_prev() quick_bytes_image = QuickBytesPhotos.objects.filter( quick_byte_id=quick_byte_id).order_by('sequence').first() if quick_bytes_image: all_image_sequence_count = QuickBytesPhotos.objects.filter( quick_byte_id=quick_byte_id).filter( Q(sequence=None) | Q(sequence=0)).count() if all_image_sequence_count > 1: next_quick_byte_pic = quick_bytes_image.get_next_pic_quick_byte( ) prev_quick_byte_pic = quick_bytes_image.get_prev_pic_quick_byte( ) else: next_quick_byte_pic = quick_bytes_image.get_next_pic_sequence() prev_quick_byte_pic = quick_bytes_image.get_prev_pic_sequence() else: next_quick_byte_pic = [] prev_quick_byte_pic = [] #meta_title = '' if len(list(author_details)) > 0: page_author_name = author_details[0].author_name if author_details[0].author_type != 1 and author_details[ 0].author_type != 2: meta_title = quickbytes_detail.quick_byte_title + '-' + author_details[ 0].author_name + ' - BW defence' meta_description = author_details[ 0].author_name + ' - ' + quickbytes_detail.quick_byte_description + ', ' + tag_names else: meta_title = quickbytes_detail.quick_byte_title + ' - BW defence' meta_description = quickbytes_detail.quick_byte_description + ', ' + tag_names else: page_author_name = 'BW defence' meta_title = quickbytes_detail.quick_byte_title + ' - BW defence' meta_description = quickbytes_detail.quick_byte_description + ', ' + tag_names meta_keyword = tag_names og_title = quickbytes_detail.quick_byte_title og_url = '/quickbytes/' + quick_byte_title + '/' + quick_byte_published_date + '-' + quick_byte_id if not quick_bytes_image: og_image = settings.AWS_S3_BASE_URL + settings.BUCKET_PATH + 'static_bwdiff/images/BW-defence-logo.jpg' else: og_image = settings.AWS_S3_BASE_URL + settings.BUCKET_PATH + settings.QUICKBYTES_IMAGE_EXTRA_LARGE_PATH + quick_bytes_image.quick_byte_photo_name #sponsored_detail = Sponsoredposts.objects.raw("SELECT S.*, SI.image_url FROM sponsoredposts S LEFT JOIN sponsoredposts_images SI ON SI.sponsoredposts_id = S.sponsoredposts_id ORDER BY S.sponsoredposts_published_date DESC LIMIT 2") #feeds_cric = feedparser.parse('http://bwcio.com/feed/') #feeds_bws = feedparser.parse('http://bwsmartcities.com/feed') #feeds_bwh = feedparser.parse('http://bwhotelier.com/feed/') closeDbConnection() return render( request, 'quickbytes/quickbytes_landing.html', { 'quickbytes_detail': quickbytes_detail, #'quickbytes_related_articles': related_articles, 'sidebar_recent_articles': sidebar_dta['sidebar_recent_articles'], 'trending_now_topics': sidebar_dta['trending_now_topics'], 'quick_bytes_listing': sidebar_dta['quick_bytes_listing'], 'bwtv_cat_details': sidebar_dta['bwtv_cat_details'], 'next_quick_byte': next_quick_byte, 'prev_quick_byte': prev_quick_byte, 'next_quick_byte_pic': next_quick_byte_pic, 'prev_quick_byte_pic': prev_quick_byte_pic, 'quick_bytes_image': quick_bytes_image, 'author_details': author_details, 'author_label': author_label, 'quickbytes_tags': quickbytes_tags, 'category_jumlist': category_jumlist, 'meta_title': meta_title, 'meta_description': meta_description, 'meta_keyword': meta_keyword, 'og_title': og_title, 'og_url': og_url, 'og_image': og_image, #'sponsored_detail':sponsored_detail, #'feeds_cric':feeds_cric, #'feeds_bws':feeds_bws, #'feeds_bwh':feeds_bwh, 'sidebar_zedo_ad': sidebar_zedo_ad, 'page_author_name': page_author_name, }) else: meta_title = 'Quickbytes - BW people' meta_description = 'Quickbytes' meta_keyword = 'Quickbytes' og_title = 'Quickbytes - BW people' #og_url= article_detail[0].get_absolute_url og_image = settings.AWS_S3_BASE_URL + settings.BUCKET_PATH + 'static_bwhr/images/BW-people-logo.jpg' return render( request, 'quickbytes/quickbytes_not_found.html', { 'qyickbytes_content': sidebar_dta['quick_bytes'], 'sidebar_recent_articles': sidebar_dta['sidebar_recent_articles'], 'trending_now_topics': sidebar_dta['trending_now_topics'], 'videomaster_listing': sidebar_dta['videomaster_listing'], 'bwtv_cat_details': sidebar_dta['bwtv_cat_details'], 'category_jumlist': category_jumlist, 'meta_title': meta_title, 'meta_description': meta_description, 'meta_keyword': meta_keyword, 'og_title': og_title, #'og_url': og_url, 'og_image': og_image, 'sidebar_zedo_ad': sidebar_zedo_ad, })
def articleLanding(request, article_title, article_published_date, article_id): global art_description_output #Sidebar and other data to be used in base template sidebar_dta = sidebar_data() category_jumlist = category_jump_list() sidebar_zedo_ad = '' url_article_title = article_title article_title = article_title.replace('-', ' ') article_detail = Articles.objects.raw("SELECT A.*,AI.photopath, AI.image_url, AI.image_title FROM articles A LEFT JOIN article_author A_A ON A.article_id = A_A.article_id LEFT JOIN article_images AI ON A.article_id = AI.article_id WHERE A.article_id = "+article_id+" AND (AI.image_status='enabled' OR AI.image_status is null)") if len(list(article_detail)) > 0: #view count entry view_date = datetime.datetime.now().date() view_time = datetime.datetime.now().time() new_entry_artcle_view = ArticleView(article_id=article_id, view_date=view_date, view_time=view_time, article_published_date=article_detail[0].article_published_date) new_entry_artcle_view.save() total_article_view = ArticleTotalView.objects.filter(article_id=article_id).first() #return HttpResponse(total_article_view.total_view) if(total_article_view): total_view = int(total_article_view.total_view) + 1 total_view = int(total_view) total_article_view = ArticleTotalView.objects.get(article_id=article_id) total_article_view.total_view = total_view total_article_view.save() else: total_article_view = ArticleTotalView(article_id=article_id, total_view=1) total_article_view.save() #end #video url if(article_detail[0].video_type == 'uploadedvideo'): #video_master video_uploaded = VideoMaster.objects.filter(video_id=article_detail[0].video_Id).first() article_video = settings.AWS_S3_BASE_URL + settings.BUCKET_PATH + settings.VIDEO_MASTER + video_uploaded.video_name article_vid_thumb = settings.AWS_S3_BASE_URL + settings.BUCKET_PATH + settings.VIDEO_THUMB + video_uploaded.video_thumb_name elif(article_detail[0].video_type == 'embededvideocode'): video_embeded = ArticleVideo.objects.filter(article_id=article_id).first() article_video = video_embeded.video_embed_code.strip() article_vid_thumb = '' else: article_video = '' article_vid_thumb = '' #end #article image for og_image article_first_image = ArticleImages.objects.filter(article_id=article_id)[:1] #article_first_image = '' #end #article images for page slider article_all_image_count = ArticleImages.objects.filter(article_id=article_id).filter(image_status='enabled').count() article_all_image = ArticleImages.objects.filter(article_id=article_id).filter(image_status='enabled') #end article_description = article_detail[0].article_description article_tags = ChannelTags.objects.raw("SELECT t.* FROM channel_tags t INNER JOIN article_tags at ON t.tag_id = at.tag_id WHERE at.article_id = "+article_id) tag_names = '' for tag in article_tags: tag_names = tag_names+', '+tag.tag_name column_details = '' author_details = Author.objects.raw("SELECT AU.*, AUTYPE.* FROM author AU INNER JOIN article_author A_A ON A_A.author_id = AU.author_id JOIN author_type AUTYPE ON AU.author_type = AUTYPE.author_type_id WHERE A_A.article_id = "+article_id) if len(list(author_details)) > 0: author_label = author_details[0].label.replace(' ', '-') if author_details[0].author_type == 4: column_details = Columns.objects.raw("SELECT C.* FROM columns C LEFT JOIN author AU ON AU.column_id = C.column_id WHERE AU.author_id = "+str(author_details[0].author_id)) else: author_label = '' #article_topic = ArticleTopics.objects.raw("SELECT T.* FROM article_topics AT LEFT JOIN channel_topics T ON AT.topic_id = T.topic_id WHERE AT.article_id = " + article_id) '''article_topic = ChannelTopics.objects.raw("SELECT t.* FROM channel_topics t INNER JOIN article_topics at ON t.topic_id = at.topic_id WHERE at.article_id = "+article_id) cat_regex = '' topic_names = '' for topic in article_topic: topic_names = topic_names+', '+topic.topic_name topic_nm = topic.topic_name.replace(' ', '-') topicId = str(topic.topic_id) topic_url = "/topics/"+topic_nm+"-"+topicId article_description = article_description.replace(topic.topic_name, "<a href='"+topic_url+"' style='text-decoration:underline'>"+topic.topic_name+"</a>") ''' html_parser = HTMLParser.HTMLParser() article_description = html_parser.unescape(article_description) article_categories = ChannelCategory.objects.raw("SELECT C.* FROM channel_category C LEFT JOIN article_category AC ON AC.category_id = C.category_id WHERE AC.article_id = "+article_id) category_names = '' for category in article_categories: category_names = category_names+', '+category.category_name #Newsletter #newsletter = NewsletterTbl.objects.order_by('?').first() #next_article = article_detail.get_recent_article_descending(); next_article = article_detail[0].get_recent_article_descending() previous_article = article_detail[0].get_recent_article_ascending() #Meta title and descriptons meta_title = article_title+' - BW wellness' meta_description = 'News and Updates for wellness in India - ' + category_names + '-' + article_detail[0].article_summary meta_keyword = tag_names og_title= article_title og_url= article_detail[0].get_absolute_url if len(list(article_first_image)) > 0: if(article_detail[0].is_old == 1): og_image= article_first_image[0].image_url else: og_image= settings.AWS_S3_BASE_URL + settings.BUCKET_PATH + settings.ARTICLE_IMAGE_LARGE_PATH + article_first_image[0].photopath else: og_image= settings.AWS_S3_BASE_URL + settings.BUCKET_PATH +'static_bwdiff/images/BW-wellness-logo.jpg' if(article_detail[0].canonical_options == 1): canoical_tag = '<link rel="canonical" href="'+article_detail[0].canonical_url+'" />' else: canoical_tag = '<link rel="canonical" href="http://bwwellness.businessworld.in/article/'+url_article_title+'/'+article_published_date+'-'+article_id+'" />' amp_tag = '<link rel="amphtml" href="http://bwwellness.businessworld.in/amp/article/'+url_article_title+'/'+article_published_date+'-'+article_id+'" />' closeDbConnection() return render(request, 'article/article_landing_with_author.html',{ 'article_detail': article_detail[0], 'article_description': article_description, 'article_tags': article_tags, 'author_details': author_details, 'author_label': author_label, 'column_details': column_details, 'article_video': article_video, 'article_vid_thumb': article_vid_thumb, 'sidebar_recent_articles': sidebar_dta['sidebar_recent_articles'], 'trending_now_topics': sidebar_dta['trending_now_topics'], 'quick_bytes_listing': sidebar_dta['quick_bytes_listing'], 'bwtv_cat_details': sidebar_dta['bwtv_cat_details'], 'category_jumlist': category_jumlist, 'meta_title': meta_title, 'meta_description': meta_description, 'meta_keyword': meta_keyword, 'og_title': og_title, 'og_url': og_url, 'og_image': og_image, 'amp_tag':amp_tag, 'article_all_image': article_all_image, 'article_all_image_count': article_all_image_count, 'next_article': next_article, 'previous_article': previous_article, 'sidebar_zedo_ad': sidebar_zedo_ad, 'canoical_tag': canoical_tag, }) else: meta_title = 'Article - BW wellness' meta_description = 'Article' meta_keyword = 'Article' og_title= 'Article - BW wellness' #og_url= article_detail[0].get_absolute_url og_image= settings.AWS_S3_BASE_URL + settings.BUCKET_PATH +'static_bwdiff/images/BW-wellness-logo.jpg' return render(request, 'article/article_not_found.html',{ 'sidebar_recent_articles': sidebar_dta['sidebar_recent_articles'], #'related_content':related_articles, 'trending_now_topics': sidebar_dta['trending_now_topics'], 'quick_bytes_listing': sidebar_dta['quick_bytes_listing'], 'bwtv_cat_details': sidebar_dta['bwtv_cat_details'], 'category_jumlist': category_jumlist, 'meta_title': meta_title, 'meta_description': meta_description, 'meta_keyword': meta_keyword, 'og_title': og_title, #'og_url': og_url, 'og_image': og_image, 'sidebar_zedo_ad': sidebar_zedo_ad, })
def recent_articles_listing(request): recent_articles = Articles.objects.raw("SELECT A.*, AU.*, AI.image_url,AI.photopath FROM articles A LEFT JOIN article_author A_A ON A.article_id = A_A.article_id LEFT JOIN author AU ON A_A.author_id = AU.author_id LEFT JOIN article_images AI ON AI.article_id = A.article_id WHERE (AI.image_status='enabled' OR AI.image_status is null) GROUP BY A.article_id ORDER BY A.article_published_date DESC") paginator = Paginator(list(recent_articles), 10) # Show 6 articles per page page = request.GET.get('page') no_of_pages = range(1, paginator.num_pages+1) pg_url = page try: recent_articles = paginator.page(page) page_no = int(page) except PageNotAnInteger: # If page is not an integer, deliver first page. recent_articles = paginator.page(1) pg_url = 1 page_no = 1 except EmptyPage: # If page is out of range (e.g. 9999), deliver last page of results. page_no = 1 recent_articles = paginator.page(paginator.num_pages) adjacent_pages = 5 #page_numbers = [n for n in \ range(paginator.num_pages - adjacent_pages, paginator.num_pages + adjacent_pages + 1) \ if n > 0 and n <= paginator.num_pages] page_numbers = [n for n in \ range(page_no - adjacent_pages, page_no + adjacent_pages + 1) \ if n > 0 and n <= page_no] sidebar_dta = sidebar_data() category_jumlist = category_jump_list() meta_title = 'BW wellness - News and Updates for wellness in India' meta_description = 'BW wellness - News and Updates for wellness in India' meta_keyword = 'Recent Articles, BW wellness' og_title= 'BW wellness | Recent Articles' og_url= '/all-articles' og_image= settings.AWS_S3_BASE_URL + settings.BUCKET_PATH +'static_bwdiff/images/BW-wellness-logo.jpg' sidebar_zedo_ad = '' closeDbConnection() return render(request, 'article/listing.html', { "news_articles": recent_articles, 'sidebar_recent_articles': sidebar_dta['sidebar_recent_articles'], 'trending_now_topics': sidebar_dta['trending_now_topics'], 'quick_bytes_listing': sidebar_dta['quick_bytes_listing'], 'bwtv_cat_details': sidebar_dta['bwtv_cat_details'], 'no_of_pages': no_of_pages, 'page_title_h1': 'Latest Articles', 'listing_page_url': '/all-articles-load', 'view_page_url': '/all-articles', 'category_jumlist': category_jumlist, 'meta_title': meta_title, 'meta_description': meta_description, 'meta_keyword': meta_keyword, 'og_title': og_title, 'og_url': og_url, 'og_image': og_image, 'sidebar_zedo_ad': sidebar_zedo_ad, 'page_numbers':page_numbers, 'show_first': 1 not in page_numbers, 'show_last': paginator.num_pages not in page_numbers, 'last_page': paginator.num_pages })
def event_articles(request): sidebar_zedo_ad = '' sidebar_dta = sidebar_data() category_jumlist = category_jump_list() event_articles = Event.objects.raw("SELECT *, datediff(start_date,CURDATE()) as datedi FROM event where end_date >= CURDATE() AND valid=1 ORDER BY datedi asc ") paginator = Paginator(list(event_articles), 10) # Show 6 articles per page page = request.GET.get('page') no_of_pages = range(1, paginator.num_pages+1) pg_url = page try: event_articles = paginator.page(page) page_no = int(page) except PageNotAnInteger: # If page is not an integer, deliver first page. event_articles = paginator.page(1) pg_url = 1 page_no = 1 except EmptyPage: # If page is out of range (e.g. 9999), deliver last page of results. page_no = 1 event_articles = paginator.page(paginator.num_pages) adjacent_pages = 5 #page_numbers = [n for n in \ range(paginator.num_pages - adjacent_pages, paginator.num_pages + adjacent_pages + 1) \ if n > 0 and n <= paginator.num_pages] page_numbers = [n for n in \ range(page_no - adjacent_pages, page_no + adjacent_pages + 1) \ if n > 0 and n <= page_no] meta_title = 'BW Events - Events hosted and managed by BW wellness ' meta_description = 'List upcoming and past Business Events hosted and Managed by BW wellness Media Pvvt. Ltd. ' og_title = 'BW Events - Events hosted and managed by BW wellness' og_url = '/bw-events' og_image = settings.AWS_S3_BASE_URL + settings.BUCKET_PATH +'static_bwdiff/images/BW-wellness-logo.jpg' eventpast_articles = Event.objects.raw("SELECT *, datediff(end_date,CURDATE()) as datedi FROM event where end_date <= CURDATE() AND valid = 1 ORDER BY datedi desc") closeDbConnection() return render(request, 'event/event_listing.html', { 'event_articles': event_articles, 'eventpast_articles':eventpast_articles, 'category_jumlist': category_jumlist, 'quick_bytes_listing': sidebar_dta['quick_bytes_listing'], 'bwtv_cat_details': sidebar_dta['bwtv_cat_details'], 'sidebar_recent_articles': sidebar_dta['sidebar_recent_articles'], 'trending_now_topics': sidebar_dta['trending_now_topics'], 'sidebar_zedo_ad': sidebar_zedo_ad, 'meta_title': meta_title, 'meta_description': meta_description, 'og_title': og_title, 'og_url': og_url, 'og_image':og_image, 'page_numbers':page_numbers, 'show_first': 1 not in page_numbers, 'show_last': paginator.num_pages not in page_numbers, 'last_page': paginator.num_pages })
def author_articles_list(request, author_type, author_name, author_id): auth_name = author_name.replace('-', ' ') auth_type = author_type.replace('-', ' ') author_details = Author.objects.raw( "SELECT AU.*, AUTYPE.* FROM author AU LEFT JOIN author_type AUTYPE ON AU.author_type = AUTYPE.author_type_id WHERE AU.author_id = '" + author_id + "' AND AUTYPE.label = '" + auth_type + "'") column_details = '' if author_details[0].author_type == 4: column_details = Columns.objects.raw( "SELECT C.* FROM columns C LEFT JOIN author AU ON AU.column_id = C.column_id WHERE AU.author_id = " + str(author_details[0].author_id)) if len(list(column_details)) > 0: column_details_data = column_details[0] else: column_details_data = '' recent_articles = Articles.objects.raw( "SELECT A.*, AU.*, AI.photopath,AI.image_url FROM articles A LEFT JOIN article_author A_A ON A.article_id = A_A.article_id LEFT JOIN author AU ON A_A.author_id = AU.author_id LEFT JOIN article_images AI ON AI.article_id = A.article_id WHERE AU.author_id = '" + author_id + "' AND (AI.image_status='enabled' OR AI.image_status is null) GROUP BY A.article_id ORDER BY A.article_published_date DESC" ) paginator = Paginator(list(recent_articles), 6) # Show 6 articles per page page = request.GET.get('page') no_of_pages = range(1, paginator.num_pages + 1) try: articles = paginator.page(page) except PageNotAnInteger: # If page is not an integer, deliver first page. articles = paginator.page(1) except EmptyPage: # If page is out of range (e.g. 9999), deliver last page of results. articles = paginator.page(paginator.num_pages) sidebar_dta = sidebar_data() category_jumlist = category_jump_list() meta_title = auth_name + ' - BW defence' meta_description = 'Latest news and analysis written by ' + auth_name + '.' + author_details[ 0].author_bio meta_keyword = auth_name + ', BW defence' og_title = 'BW defence | ' + auth_name og_url = '/author/' + author_type + '/' + author_name + '-' + author_id og_image = settings.AWS_S3_BASE_URL + settings.BUCKET_PATH + 'static_bwdiff/images/BW-defence-logo.jpg' columnist = Author.objects.raw( "SELECT * FROM (SELECT au.*,ar.article_published_date FROM author au INNER JOIN article_author aru ON au.author_id=aru.author_id INNER JOIN articles ar ON aru.article_id=ar.article_id WHERE au.author_type='4' ORDER BY ar.article_published_date DESC) AS tem GROUP BY tem.author_id LIMIT 9" ) #columnist = Author.objects.filter(author_type='4')[:9] sidebar_zedo_ad = '' closeDbConnection() return render( request, 'article/author_article_listing.html', { "recent_articles": articles, 'sidebar_recent_articles': sidebar_dta['sidebar_recent_articles'], 'trending_now_topics': sidebar_dta['trending_now_topics'], 'quick_bytes_listing': sidebar_dta['quick_bytes_listing'], 'bwtv_cat_details': sidebar_dta['bwtv_cat_details'], 'no_of_pages': no_of_pages, 'page_title_h1': 'Latest Articles By ' + auth_name, 'listing_page_url': '/author-load/' + author_type + '/' + author_id, 'view_page_url': '/author/' + author_type + '/' + author_name + '-' + author_id, 'author_details': author_details, 'column_details': column_details_data, 'columnist': columnist, 'category_jumlist': category_jumlist, 'meta_title': meta_title, 'meta_description': meta_description, 'meta_keyword': meta_keyword, 'og_title': og_title, 'og_url': og_url, 'og_image': og_image, 'sidebar_zedo_ad': sidebar_zedo_ad, })
def Interviews_articles(request): sidebar_zedo_ad = '' sidebar_dta = sidebar_data() category_jumlist = category_jump_list() interview_articles = Articles.objects.raw("SELECT A.*, AU.*, AI.image_url, AI.photopath FROM articles A LEFT JOIN article_author A_A ON A.article_id = A_A.article_id LEFT JOIN author AU ON A_A.author_id = AU.author_id LEFT JOIN article_images AI ON A.article_id = AI.article_id WHERE A.article_type = 3 GROUP BY A.article_id ORDER BY A.article_published_date DESC") paginator = Paginator(list(interview_articles), 10) # Show 6 articles per page page = request.GET.get('page') no_of_pages = range(1, paginator.num_pages+1) pg_url = page try: interview_articles = paginator.page(page) page_no = int(page) except PageNotAnInteger: # If page is not an integer, deliver first page. interview_articles = paginator.page(1) pg_url = 1 page_no = 1 except EmptyPage: # If page is out of range (e.g. 9999), deliver last page of results. page_no = 1 interview_articles = paginator.page(paginator.num_pages) adjacent_pages = 5 #page_numbers = [n for n in \ range(paginator.num_pages - adjacent_pages, paginator.num_pages + adjacent_pages + 1) \ if n > 0 and n <= paginator.num_pages] page_numbers = [n for n in \ range(page_no - adjacent_pages, page_no + adjacent_pages + 1) \ if n > 0 and n <= page_no] meta_title = 'Opinion and Analysis of latest News and Updates for wellness in India by Experts - BW wellness' meta_description = 'Opinion and Analysis of latest News and Updates for wellness in India by Experts, Columnists and Comments - BW wellness' meta_keyword = 'News and Updates for wellness Business Opinion and Analysis in India, Hotel Industry and Hospitality Interviews' og_title = 'Opinion and Analysis of latest News and Updates for wellness in India Business News by Experts - BW wellness' og_url = '/business-opinion-analysis' og_image = settings.AWS_S3_BASE_URL + settings.BUCKET_PATH +'static_bwhr/images/BW-wellness-logo.jpg' closeDbConnection() return render(request, 'article/listing.html', { 'news_articles': interview_articles, 'category_jumlist': category_jumlist, 'quick_bytes_listing': sidebar_dta['quick_bytes_listing'], 'bwtv_cat_details': sidebar_dta['bwtv_cat_details'], 'sidebar_recent_articles': sidebar_dta['sidebar_recent_articles'], 'trending_now_topics': sidebar_dta['trending_now_topics'], 'sidebar_zedo_ad': sidebar_zedo_ad, 'meta_title': meta_title, 'page_title_h1': 'Interviews Articles', 'meta_description': meta_description, 'meta_keyword': meta_keyword, 'og_title': og_title, 'og_url': og_url, 'og_image':og_image, 'page_numbers':page_numbers, 'show_first': 1 not in page_numbers, 'show_last': paginator.num_pages not in page_numbers, 'last_page': paginator.num_pages })
def feature_articles(request): sidebar_zedo_ad = '' sidebar_dta = sidebar_data() category_jumlist = category_jump_list() feature_articles = Articles.objects.raw("SELECT A.*, AI.image_url, AI.photopath FROM articles A LEFT JOIN article_images AI ON A.article_id = AI.article_id WHERE A.article_type = '5' GROUP BY A.article_id ORDER BY A.article_published_date DESC") paginator = Paginator(list(feature_articles), 10) # Show 6 articles per page page = request.GET.get('page') no_of_pages = range(1, paginator.num_pages+1) pg_url = page try: feature_articles = paginator.page(page) page_no = int(page) except PageNotAnInteger: # If page is not an integer, deliver first page. feature_articles = paginator.page(1) pg_url = 1 page_no = 1 except EmptyPage: # If page is out of range (e.g. 9999), deliver last page of results. page_no = 1 feature_articles = paginator.page(paginator.num_pages) adjacent_pages = 5 #page_numbers = [n for n in \ range(paginator.num_pages - adjacent_pages, paginator.num_pages + adjacent_pages + 1) \ if n > 0 and n <= paginator.num_pages] page_numbers = [n for n in \ range(page_no - adjacent_pages, page_no + adjacent_pages + 1) \ if n > 0 and n <= page_no] meta_title = 'News and Updates for wellness in India Business Features of BW wellness' meta_description = 'Feature stories around News and Updates for wellness in India Business. BW wellness' og_image = settings.AWS_S3_BASE_URL + settings.BUCKET_PATH +'static_bwhr/images/BW-wellness-logo.jpg' meta_keyword = 'News and Updates for wellness Business in India, News and Updates for wellness in India Interviews' og_title = 'News and Updates for wellness in India Business Features covered by inhouse reporters of BW wellness' og_url = '/business-feature-stories' closeDbConnection() return render(request, 'article/article_feature_type_listing.html', { 'feature_articles': feature_articles, 'category_jumlist': category_jumlist, 'quick_bytes_listing': sidebar_dta['quick_bytes_listing'], 'bwtv_cat_details': sidebar_dta['bwtv_cat_details'], 'sidebar_recent_articles': sidebar_dta['sidebar_recent_articles'], 'trending_now_topics': sidebar_dta['trending_now_topics'], 'sidebar_zedo_ad': sidebar_zedo_ad, 'meta_title': meta_title, 'page_title_h1': 'Feature Articles', 'meta_description': meta_description, 'meta_keyword': meta_keyword, 'og_title': og_title, 'og_url': og_url, 'og_image':og_image, 'page_numbers':page_numbers, 'show_first': 1 not in page_numbers, 'show_last': paginator.num_pages not in page_numbers, 'last_page': paginator.num_pages })
def magzine_articles_listing(request,year,magazine_id,title): magazinshow = Magazine.objects.raw("SELECT * FROM magazine where magazine_id ="+magazine_id+"") magzine_articles = Articles.objects.raw("SELECT A.*, AU.*, AI.image_url,AI.photopath FROM articles A LEFT JOIN article_author A_A ON A.article_id = A_A.article_id LEFT JOIN author AU ON A_A.author_id = AU.author_id LEFT JOIN article_images AI ON AI.article_id = A.article_id WHERE (AI.image_status='enabled' OR AI.image_status is null) AND magzine_issue_name = "+magazine_id+" GROUP BY A.article_id ORDER BY A.article_published_date DESC") paginator = Paginator(list(magzine_articles), 10) # Show 6 articles per page page = request.GET.get('page') no_of_pages = range(1, paginator.num_pages+1) pg_url = page try: magzine_articles = paginator.page(page) page_no = int(page) except PageNotAnInteger: # If page is not an integer, deliver first page. magzine_articles = paginator.page(1) pg_url = 1 page_no = 1 except EmptyPage: # If page is out of range (e.g. 9999), deliver last page of results. page_no = 1 magzine_articles = paginator.page(paginator.num_pages) adjacent_pages = 5 #page_numbers = [n for n in \ range(paginator.num_pages - adjacent_pages, paginator.num_pages + adjacent_pages + 1) \ if n > 0 and n <= paginator.num_pages] page_numbers = [n for n in \ range(page_no - adjacent_pages, page_no + adjacent_pages + 1) \ if n > 0 and n <= page_no] sidebar_dta = sidebar_data() category_jumlist = category_jump_list() meta_title = 'Magazine- '+ str(magazinshow[0].title) +' -'+ str(magazinshow[0].publish_date_m)+' BW wellness' meta_description = 'BW wellness Magazine published on '+ str(magazinshow[0].publish_date_m)+' with cover story '+ str(magazinshow[0].title) +'. Read all stories from the' meta_keyword = 'magazine issue, BW wellness' og_title= 'Magazine- '+ str(magazinshow[0].title) +' -'+ str(magazinshow[0].publish_date_m)+' BW wellness' og_url= '/magazine-issues/'+str(year)+'/'+str(magazinshow[0].title)+'-'+str(magazine_id)+'/web-view' if (magazinshow[0].imagepath ==''): og_image= settings.AWS_S3_BASE_URL + settings.BUCKET_PATH +'static_bwhr/images/BW-wellness-logo.jpg' else: og_image= settings.AWS_S3_BASE_URL + settings.BUCKET_PATH + settings.MAGAZINE_IMAGE_PATH_URL + magazinshow[0].imagepath sidebar_zedo_ad = '<!-- Javascript tag --><!-- begin ZEDO for channel: Internal Pages , publisher: wellness , Ad Dimension: Medium Rectangle-300x250-IP - 300 x 250 --><script language="JavaScript">var zflag_nid="3336"; var zflag_cid="4"; var zflag_sid="1"; var zflag_width="300"; var zflag_height="250"; var zflag_sz="22"; </script><script language="JavaScript" src="http://xp2.zedo.com/jsc/xp2/fo.js"></script><!-- end ZEDO for channel: Internal Pages , publisher: BW Hotelier , Ad Dimension: Medium Rectangle-300x250-IP - 300 x 250 -->' closeDbConnection() return render(request, 'article/article_feature_type_listing.html', { 'feature_articles': magzine_articles, 'category_jumlist': category_jumlist, 'quick_bytes_listing': sidebar_dta['quick_bytes_listing'], 'bwtv_cat_details': sidebar_dta['bwtv_cat_details'], 'sidebar_recent_articles': sidebar_dta['sidebar_recent_articles'], 'trending_now_topics': sidebar_dta['trending_now_topics'], 'sidebar_zedo_ad': sidebar_zedo_ad, 'page_title_h1': 'Magazine Articles', 'meta_title': meta_title, 'meta_description': meta_description, 'meta_keyword': meta_keyword, 'og_title': og_title, 'og_url': og_url, 'og_image':og_image, 'page_numbers':page_numbers, 'show_first': 1 not in page_numbers, 'show_last': paginator.num_pages not in page_numbers, 'last_page': paginator.num_pages })