def personal(request): users = request.user check = Interest.objects.filter(user=users).exists() top_news = news.get_all() sources = news.get_source() categories = ['business', 'entertainment', 'general', 'health', 'science', 'sports', 'technology'] languages = ({'name': 'Arabic', 'id': 'ar'}, {'name': 'German', 'id': 'de'}, {'name': 'English', 'id': 'en'}, {'name': 'Spanish', 'id': 'es'}, {'name': 'French', 'id': 'fr'}, {'name': 'Hebrew', 'id': 'he'}, {'name': 'Italian', 'id': 'it'}, {'name': 'Dutch', 'id': 'nl'}, {'name': 'Norwegian', 'id': 'no'}, {'name': 'Portuguese', 'id': 'po'}, {'name': 'Russian', 'id': 'ru'}, {'name': 'Northern Sami', 'id': 'se'}, {'name': 'Udmurt', 'id': 'ud'}, {'name': 'Chinese', 'id': 'zh'}, ) if check: interest = Interest.objects.get(user=users) cat = interest.category sou = interest.sources results = user_specific.personal(sou) user_cat_news = {} for cats in cat.split(','): temp = (news.category(cats, 10)) user_cat_news[cats] = temp['articles'] if results: return render(request, 'personal.html', {'context': results, 'cat': cat.split(','), 'sou': sou, 'news': top_news['articles'], 'cat_news': user_cat_news, 'sources': sources, 'categories': categories, 'languages': languages}) else: return render(request, 'personal.html', {'context': 'error'}) else: return render(request, 'personal.html', {'context': 'error'})
def pricing(request): if request.method == 'GET': sources = news.get_source() check = user_views.check_paid(request) categories = ['business', 'entertainment', 'general', 'health', 'science', 'sports', 'technology'] languages = ({'name': 'Arabic', 'id': 'ar'}, {'name': 'German', 'id': 'de'}, {'name': 'English', 'id': 'en'}, {'name': 'Spanish', 'id': 'es'}, {'name': 'French', 'id': 'fr'}, {'name': 'Hebrew', 'id': 'he'}, {'name': 'Italian', 'id': 'it'}, {'name': 'Dutch', 'id': 'nl'}, {'name': 'Norwegian', 'id': 'no'}, {'name': 'Portuguese', 'id': 'po'}, {'name': 'Russian', 'id': 'ru'}, {'name': 'Northern Sami', 'id': 'se'}, {'name': 'Udmurt', 'id': 'ud'}, {'name': 'Chinese', 'id': 'zh'}, ) if request.user.is_authenticated: check = user_views.check_paid(request) if check is not None: context = {'status_check': check.status, 'sources': sources, 'categories': categories, 'languages': languages, 'status_check': check.status} return render(request, 'pricing.html', context) else: return render(request, 'login.html', {}) else: context = {} return render(request, 'login.html', context) else: pass
def source_selected(request): top_news = news.get_all() sources = news.get_source() check = user_views.check_paid(request) source_selected_news = news.source_selected(request.GET['source_id']) categories = ['business', 'entertainment', 'general', 'health', 'science', 'sports', 'technology'] languages = ({'name': 'Arabic', 'id': 'ar'}, {'name': 'German', 'id': 'de'}, {'name': 'English', 'id': 'en'}, {'name': 'Spanish', 'id': 'es'}, {'name': 'French', 'id': 'fr'}, {'name': 'Hebrew', 'id': 'he'}, {'name': 'Italian', 'id': 'it'}, {'name': 'Dutch', 'id': 'nl'}, {'name': 'Norwegian', 'id': 'no'}, {'name': 'Portuguese', 'id': 'po'}, {'name': 'Russian', 'id': 'ru'}, {'name': 'Northern Sami', 'id': 'se'}, {'name': 'Udmurt', 'id': 'ud'}, {'name': 'Chinese', 'id': 'zh'}, ) if source_selected_news: return render(request, 'source_selected.html', {'news': top_news['articles'], 'source_news': source_selected_news, 'source_selected': source_selected_news[0]['source']['name'], 'sources': print('sources'), 'categories': print('categories'), 'languages': print('languages'), 'status_check': print('check.status')}) else: return render(request, 'source_selected.html', {'news': top_news['articles'], 'source_news': source_selected_news, 'source_selected': False, 'sources': sources, 'categories': categories, 'languages': languages, 'check_status': check.status})
def search(request): top_news = news.get_all() data = news.query(request.POST['query']) sources = news.get_source() check = user_views.check_paid(request) categories = ['business', 'entertainment', 'general', 'health', 'science', 'sports', 'technology'] languages = ({'name': 'Arabic', 'id': 'ar'}, {'name': 'German', 'id': 'de'}, {'name': 'English', 'id': 'en'}, {'name': 'Spanish', 'id': 'es'}, {'name': 'French', 'id': 'fr'}, {'name': 'Hebrew', 'id': 'he'}, {'name': 'Italian', 'id': 'it'}, {'name': 'Dutch', 'id': 'nl'}, {'name': 'Norwegian', 'id': 'no'}, {'name': 'Portuguese', 'id': 'po'}, {'name': 'Russian', 'id': 'ru'}, {'name': 'Northern Sami', 'id': 'se'}, {'name': 'Udmurt', 'id': 'ud'}, {'name': 'Chinese', 'id': 'zh'}, ) return render(request, 'search.html', {'news': top_news['articles'], 'query': data['articles'], 'key': request.POST['query'], 'sources': print('sources'), 'categories':print('categories'), 'languages': print('languages'), 'status_check': print('check.status') })
def edit(request): users = request.user check = Interest.objects.filter(user=users).exists() if check: interest = Interest.objects.get(user=users) user_category = interest.category user_sources = interest.sources else: user_sources = '' user_category = '' top_news = news.get_all() sources = news.get_source() all_category = ['business', 'health', 'general', 'science', 'sports', 'technology', 'entertainment'] languages = ({'name': 'Arabic', 'id': 'ar'}, {'name': 'German', 'id': 'de'}, {'name': 'English', 'id': 'en'}, {'name': 'Spanish', 'id': 'es'}, {'name': 'French', 'id': 'fr'}, {'name': 'Hebrew', 'id': 'he'}, {'name': 'Italian', 'id': 'it'}, {'name': 'Dutch', 'id': 'nl'}, {'name': 'Norwegian', 'id': 'no'}, {'name': 'Portuguese', 'id': 'po'}, {'name': 'Russian', 'id': 'ru'}, {'name': 'Northern Sami', 'id': 'se'}, {'name': 'Udmurt', 'id': 'ud'}, {'name': 'Chinese', 'id': 'zh'}, ) return render(request, 'customize.html', {'news': top_news['articles'], 'sources': sources, 'user_source': user_sources, 'user_category': user_category, 'all_category': all_category, 'languages': languages})