コード例 #1
0
def upload_user_photo(request, user):
    """
    Saves a user profile photo whose data is in the request.
    The callee or decorator is reponsible for ensuring request.user == user
    """
    user.photo, user.thumbnail = save_image_from_request(
        request, name_prefix="user-%s" % user.pk, thumb_size=(85, 85))
    user.save_with_user(request.user)

    return {'url': user.thumbnail.url}
コード例 #2
0
ファイル: user.py プロジェクト: barbaralluz/otm-core
def upload_user_photo(request, user):
    """
    Saves a user profile photo whose data is in the request.
    The callee or decorator is reponsible for ensuring request.user == user
    """
    user.photo, user.thumbnail = save_image_from_request(
        request, name_prefix="user-%s" % user.pk, thumb_size=(85, 85))
    user.save_with_user(request.user)

    return {'url': user.thumbnail.url}
コード例 #3
0
ファイル: user.py プロジェクト: cgarrard/OTM2
def upload_user_photo(request, user):
    """
    Saves a user profile photo whose data is in the request.
    The callee or decorator is reponsible for ensuring request.user == user
    """
    try:
        user.photo, user.thumbnail = save_image_from_request(
            request, name_prefix="user-%s" % user.pk, thumb_size=(85, 85))
        user.save_with_user(request.user)
    except ValidationError as e:
        # Most of these ValidationError are not field-errors and so their
        # messages are a Dict, which is why they simply joined together
        return bad_request_json_response('; '.join(e.messages))

    return {'url': user.thumbnail.url}
コード例 #4
0
def upload_user_photo(request, user):
    """
    Saves a user profile photo whose data is in the request.
    The callee or decorator is reponsible for ensuring request.user == user
    """
    try:
        user.photo, user.thumbnail = save_image_from_request(
            request, name_prefix="user-%s" % user.pk, thumb_size=(85, 85))
        user.save_with_user(request.user)
    except ValidationError as e:
        # Most of these ValidationError are not field-errors and so their
        # messages are a Dict, which is why they simply joined together
        return bad_request_json_response('; '.join(e.messages))

    return {'url': user.thumbnail.url}
コード例 #5
0
ファイル: management.py プロジェクト: OpenTreeMap/otm-core
def update_logo(request, instance):
    name_prefix = "logo-%s" % instance.url_name
    instance.logo, __ = save_image_from_request(request, name_prefix)
    instance.save()

    return {'url': instance.logo.url}
コード例 #6
0
def update_logo(request, instance):
    name_prefix = "logo-%s" % instance.url_name
    instance.logo, __ = save_image_from_request(request, name_prefix)
    instance.save()

    return {'url': instance.logo.url}