本文整理汇总了Python中mezzanine.pages.models.Page.save方法的典型用法代码示例。如果您正苦于以下问题:Python Page.save方法的具体用法?Python Page.save怎么用?Python Page.save使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mezzanine.pages.models.Page
的用法示例。
在下文中一共展示了Page.save方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: TestPageImageTags
# 需要导入模块: from mezzanine.pages.models import Page [as 别名]
# 或者: from mezzanine.pages.models.Page import save [as 别名]
class TestPageImageTags(TestCase):
def setUp(self):
self.p = Page(title='test')
self.p.save()
def setUpTemplate(self):
self.tmpl = Template(u'{% load pageimage_tags %}This will point to image \'{% pageimage \'BACKGROUND\' %}\'.')
self.c = Context({'page': self.p})
def test_simpletemplate_empty(self):
self.setUpTemplate()
tmplout = self.tmpl.render(self.c)
self.assertTrue('\'\'' in tmplout)
def test_simpletemplate_default(self):
self.setUpTemplate()
DefaultImage.objects.create(type='BACKGROUND', file='defaultback.jpg')
self.assertTrue(
'\'/static/media/defaultback.jpg\'' in self.tmpl.render(self.c)
)
def test_simpletemplate_specific(self):
self.setUpTemplate()
PageImage.objects.create(page=self.p, type='BACKGROUND', file='back.jpg')
self.assertTrue(
'\'/static/media/back.jpg\'' in self.tmpl.render(self.c)
)
示例2: setUp
# 需要导入模块: from mezzanine.pages.models import Page [as 别名]
# 或者: from mezzanine.pages.models.Page import save [as 别名]
def setUp(self):
self.user = User(username="asdf")
self.user.set_password("asdf")
self.user.save()
p = os.path.dirname(os.path.abspath(__file__))
icon = open(os.path.join(p, "test_files/icon.psd"))
f_icon = File(icon)
self.button = HybridButton(
name="Testbutton",
user=self.user,
icon=f_icon,
)
self.button.save()
page = Page(status='2', description="buttonizer", title="Buttonizer")
page.save()
示例3: TestGetImageForPage
# 需要导入模块: from mezzanine.pages.models import Page [as 别名]
# 或者: from mezzanine.pages.models.Page import save [as 别名]
class TestGetImageForPage(TestCase):
def setUp(self):
self.p = Page(title='test')
self.p.save()
def setUpDefaultImage(self):
di = DefaultImage(file='default.jpg', type='BACKGROUND')
di.save()
def setUpPageImage(self):
pi = PageImage(page=self.p, type='BACKGROUND', file='test.jpg')
pi.save()
def test_get_empty(self):
self.assertEqual(
'',
get_image_for_page(self.p, 'BACKGROUND')
)
def test_get_default_image(self):
self.setUpDefaultImage()
self.assertEqual(
'/static/media/default.jpg',
get_image_for_page(self.p, 'BACKGROUND')
)
def test_get_specific_image(self):
self.setUpDefaultImage()
self.setUpPageImage()
self.assertEqual(
'/static/media/test.jpg',
get_image_for_page(self.p, 'BACKGROUND')
)
def test_get_child_images(self):
self.setUpDefaultImage()
self.setUpPageImage()
p1 = Page.objects.create(title='child1', parent=self.p)
p2 = Page.objects.create(title='child2', parent=self.p)
PageImage.objects.create(page=p2, type='BACKGROUND', file='child2.jpg')
self.assertEqual(
'/static/media/test.jpg',
get_image_for_page(p1, 'BACKGROUND')
)
self.assertEqual(
'/static/media/child2.jpg',
get_image_for_page(p2, 'BACKGROUND')
)
def test_get_banner_image(self):
DefaultImage.objects.create(type='BANNER', file='defaultbanner.jpg')
self.assertEqual(
'/static/media/defaultbanner.jpg',
get_image_for_page(self.p, 'BANNER')
)