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


Python Addon.save方法代码示例

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


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

示例1: create_file

# 需要导入模块: from addons.models import Addon [as 别名]
# 或者: from addons.models.Addon import save [as 别名]
    def create_file(self, **kwargs):
        addon = Addon()
        addon.save()
        ver = Version(version='0.1')
        ver.addon = addon
        ver.save()

        f = File(**kwargs)
        f.version = ver
        f.save()

        return f
开发者ID:ujdhesa,项目名称:olympia,代码行数:14,代码来源:test_models.py

示例2: create_addon

# 需要导入模块: from addons.models import Addon [as 别名]
# 或者: from addons.models.Addon import save [as 别名]
    def create_addon(self, user, license=None):
        data = self.cleaned_data
        a = Addon(guid=data['guid'],
                  name=data['name'],
                  type=data['type'],
                  status=amo.STATUS_UNREVIEWED,
                  homepage=data['homepage'],
                  description=data['description'])
        a.save()
        AddonUser(addon=a, user=user).save()

        self.addon = a
        # Save Version, attach License
        self.create_version(license=license)
        log.info('Addon %d saved' % a.id)
        return a
开发者ID:ozten,项目名称:zamboni,代码行数:18,代码来源:forms.py

示例3: create_addon

# 需要导入模块: from addons.models import Addon [as 别名]
# 或者: from addons.models.Addon import save [as 别名]
    def create_addon(self, license=None):
        data = self.cleaned_data
        a = Addon(guid=data['guid'],
                  name=data['name'],
                  type=data['type'],
                  status=amo.STATUS_UNREVIEWED,
                  homepage=data['homepage'],
                  summary=data['summary'])
        a.save()
        AddonUser(addon=a, user=self.request.amo_user).save()

        self.addon = a
        # Save Version, attach License
        self.create_version(license=license)
        amo.log(amo.LOG.CREATE_ADDON, a)
        log.info('Addon %d saved' % a.id)
        return a
开发者ID:LucianU,项目名称:zamboni,代码行数:19,代码来源:forms.py

示例4: TestAddonWatchDisabled

# 需要导入模块: from addons.models import Addon [as 别名]
# 或者: from addons.models.Addon import save [as 别名]
class TestAddonWatchDisabled(test_utils.TestCase):

    def setUp(self):
        self.addon = Addon(type=amo.ADDON_THEME, disabled_by_user=False,
                           status=amo.STATUS_PUBLIC)
        self.addon.save()

    @patch('addons.models.File.objects.filter')
    def test_no_disabled_change(self, file_mock):
        mock = Mock()
        file_mock.return_value = [mock]
        self.addon.save()
        assert not mock.unhide_disabled_file.called
        assert not mock.hide_disabled_file.called

    @patch('addons.models.File.objects.filter')
    def test_disable_addon(self, file_mock):
        mock = Mock()
        file_mock.return_value = [mock]
        self.addon.update(disabled_by_user=True)
        assert not mock.unhide_disabled_file.called
        assert mock.hide_disabled_file.called

    @patch('addons.models.File.objects.filter')
    def test_admin_disable_addon(self, file_mock):
        mock = Mock()
        file_mock.return_value = [mock]
        self.addon.update(status=amo.STATUS_DISABLED)
        assert not mock.unhide_disabled_file.called
        assert mock.hide_disabled_file.called

    @patch('addons.models.File.objects.filter')
    def test_enable_addon(self, file_mock):
        mock = Mock()
        file_mock.return_value = [mock]
        self.addon.update(status=amo.STATUS_DISABLED)
        mock.reset_mock()
        self.addon.update(status=amo.STATUS_PUBLIC)
        assert mock.unhide_disabled_file.called
        assert not mock.hide_disabled_file.called
开发者ID:ricardodani,项目名称:zamboni,代码行数:42,代码来源:test_models.py

示例5: test_personas_landing

# 需要导入模块: from addons.models import Addon [as 别名]
# 或者: from addons.models.Addon import save [as 别名]
 def test_personas_landing(self):
     """Show landing page if there are greater than 4 Personas."""
     for i in xrange(3):
         a = Addon(type=amo.ADDON_PERSONA)
         a.name = 'persona-%s' % i
         a.all_categories = []
         a.save()
         v = Version.objects.get(addon=Addon.objects.get(id=15679))
         v.addon = a
         v.pk = None
         v.save()
         p = Persona(addon_id=a.id, persona_id=i)
         p.save()
         a.persona = p
         a._current_version = v
         a.status = amo.STATUS_PUBLIC
         a.save()
     base = (Addon.objects.public().filter(type=amo.ADDON_PERSONA)
             .extra(select={'_app': amo.FIREFOX.id}))
     eq_(base.count(), 5)
     r = self.client.get(reverse('browse.personas'))
     self.assertTemplateUsed(r, 'browse/personas/category_landing.html')
开发者ID:AutomatedTester,项目名称:zamboni,代码行数:24,代码来源:tests.py


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