Example #1
0
def widget(request):
    context = {'error': request.GET['error']} if 'error' in request.GET else {}
    if 'random' in request.GET and 'user' not in request.GET:
        context['profile'] = DataloveProfile.get_random_profile()
    elif 'user' in request.GET and 'random' not in request.GET:
        try:
            context['profile'] = DataloveProfile.objects.get(
                    user__username=request.GET['user']
                )
        except DataloveProfile.DoesNotExist:
            context['error'] = "User '%s' does not exist" % request.GET['user']
    else:
        return HttpResponseBadRequest(
                "GET request must have eather query parameter 'user' or "
                "'random'."
            )
    return _common.render_to_response2(request, 'give/widget.html', context)
Example #2
0
def total_loverz(request):
    return {'total_loverz': DataloveProfile.get_total_loverz()}