def past_event_articles(request): sidebar_zedo_ad = '' sidebar_dta = sidebar_data() category_jumlist = category_jump_list() event_articles = Event.objects.raw("SELECT *, datediff(end_date,CURDATE()) as datedi FROM event where end_date <= CURDATE() AND valid = 1 ORDER BY datedi desc") paginator = Paginator(list(event_articles), 2) # Show 10 articles per page page = request.GET.get('page') no_of_pages = range(1, paginator.num_pages+1) try: event_articles = paginator.page(page) except PageNotAnInteger: # If page is not an integer, deliver first page. event_articles = paginator.page(1) except EmptyPage: # If page is out of range (e.g. 9999), deliver last page of results. event_articles = paginator.page(paginator.num_pages) return render(request, 'event/past_event_listing.html', { 'event_articles': event_articles, #'arcticleall_event':arcticleall_event, 'no_of_pages': no_of_pages, 'category_jumlist': category_jumlist, 'quick_bytes_listing': sidebar_dta['quick_bytes_listing'], 'sidebar_recent_articles': sidebar_dta['sidebar_recent_articles'], 'trending_now_topics': sidebar_dta['trending_now_topics'], '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 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 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 static_rss_feeds(request): sidebar_dta = sidebar_data() category_jumlist = category_jump_list() meta_title = 'RSS Feeds, Latest Feeds, Latest XML Feeds - News and Updates for HR Professional in India - BW people' meta_description = "Latest RSS Feeds, Latest XML Feeds for News and Updates for HR Professional in India, News and Updates for HR Professional in India from BW people" meta_keyword = 'RSS Feeds, BW people' og_title = 'RSS Feeds, Latest Feeds, Latest XML Feeds - News and Updates for HR Professional in India - BW people' og_url = '/rss-feed' og_image = settings.AWS_S3_BASE_URL + settings.BUCKET_PATH + 'static_bwhr/images/BW-people-logo.jpg' return render( request, 'static_pages/rss-feed.html', { '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, })
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 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 search_sponsored(request): q = request.GET.get('q') articles_search = SearchQuerySet().models(Sponsoredposts).filter( Q(sponsoredposts_title__contains=q) | Q(sponsoredposts_desc__contains=q) | Q(sponsoredposts_sum__contains=q)).order_by('-pub_date') paginator = Paginator(articles_search, 6) # Show 6 articles per page page = request.GET.get('page') no_of_pages = range(1, paginator.num_pages + 1) pg_url = page try: articles = paginator.page(page) except PageNotAnInteger: # If page is not an integer, deliver first page. articles = paginator.page(1) pg_url = 1 except EmptyPage: # If page is out of range (e.g. 9999), deliver last page of results. articles = paginator.page(paginator.num_pages) #Sidebar and other data to be used in base template sidebar_dta = sidebar_data() category_jumlist = category_jump_list() meta_title = 'Search Result: ' + q + ' - BWdefence' meta_description = 'Sponsored Articles, Photos, News and Opinion about ' + q meta_keyword = q + ', BWdefence' og_title = 'Search Result: ' + q + ' - BWdefence' og_url = '/search/articles?q=' + q + '&page=' + str(pg_url) og_image = settings.AWS_S3_BASE_URL + settings.BUCKET_PATH + 'static_bwdiff/images/BWH-Logo-300x72.jpg' return render( request, 'search/search_sponsored.html', { 'query': q, 'articles': articles, 'sidebar_recent_articles': sidebar_dta['sidebar_recent_articles'], 'trending_now_topics': sidebar_dta['trending_now_topics'], 'bwtv_articles': sidebar_dta['bwtv_articles'], 'videomaster_listing': sidebar_dta['videomaster_listing'], '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, })
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 master_video_landing_page(request,video_title,updated_at,video_id): sidebar_zedo_ad = '' sidebar_dta = sidebar_data() category_jumlist = category_jump_list() VideoMaster_data = VideoMaster.objects.filter(video_id=video_id).first() videomaster_listing = VideoMaster.objects.raw("SELECT * FROM video_master ORDER BY video_id DESC LIMIT 0,5 ") #Meta title and descriptons meta_title = video_title+'- bwhr' og_title= video_title if VideoMaster_data: meta_description = VideoMaster_data.video_summary og_url= VideoMaster_data.get_absolute_url if VideoMaster_data: og_image= settings.AWS_S3_BASE_URL + settings.VIDEO_THUMB +VideoMaster_data.video_thumb_name else: og_image= settings.AWS_S3_BASE_URL + settings.BUCKET_PATH +'static_bwdiff/images/BW-defence-logo.jpg' return render(request, 'mastervideo/master_video_landing_page.html', { 'VideoMaster_data':VideoMaster_data, 'videomaster_listing':videomaster_listing, 'category_jumlist': category_jumlist, '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'], 'sidebar_zedo_ad': sidebar_zedo_ad, 'meta_title':meta_title, 'meta_description':meta_description, 'og_url':og_url, 'og_image':og_image, })
def photo_shoot_landing_page(request,photo_shoot_title,photo_shoot_updated_at,photo_shoot_id): sidebar_zedo_ad = '' sidebar_dta = sidebar_data() category_jumlist = category_jump_list() photoshoot_data = PhotoShoot.objects.raw("SELECT * from photo_shoot where photo_shoot_id ='"+photo_shoot_id+"' ") photoshoot_image = PhotoShoot.objects.raw("SELECT * from photo_shoot_photos where photo_shoot_id ='"+photo_shoot_id+"' ") 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,10") #Meta title and descriptons meta_title = photo_shoot_title+'- bw People' og_title= photo_shoot_title if len(list(photoshoot_data)) > 0: meta_description = photoshoot_data[0].photo_shoot_description og_url= photoshoot_data[0].get_absolute_url if len(list(photoshoot_image)) > 0: og_image= settings.AWS_S3_BASE_URL + settings.PHOTOSHOOT_IMAGE_PATH +photoshoot_image[0].photo_shoot_photo_name else: og_image= settings.AWS_S3_BASE_URL + settings.BUCKET_PATH +'static_bwdiff/images/BW-defence-logo.jpg' return render(request, 'photoshoot/photo_shoot_landing_page.html', { 'photoshoot_data':photoshoot_data, 'photoshoot_image':photoshoot_image, 'photoshoot_listing':photoshoot_listing, '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_url':og_url, 'og_image':og_image, })
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 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 })
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 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 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 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 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 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 quickbyte_listing(request): sidebar_zedo_ad = '<!-- Javascript tag --><!-- begin ZEDO for channel: Category Pages , publisher: people , Ad Dimension: Medium Rectangle-300x250-CP - 300 x 250 --><script language="JavaScript">var zflag_nid="3336"; var zflag_cid="2"; var zflag_sid="1"; var zflag_width="300"; var zflag_height="250"; var zflag_sz="19"; </script><script language="JavaScript" src="http://xp2.zedo.com/jsc/xp2/fo.js"></script><!-- end ZEDO for channel: Category Pages , publisher: Businessworld , Ad Dimension: Medium Rectangle-300x250-CP - 300 x 250 -->' sidebar_dta = sidebar_data() category_jumlist = category_jump_list() quick_bytes = QuickBytes.objects.raw( "SELECT Q.*, QP.quick_byte_photo_url as image_url, QP.quick_byte_photo_name FROM quick_bytes Q LEFT JOIN quick_bytes_photos QP ON Q.quick_byte_id = QP.quick_byte_id GROUP BY Q.quick_byte_id ORDER BY Q.quick_byte_published_date DESC " ) paginator = Paginator(list(quick_bytes), 10) # Show 6 articles per page page = request.GET.get('page') no_of_pages = range(1, paginator.num_pages + 1) pg_url = page try: quick_bytes = paginator.page(page) page_no = int(page) except PageNotAnInteger: # If page is not an integer, deliver first page. quick_bytes = 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 quick_bytes = 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 = 'Trending Business Listicles - BW people - Page' + str( page_no) meta_description = 'Trending Business Stories and Listicles from India and across the world. Page ' + str( page_no) + ' BW people.' og_title = 'Trending Business Listicles - BW people - Page' + str(page_no) og_url = '/all-quickbytes' og_image = settings.AWS_S3_BASE_URL + settings.BUCKET_PATH + 'static_bwhr/images/BW-people-logo.jpg' return render( request, 'quickbytes/listing_quick.html', { 'quick_bytes': quick_bytes, 'category_jumlist': category_jumlist, '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'], '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 column_articles(request): sidebar_zedo_ad = '' sidebar_dta = sidebar_data() category_jumlist = category_jump_list() column_articles = Articles.objects.raw("SELECT A.*, AI.image_url, AI.photopath 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_A.author_type='4' GROUP BY A.article_id ORDER BY A.article_published_date DESC ") paginator = Paginator(list(column_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: column_articles = paginator.page(page) page_no = int(page) except PageNotAnInteger: # If page is not an integer, deliver first page. column_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 column_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 = 'Exclusive articles by Columnists - BW wellness - Page'+str(page_no) meta_description = 'Columnists at BW wellness analysis, dissects and opinionate on the latest financial situations and developments in India and world. Page '+str(page_no)+' of the list.' og_title = 'Exclusive articles by Columnists - BW wellness - Page'+str(page_no) og_url = '/columns' og_image='http://d1s8mqgwixvb29.cloudfront.net/static_bwdiff/images/BW-wellness-logo.jpg' return render(request, 'column/listing_column.html', { 'column_articles': column_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 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 search_articles(request): if (request.GET.get('q')): q = request.GET.get('q') else: q = '' page = request.GET.get('page') if (' ' in q) == True: count_dta = {"query": {"match_phrase": {"article_title": q}}} else: count_dta = {"query": {"query_string": {"query": q}}} total_results = requests.get(settings.AWS_ELASTICSEARCH_URL + settings.AWS_ELASTICSEARCH_INDEX + 'articles/_count', data=json.dumps(count_dta)) tlt_count = total_results.json() no_of_pages = range(1, tlt_count['count'], 10) #return HttpResponse(tlt_count['count'] / 10) if (tlt_count['count'] % 10 == 0): last_page = tlt_count['count'] / 10 else: last_page = (tlt_count['count'] / 10) + 1 pg_url = page if (page): page_no = int(page) from_elem = (page_no - 1) * 10 if (' ' in q) == True: data = { "sort": { "article_published_date": { "order": "desc" } }, "query": { "match_phrase": { "article_title": q } }, "from": from_elem, "size": 10 } else: data = { "sort": { "article_published_date": { "order": "desc" } }, "query": { "query_string": { "query": q } }, "from": from_elem, "size": 10 } else: # If page is not an integer, deliver first page. if (' ' in q) == True: data = { "sort": { "article_published_date": { "order": "desc" } }, "query": { "match_phrase": { "article_title": q } }, "from": 0, "size": 10, } else: data = { "sort": { "article_published_date": { "order": "desc" } }, "query": { "query_string": { "query": q } }, "from": 0, "size": 10, } pg_url = 1 page_no = 1 #return HttpResponse(json.dumps(data)) result_response = requests.get(settings.AWS_ELASTICSEARCH_URL + settings.AWS_ELASTICSEARCH_INDEX + 'articles/_search', data=json.dumps(data)) response_dta = result_response.json() #return HttpResponse(json.dumps(response_dta['hits']['hits'])) adjacent_pages = 5 if (page_no < adjacent_pages): start_page = 1 else: if (page_no <= (last_page - 5)): start_page = page_no else: start_page = last_page - 4 end_page = page_no + adjacent_pages if (end_page > last_page): end_page = last_page + 1 page_numbers = [n for n in \ range(start_page, end_page)] #Sidebar and other data to be used in base template sidebar_dta = sidebar_data() category_jumlist = category_jump_list() meta_title = 'Search Result: ' + q + ' - BWdefence' meta_description = 'Articles, Photos, News and Opinion about ' + q meta_keyword = q + ', BWdefence' og_title = 'Search Result: ' + q + ' - BWdefence' og_url = '/search/articles?q=' + q + '&page=' + str(pg_url) og_image = settings.AWS_S3_BASE_URL + settings.BUCKET_PATH + 'static_bwdefence/images/BWH-Logo-300x72.jpg' return render( request, 'search/search_article.html', { 'query': q, 'articles': response_dta, 'sidebar_recent_articles': sidebar_dta['sidebar_recent_articles'], 'trending_now_topics': sidebar_dta['trending_now_topics'], 'bwtv_articles': sidebar_dta['bwtv_articles'], 'videomaster_listing': sidebar_dta['videomaster_listing'], '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, 'page_numbers': page_numbers, 'show_first': 1 not in page_numbers, 'show_last': last_page not in page_numbers, 'last_page': last_page, 'current_page': page_no, 'previous_page': int(page_no) - 1, 'next_page': int(page_no) + 1 })