当前位置: 首页>>代码示例>>Python>>正文


Python Persona.accentcolor方法代码示例

本文整理汇总了Python中addons.models.Persona.accentcolor方法的典型用法代码示例。如果您正苦于以下问题:Python Persona.accentcolor方法的具体用法?Python Persona.accentcolor怎么用?Python Persona.accentcolor使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在addons.models.Persona的用法示例。


在下文中一共展示了Persona.accentcolor方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: save

# 需要导入模块: from addons.models import Persona [as 别名]
# 或者: from addons.models.Persona import accentcolor [as 别名]
    def save(self, commit=False):
        from .tasks import create_persona_preview_image, save_persona_image
        # We ignore `commit`, since we need it to be `False` so we can save
        # the ManyToMany fields on our own.
        addon = super(NewPersonaForm, self).save(commit=False)
        addon.status = amo.STATUS_UNREVIEWED
        addon.type = amo.ADDON_PERSONA
        addon.save()
        addon._current_version = Version.objects.create(addon=addon,
                                                        version='0')
        addon.save()
        amo.log(amo.LOG.CREATE_ADDON, addon)
        log.debug('New persona %r uploaded' % addon)

        data = self.cleaned_data

        header = data['header_hash']
        footer = data['footer_hash']

        header = os.path.join(settings.TMP_PATH, 'persona_header', header)
        footer = os.path.join(settings.TMP_PATH, 'persona_footer', footer)
        dst = os.path.join(settings.PERSONAS_PATH, str(addon.id))

        # Save header, footer, and preview images.
        save_persona_image(src=header, dst=dst, img_basename='header.jpg')
        save_persona_image(src=footer, dst=dst, img_basename='footer.jpg')
        create_persona_preview_image(src=header, dst=dst,
                                     img_basename='preview.jpg',
                                     set_modified_on=[addon])

        # Save user info.
        user = self.request.amo_user
        AddonUser(addon=addon, user=user).save()

        p = Persona()
        p.persona_id = 0
        p.addon = addon
        p.header = 'header.jpg'
        p.footer = 'footer.jpg'
        if data['accentcolor']:
            p.accentcolor = data['accentcolor'].lstrip('#')
        if data['textcolor']:
            p.textcolor = data['textcolor'].lstrip('#')
        p.license_id = data['license']
        p.submit = datetime.now()
        p.author = user.name
        p.display_username = user.username
        p.save()

        # Save tags.
        for t in data['tags']:
            Tag(tag_text=t).save_tag(addon)

        # Save categories.
        tb_c = Category.objects.get(application=amo.THUNDERBIRD.id,
                                    name__id=data['category'].name_id)
        AddonCategory(addon=addon, category=data['category']).save()
        AddonCategory(addon=addon, category=tb_c).save()

        return addon
开发者ID:MechanisM,项目名称:zamboni,代码行数:62,代码来源:forms.py

示例2: save

# 需要导入模块: from addons.models import Persona [as 别名]
# 或者: from addons.models.Persona import accentcolor [as 别名]
    def save(self, commit=False):
        from addons.tasks import (create_persona_preview_images,
                                  save_persona_image)
        data = self.cleaned_data
        addon = Addon.objects.create(name=data['name'],
            slug=data.get('slug'),
            description=data.get('summary'),
            status=amo.STATUS_PENDING, type=amo.ADDON_PERSONA)
        addon._current_version = Version.objects.create(addon=addon,
                                                        version='0')
        addon.save()

        # Save header, footer, and preview images.
        try:
            header = data['header_hash']
            footer = data['footer_hash']
            header = os.path.join(settings.TMP_PATH, 'persona_header', header)
            footer = os.path.join(settings.TMP_PATH, 'persona_footer', footer)
            dst_root = os.path.join(settings.ADDONS_PATH, str(addon.id))

            save_persona_image.delay(src=header,
                full_dst=os.path.join(dst_root, 'header.png'))
            save_persona_image.delay(src=footer,
                full_dst=os.path.join(dst_root, 'footer.png'))
            create_persona_preview_images.delay(src=header,
                full_dst=[os.path.join(dst_root, 'preview.png'),
                          os.path.join(dst_root, 'icon.png')],
                set_modified_on=[addon])
        except IOError:
            addon.delete()
            raise

        # Save user info.
        user = self.request.amo_user
        AddonUser(addon=addon, user=user).save()

        # Create Persona instance.
        p = Persona()
        p.persona_id = 0
        p.addon = addon
        p.header = 'header.png'
        p.footer = 'footer.png'
        if data['accentcolor']:
            p.accentcolor = data['accentcolor'].lstrip('#')
        if data['textcolor']:
            p.textcolor = data['textcolor'].lstrip('#')
        p.license_id = data['license']
        p.submit = datetime.now()
        p.author = user.name
        p.display_username = user.username
        p.save()

        # Save tags.
        for t in data['tags']:
            Tag(tag_text=t).save_tag(addon)

        # Save categories.
        AddonCategory(addon=addon, category=data['category']).save()

        return addon
开发者ID:sandy-slin,项目名称:zamboni,代码行数:62,代码来源:forms.py

示例3: save

# 需要导入模块: from addons.models import Persona [as 别名]
# 或者: from addons.models.Persona import accentcolor [as 别名]
    def save(self, commit=False):
        data = self.cleaned_data
        addon = Addon.objects.create(
            slug=data.get('slug'),
            status=amo.STATUS_PENDING, type=amo.ADDON_PERSONA)
        addon.name = {'en-US': data['name']}
        if data.get('description'):
            addon.description = data['description']
        addon._current_version = Version.objects.create(addon=addon,
                                                        version='0')
        addon.save()

        # Create Persona instance.
        p = Persona()
        p.persona_id = 0
        p.addon = addon
        p.header = 'header.png'
        if data['footer_hash']:
            p.footer = 'footer.png'
        if data['accentcolor']:
            p.accentcolor = data['accentcolor'].lstrip('#')
        if data['textcolor']:
            p.textcolor = data['textcolor'].lstrip('#')
        p.license = data['license']
        p.submit = datetime.now()
        user = self.request.amo_user
        p.author = user.username
        p.display_username = user.name
        p.save()

        # Save header, footer, and preview images.
        save_theme.delay(data['header_hash'], data['footer_hash'], addon)

        # Save user info.
        addon.addonuser_set.create(user=user, role=amo.AUTHOR_ROLE_OWNER)

        # Save tags.
        for t in data['tags']:
            Tag(tag_text=t).save_tag(addon)

        # Save categories.
        AddonCategory(addon=addon, category=data['category']).save()

        return addon
开发者ID:magopian,项目名称:olympia,代码行数:46,代码来源:forms.py


注:本文中的addons.models.Persona.accentcolor方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。