Ejemplo n.º 1
0
def approve_rereview(theme):
    """Replace original theme with pending theme on filesystem."""
    # If reuploaded theme, replace old theme design.
    storage = LocalFileStorage()
    rereview = theme.rereviewqueuetheme_set.all()
    reupload = rereview[0]

    if reupload.header_path != reupload.theme.header_path:
        move_stored_file(reupload.header_path,
                         reupload.theme.header_path,
                         storage=storage)
    if reupload.footer_path != reupload.theme.footer_path:
        move_stored_file(reupload.footer_path,
                         reupload.theme.footer_path,
                         storage=storage)
    create_persona_preview_images(
        src=reupload.theme.header_path,
        full_dst=[
            reupload.theme.header_path.replace('header', 'preview'),
            reupload.theme.header_path.replace('header', 'icon')
        ],
        set_modified_on=[reupload.theme.addon])
    rereview.delete()

    theme.addon.increment_version()
Ejemplo n.º 2
0
def approve_rereview(theme):
    """Replace original theme with pending theme on filesystem."""
    # If reuploaded theme, replace old theme design.
    storage = LocalFileStorage()
    rereview = theme.rereviewqueuetheme_set.all()
    reupload = rereview[0]

    if reupload.header_path != reupload.theme.header_path:
        create_persona_preview_images(
            src=reupload.header_path,
            full_dst=[reupload.theme.thumb_path, reupload.theme.icon_path],
            set_modified_on=[reupload.theme.addon])

        if not reupload.theme.is_new():
            # Legacy themes also need a preview_large.jpg.
            # Modern themes use preview.png for both thumb and preview so there
            # is no problem there.
            copy_stored_file(reupload.theme.thumb_path,
                             reupload.theme.preview_path,
                             storage=storage)

        move_stored_file(reupload.header_path,
                         reupload.theme.header_path,
                         storage=storage)
    if reupload.footer_path != reupload.theme.footer_path:
        move_stored_file(reupload.footer_path,
                         reupload.theme.footer_path,
                         storage=storage)
    rereview.delete()

    theme.addon.increment_version()
Ejemplo n.º 3
0
def approve_rereview(theme):
    """Replace original theme with pending theme on filesystem."""
    # If reuploaded theme, replace old theme design.
    storage = LocalFileStorage()
    rereview = theme.rereviewqueuetheme_set.all()
    reupload = rereview[0]

    if reupload.header_path != reupload.theme.header_path:
        create_persona_preview_images(
            src=reupload.header_path,
            full_dst=[
                reupload.theme.thumb_path,
                reupload.theme.icon_path],
            set_modified_on=[reupload.theme.addon])

        if not reupload.theme.is_new():
            # Legacy themes also need a preview_large.jpg.
            # Modern themes use preview.png for both thumb and preview so there
            # is no problem there.
            copy_stored_file(reupload.theme.thumb_path,
                             reupload.theme.preview_path, storage=storage)

        move_stored_file(
            reupload.header_path, reupload.theme.header_path,
            storage=storage)
    if reupload.footer_path != reupload.theme.footer_path:
        move_stored_file(
            reupload.footer_path, reupload.theme.footer_path,
            storage=storage)
    rereview.delete()

    theme.addon.increment_version()
Ejemplo n.º 4
0
 def mv(cls, src, dst, msg):
     """Move a file from src to dst."""
     try:
         if storage.exists(src):
             log.info(msg % (src, dst))
             move_stored_file(src, dst)
     except UnicodeEncodeError:
         log.error('Move Failure: %s %s' % (smart_str(src), smart_str(dst)))
Ejemplo n.º 5
0
 def mv(cls, src, dst, msg):
     """Move a file from src to dst."""
     try:
         if storage.exists(src):
             log.info(msg % (src, dst))
             move_stored_file(src, dst)
     except UnicodeEncodeError:
         log.error('Move Failure: %s %s' % (smart_str(src), smart_str(dst)))
Ejemplo n.º 6
0
def approve_rereview(theme):
    """Replace original theme with pending theme on filesystem."""
    # If reuploaded theme, replace old theme design.
    storage = LocalFileStorage()
    rereview = theme.rereviewqueuetheme_set.all()
    reupload = rereview[0]

    move_stored_file(
        reupload.header_path, reupload.theme.header_path,
        storage=storage)
    move_stored_file(
        reupload.footer_path, reupload.theme.footer_path,
        storage=storage)
    rereview.delete()
Ejemplo n.º 7
0
def approve_rereview(theme):
    """Replace original theme with pending theme on filesystem."""
    # If reuploaded theme, replace old theme design.
    storage = LocalFileStorage()
    rereview = theme.rereviewqueuetheme_set.all()
    reupload = rereview[0]

    move_stored_file(
        reupload.header_path, reupload.theme.header_path,
        storage=storage)
    move_stored_file(
        reupload.footer_path, reupload.theme.footer_path,
        storage=storage)
    create_persona_preview_images(
        src=reupload.theme.header_path,
        full_dst=[
            reupload.theme.header_path.replace('header', 'preview'),
            reupload.theme.header_path.replace('header', 'icon')],
        set_modified_on=[reupload.theme.addon])
    rereview.delete()
Ejemplo n.º 8
0
 def test_move(self):
     src = self.newfile('src.txt', '<contents>')
     dest = self.path('somedir/dest.txt')
     move_stored_file(src, dest)
     eq_(self.contents(dest), '<contents>')
     eq_(storage.exists(src), False)
Ejemplo n.º 9
0
 def test_move_chunking(self):
     src = self.newfile('src.txt', '<contents>')
     dest = self.path('somedir/dest.txt')
     move_stored_file(src, dest, chunk_size=1)
     eq_(self.contents(dest), '<contents>')
     eq_(storage.exists(src), False)