Exemple #1
0
def get_email_info(request):
    auth_manager = request.auth_manager
    email_form = forms.EmailForm(request.GET)

    if email_form.is_valid():
        email = email_form.cleaned_data['email']
        image_url = gravatar_url(email, 38)
        response = { 'email': email, 'image_url': image_url}
    else:
        return HttpResponse('{"pStatus": "ERROR", "pMessage": "'+ugettext("PRIV-SHARE-EMAIL-ERROR")+'"}', content_type='application/json', status=400)
    return HttpResponse(json.dumps(response), content_type='application/json')
Exemple #2
0
def get_email_info(request):
    auth_manager = request.auth_manager
    email_form = forms.EmailForm(request.GET)

    if email_form.is_valid():
        email = email_form.cleaned_data['email']
        image_url = gravatar_url(email, 38)
        response = {'email': email, 'image_url': image_url}
    else:
        return HttpResponse('{"pStatus": "ERROR", "pMessage": "' +
                            ugettext("PRIV-SHARE-EMAIL-ERROR") + '"}',
                            content_type='application/json',
                            status=400)
    return HttpResponse(json.dumps(response), content_type='application/json')
Exemple #3
0
def gravatar(auth_manager, size, klass, user_nick=None, user_email=None):
    """ auth_manager param can also be a user object or dict with user nick and email """
    from django.conf import settings
    from core.http import gravatar_url

    if not user_nick:
        email = auth_manager.email
        nick = auth_manager.nick
    else:
        email = user_email
        nick = user_nick

    if not isinstance( size, (int, long)):
        size = settings.GRAVATAR['sizes'][size]
    url = gravatar_url(email, size)
    return '<img src="%s" alt="%s" title="%s" class="%s"/>' % (url, nick, nick, klass)