Example #1
0
def custom_404(request):
    """Custom 404 error handler."""
    featured_rep = utils.latest_object_or_none(FeaturedRep)
    t = loader.get_template('404.html')
    return http.HttpResponseNotFound(
        t.render(RequestContext(request, {'request_path': request.path,
                                          'featuredrep': featured_rep})))
Example #2
0
def custom_404(request):
    """Custom 404 error handler."""
    featured_rep = utils.latest_object_or_none(FeaturedRep)
    t = loader.get_template('404.html')
    return http.HttpResponseNotFound(
        t.render(
            RequestContext(request, {
                'request_path': request.path,
                'featuredrep': featured_rep
            })))
Example #3
0
def main(request):
    """Main page of the website."""
    featured_rep = utils.latest_object_or_none(FeaturedRep)
    if featured_rep:
        avatar_url = featured_rep.user.userprofile.get_avatar_url(80)
    else:
        avatar_url = None
    return render(request, 'main.html', {'featuredrep': featured_rep,
                                         'avatar_url': avatar_url,
                                         'next_url': reverse('dashboard')})
Example #4
0
def custom_404(request):
    """Custom 404 error handler."""
    featured_rep = utils.latest_object_or_none(FeaturedRep)
    if featured_rep:
        avatar_url = featured_rep.user.userprofile.get_avatar_url(80)
    else:
        avatar_url = None
    t = loader.get_template('404.html')
    return http.HttpResponseNotFound(
        t.render(RequestContext(request, {'request_path': request.path,
                                          'featuredrep': featured_rep,
                                          'avatar_url': avatar_url})))
Example #5
0
def main(request):
    """Main page of the website."""
    featured_rep = utils.latest_object_or_none(FeaturedRep)

    planet_feed = cache.get('planet')
    if not planet_feed:
        try:
            planet_feed = requests.get(settings.PLANET_URL,
                                       timeout=settings.PLANET_MAX_TIMEOUT).text
        except (requests.exceptions.Timeout, requests.exceptions.ConnectionError):
            planet_feed = ''
        else:
            cache.set('planet', planet_feed, 60 * 60 * 8)

    results = feedparser.parse(planet_feed).entries[:3]

    return render(request, 'main.jinja', {'featuredrep': featured_rep,
                                          'planet_entries': results})
Example #6
0
def main(request):
    """Main page of the website."""
    featured_rep = utils.latest_object_or_none(FeaturedRep)

    planet_feed = cache.get('planet')
    if not planet_feed:
        try:
            planet_feed = requests.get(
                settings.PLANET_URL, timeout=settings.PLANET_MAX_TIMEOUT).text
        except (requests.exceptions.Timeout,
                requests.exceptions.ConnectionError):
            planet_feed = ''
        else:
            cache.set('planet', planet_feed, 60 * 60 * 8)

    results = feedparser.parse(planet_feed).entries[:3]

    return render(request, 'main.jinja', {
        'featuredrep': featured_rep,
        'planet_entries': results
    })
Example #7
0
def main(request):
    """Main page of the website."""
    featured_rep = utils.latest_object_or_none(FeaturedRep)
    return render(request, 'main.html', {'featuredrep': featured_rep})
Example #8
0
def custom_404(request):
    """Custom 404 error handler."""
    featured_rep = utils.latest_object_or_none(FeaturedRep)
    return http.HttpResponseNotFound(
        render(request, '404.html', {'featuredrep': featured_rep}))
Example #9
0
def main(request):
    """Main page of the website."""
    featured_rep = utils.latest_object_or_none(FeaturedRep)
    return render(request, 'main.html', {'featuredrep': featured_rep,
                                         'next_url': reverse('dashboard')})
Example #10
0
def custom_404(request):
    """Custom 404 error handler."""
    featured_rep = utils.latest_object_or_none(FeaturedRep)
    return http.HttpResponseNotFound(render(request, '404.html',
                                            {'featuredrep': featured_rep}))
Example #11
0
def main(request):
    """Main page of the website."""
    featured_rep = utils.latest_object_or_none(FeaturedRep)
    return render(request, 'main.html', {'featuredrep': featured_rep})