def get_item_by_url(request, html_cache_url):
    """Item data"""

    if settings.ENV == 'production':
        try:
            data, code, item = resource.get_item_by_url(request, html_cache_url)
        except:
            return {'code': 'html_cache/get_item/fail'}, 404
    else:
        data, code, item = resource.get_item_by_url(request, html_cache_url)
    return data, code
def update(request, html_cache_id):
    """Update record"""

    data = request.DATA

    if data is False:
        return {'code': 'no_data'}, 404, False

    data = helpers.set_null_values_if_not_exist(data, resource.get_fields())

    if data['url'] is None:
        return {'code': 'html_cache/no_url'}, 404, False

    user = helpers.get_user(request)

    if not user or not request.user.is_superuser:
        return {'code': 'no_access'}, 404, False
    if user is None:
        return {'code': 'account/not_active'}, 404, False

    data, code, item = resource.get_item_by_url(request, data['url'])

    if (item is not False) and (int(item.id) != int(html_cache_id)):
        return {'code': 'html_cache/exists', 'values': [data['url']]}, 404, False

    return {'code': 'ok'}, 200, True