Example #1
0
def update_media_revision(skin=None):
    """update skin media revision number based on the contents
    of the skin media directory"""
    from askbot.conf import settings as askbot_settings
    resource_revision = askbot_settings.MEDIA_RESOURCE_REVISION

    skin = skin or askbot_settings.ASKBOT_DEFAULT_SKIN

    if skin in list(get_available_skins().keys()):
        skin_path = get_path_to_skin(skin)
    else:
        assert (skin != 'default')
        msg = 'Skin "%s" not found. Please check ASKBOT_EXTRA_SKINS_DIR setting'
        raise MediaNotFound(msg % skin)

    media_dirs = [
        os.path.join(skin_path, 'media'),
    ]

    if skin != 'default':
        #we have default skin as parent of the custom skin
        default_skin_path = get_path_to_skin('default')
        media_dirs.append(os.path.join(default_skin_path, 'media'))

    current_hash = hasher.get_hash_of_dirs(media_dirs)

    if current_hash != askbot_settings.MEDIA_RESOURCE_REVISION_HASH:
        askbot_settings.update('MEDIA_RESOURCE_REVISION',
                               resource_revision + 1)
        askbot_settings.update('MEDIA_RESOURCE_REVISION_HASH', current_hash)
        logging.debug('MEDIA_RESOURCE_REVISION changed')
Example #2
0
def update_media_revision(skin = None):
    """update skin media revision number based on the contents
    of the skin media directory"""
    from askbot.conf import settings as askbot_settings
    resource_revision = askbot_settings.MEDIA_RESOURCE_REVISION

    if skin:
        if skin in get_skin_choices():
            skin_path = get_path_to_skin(skin)
        else:
            raise MediaNotFound('Skin %s not found' % skin)
    else:
        skin = 'default'
        skin_path = get_path_to_skin(askbot_settings.ASKBOT_DEFAULT_SKIN)

    media_dirs = [
        os.path.join(skin_path, 'media'),
        os.path.join(get_path_to_skin('common'), 'media')#we always use common
    ]

    if skin != 'default':
        #we have default skin as parent of the custom skin
        default_skin_path = get_path_to_skin('default')
        media_dirs.append(os.path.join(default_skin_path, 'media'))

    current_hash = hasher.get_hash_of_dirs(media_dirs)

    if current_hash != askbot_settings.MEDIA_RESOURCE_REVISION_HASH:
        askbot_settings.update('MEDIA_RESOURCE_REVISION', resource_revision + 1)
        askbot_settings.update('MEDIA_RESOURCE_REVISION_HASH', current_hash)
        logging.debug('MEDIA_RESOURCE_REVISION changed')
    askbot_settings.MEDIA_RESOURCE_REVISION
Example #3
0
def update_media_revision(skin=None):
    """update skin media revision number based on the contents
    of the skin media directory"""
    from askbot.conf import settings as askbot_settings
    resource_revision = askbot_settings.MEDIA_RESOURCE_REVISION

    skin = skin or askbot_settings.ASKBOT_DEFAULT_SKIN

    if skin in get_available_skins().keys():
        skin_path = get_path_to_skin(skin)
    else:
        assert(skin != 'default')
        msg = 'Skin "%s" not found. Please check ASKBOT_EXTRA_SKINS_DIR setting'
        raise MediaNotFound(msg % skin)

    media_dirs = [
        os.path.join(skin_path, 'media'),
    ]

    if skin != 'default':
        #we have default skin as parent of the custom skin
        default_skin_path = get_path_to_skin('default')
        media_dirs.append(os.path.join(default_skin_path, 'media'))

    current_hash = hasher.get_hash_of_dirs(media_dirs)

    if current_hash != askbot_settings.MEDIA_RESOURCE_REVISION_HASH:
        askbot_settings.update('MEDIA_RESOURCE_REVISION', resource_revision + 1)
        askbot_settings.update('MEDIA_RESOURCE_REVISION_HASH', current_hash)
        logging.debug('MEDIA_RESOURCE_REVISION changed')
Example #4
0
def update_media_revision(skin=None):
    """update skin media revision number based on the contents
    of the skin media directory"""
    from askbot.conf import settings as askbot_settings
    resource_revision = askbot_settings.MEDIA_RESOURCE_REVISION

    if skin:
        if skin in get_skin_choices():
            skin_path = get_path_to_skin(skin)
        else:
            raise MediaNotFound('Skin %s not found' % skin)
    else:
        skin = 'default'
        skin_path = get_path_to_skin(askbot_settings.ASKBOT_DEFAULT_SKIN)

    media_dirs = [
        os.path.join(skin_path, 'media'),
    ]

    if skin != 'default':
        #we have default skin as parent of the custom skin
        default_skin_path = get_path_to_skin('default')
        media_dirs.append(os.path.join(default_skin_path, 'media'))

    current_hash = hasher.get_hash_of_dirs(media_dirs)

    if current_hash != askbot_settings.MEDIA_RESOURCE_REVISION_HASH:
        askbot_settings.update('MEDIA_RESOURCE_REVISION',
                               resource_revision + 1)
        askbot_settings.update('MEDIA_RESOURCE_REVISION_HASH', current_hash)
        logging.debug('MEDIA_RESOURCE_REVISION changed')
    askbot_settings.MEDIA_RESOURCE_REVISION