# Path: chant/settings.py
# AVATAR_HEIGHT = getattr(settings, 'CHANT_AVATAR_HEIGHT', 32)
# 
# AVATAR_WIDTH = getattr(settings, 'CHANT_AVATAR_WIDTH', 32)
# 
# GRAVATAR_DEFAULT = getattr(settings, 'CHANT_GRAVATAR_DEFAULT', 'identicon')


import time
from collections import deque
from hashlib import md5
from .settings import AVATAR_HEIGHT, AVATAR_WIDTH, GRAVATAR_DEFAULT
    from django.db.models.fields.related import ManyToManyField
        # if not getattr(f, 'editable', False):
        #     continue
        if fields and not f.name in fields:
            continue
        if exclude and f.name in exclude:
            continue
        if isinstance(f, ManyToManyField):
            # If the object doesn't have a primary key yet, just use an empty
            # list for its m2m fields. Calling f.value_from_object will raise
            # an exception.
            if instance.pk is None:
                data[f.name] = []
            else:
                # MultipleChoiceWidget needs a list of pks, not object instances.
                data[f.name] = list(f.value_from_object(instance).values_list('pk', flat=True))
        else:
            data[f.name] = f.value_from_object(instance)
    return data


def gravatar_url(email, width, height, gravatar_default):
    digest = md5(email.lower()).hexdigest()
    size = max(width, height)
    url = '//www.gravatar.com/avatar/%s?size=%s&default=%s' % (digest, size, gravatar_default)
    return url


def format_user(user):
    user_dict = model_to_dict(user, fields=['id', 'username', 'name', 'first_name', 'last_name'])
    user_dict.update({

# Path: chant/settings.py
# AVATAR_HEIGHT = getattr(settings, 'CHANT_AVATAR_HEIGHT', 32)
# 
# AVATAR_WIDTH = getattr(settings, 'CHANT_AVATAR_WIDTH', 32)
# 
# GRAVATAR_DEFAULT = getattr(settings, 'CHANT_GRAVATAR_DEFAULT', 'identicon')


# Path: chant/utils.py
import time
from collections import deque
from hashlib import md5
from .settings import AVATAR_HEIGHT, AVATAR_WIDTH, GRAVATAR_DEFAULT
    from django.db.models.fields.related import ManyToManyField

        # if not getattr(f, 'editable', False):
        #     continue
        if fields and not f.name in fields:
            continue
        if exclude and f.name in exclude:
            continue
        if isinstance(f, ManyToManyField):
            # If the object doesn't have a primary key yet, just use an empty
            # list for its m2m fields. Calling f.value_from_object will raise
            # an exception.
            if instance.pk is None:
                data[f.name] = []
            else:
                # MultipleChoiceWidget needs a list of pks, not object instances.
                data[f.name] = list(f.value_from_object(instance).values_list('pk', flat=True))
        else:
            data[f.name] = f.value_from_object(instance)
    return data


def gravatar_url(email, width, height, gravatar_default):
    digest = md5(email.lower()).hexdigest()
    size = max(width, height)
    url = '//www.gravatar.com/avatar/%s?size=%s&default=%s' % (digest, size, gravatar_default)
    return url


def format_user(user):
    user_dict = model_to_dict(user, fields=['id', 'username', 'name', 'first_name', 'last_name'])
    user_dict.update({

        'avatar': gravatar_url(user.email, AVATAR_WIDTH, AVATAR_HEIGHT, GRAVATAR_DEFAULT)