Ejemplo n.º 1
0
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
Ejemplo n.º 2
0
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})
Ejemplo n.º 3
0
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')
                   })