本文整理匯總了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')
)