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


Python Box.save方法代码示例

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


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

示例1: test_box_timeline

# 需要导入模块: from models import Box [as 别名]
# 或者: from models.Box import save [as 别名]
    def test_box_timeline(self):
        if not settings.BOX_USES_TIMELINE: return
        # What is the latest time, before we start?
        start = self._get_latest_time()

        # @ Time 1: Create empty box.
        b = Box()
        b.save()
        box_created = self._get_latest_time()
        self.assertTrue( (box_created > start),
                         "Timeline not advanced on box creation." )

        # @ Time 2: Add pages to box.
        b.add_content( [p1, p2] )
        pages_added = self._get_latest_time()
        self.assertTrue( (pages_added > box_created),
                         "Timeline not advanced on content addition." )

        # @ Time 4: Remove page 1 from box.
        b.remove_content(p1)
        page_removed = self._get_latest_time()
        self.assertTrue( (page_removed > pages_added),
                         "Timeline not advanced on content removal." )

        # Verify that box contains one page at the present time.
        self.assertEqual(len(b.contents.all()), 1,
                         "Box contents at present time not correct.")

        # View box pages @ time 2 again.
        way_back_when = b.contents.filter(added__lte=pages_added,
                                          removed__gt=pages_added)
        self.assertEqual(len(way_back_when), 2,
                         "Box contents at prior time not correct.")
开发者ID:pombredanne,项目名称:django-dogwood,代码行数:35,代码来源:tests.py

示例2: test_combine_envelope_contents

# 需要导入模块: from models import Box [as 别名]
# 或者: from models.Box import save [as 别名]
    def test_combine_envelope_contents(self):
        # Make some pages.
        p1 = Page()
        p1.save()
        p2 = Page()
        p2.save()
        p3 = Page()
        p3.save()
        p4 = Page()
        p4.save()

        # Make a box for them.
        b = Box()
        b.save()

        # Put them in the box.
        box.add_content( (p1, p2, p3, p4) )

        # Make two envelopes and put pages in them.
        e1 = Envelope()
        e1.add_content( (p1, p2) )
        e2 = Envelope()
        e2.add_content( (p3, p4) )

        # Combine envelope contents.
        e2.send_contents_to_envelope(e1)

        self.assertEqual(len(e2.contents.all()), 0,
                         "Some content is still left in sending envelope.")
        self.assertEqual(len(e1.contents.all()), 4,
                         "Content in receiving envelope is not correct.")
        for page in [p1, p2, p3, p4]:
            self.assertTrue(page in e1.get_content(),
                            "Page not found in receiving envelope.")
开发者ID:pombredanne,项目名称:django-dogwood,代码行数:36,代码来源:tests.py

示例3: test_move_contents_together

# 需要导入模块: from models import Box [as 别名]
# 或者: from models.Box import save [as 别名]
    def test_move_contents_together(self):
        # Make some test pages.
        p1 = Page()
        p1.title = 'Test Page 1'
        p1.save()
        p2 = Page()
        p2.title = 'Test Page 2'
        p2.save()

        # Make two test boxes.
        b1 = Box()
        b1.save()
        b2 = Box()
        b2.save()

        # Put two pages in box 1.
        b1.add_content( (p1, p2) )

        # Put two pages in the same box into an envelope.
        e.add_content( (p1, p2) )

        # Move the envelope to box 2.
        e.move_to_box(b2)

        self.assertFalse(b1.contains_content(p1), "Page 1 did not leave box 1.")
        self.assertFalse(b1.contains_content(p2), "Page 2 did not leave box 1.")
        self.assertTrue(b2.contains_content(p1), "Page 1 did not move to box 2.")
        self.assertTrue(b2.contains_content(p2), "Page 2 did not move to box 2.")
开发者ID:pombredanne,项目名称:django-dogwood,代码行数:30,代码来源:tests.py

示例4: addbox

# 需要导入模块: from models import Box [as 别名]
# 或者: from models.Box import save [as 别名]
def addbox(request):
    request.session.set_expiry(0)
    box = Box()
    location_id = request.POST['sel2']
    box.Location = Location.objects.get(id = location_id)
    box.save()

    return redirect('admin')
开发者ID:dkeske,项目名称:KutijaSajt,代码行数:10,代码来源:views.py

示例5: test_box_descriptor

# 需要导入模块: from models import Box [as 别名]
# 或者: from models.Box import save [as 别名]
    def test_box_descriptor(self):
        b = Box()
        self.assertTrue(b.descriptor is None, "Descriptor not initialized to None.")

        p = Page()
        p.title = 'Testbox 1'
        p.data = 'This Page is used as the descriptor for Testbox 1.'
        p.save()

        b.descriptor = p
        b.save()
        self.assertTrue(b.descriptor == p, "Descriptor not saved.")
        self.assertTrue(p.describes_box == b, "Descriptor does not point back to box.")
开发者ID:pombredanne,项目名称:django-dogwood,代码行数:15,代码来源:tests.py

示例6: test_envelope_integrity

# 需要导入模块: from models import Box [as 别名]
# 或者: from models.Box import save [as 别名]
    def test_envelope_integrity(self):
        """ Contents in an envelope must move from box to box together. """
        # Make some test pages.
        p1 = Page()
        p1.title = 'Test Page 1'
        p1.save()
        p2 = Page()
        p2.title = 'Test Page 2'
        p2.save()
        p3 = Page()
        p3.title = 'Test Page 3'
        p3.save()

        # Make two test boxes.
        b1 = Box()
        b1.save()
        b2 = Box()
        b2.save()

        # Put two pages in box 1.
        b1.add_content(p1)
        b1.add_content(p2)

        # Put the last page in box 2.
        b2.add_content(p3)

        # Put two pages in the same box into an envelope.
        e.add_content(p1)
        e.add_content(p2)

        # Try to put the last page (which is in a different box) into the envelope.
        try:
            e.add_content(p3)
            self.fail("Envelope allowed content from multiple boxes.")
        except EnvelopeIntegrityError:
            # It should have gotten this exception, if it's working right.
            pass

        # Try to take a page out of a box without the other pages in the envelope.
        try:
            b1.remove_content(p1)
            self.fail("Envelope allowed content to be removed from box by itself.")
        except EnvelopeIntegrityError:
            # It should have gotten this exception, if it's working right.
            pass
开发者ID:pombredanne,项目名称:django-dogwood,代码行数:47,代码来源:tests.py

示例7: test_box_contents

# 需要导入模块: from models import Box [as 别名]
# 或者: from models.Box import save [as 别名]
    def test_box_contents(self):
        b = Box()
        b.save()
        self.assertEqual(len(b.contents.all()), 0, "Box should start out empty.")

        p1 = Page()
        p1.title = 'Test Page 1'
        b.add_content(p1)
        p2 = Page()
        p2.title = 'Test Page 2'
        b.add_content(p2)
        self.assertTrue(b.contains_content(p1), "Page 1 not found in box.")
        self.assertTrue(b.contains_content(p2), "Page 2 not found in box.")

        b.remove_content(p1)
        self.assertFalse(b.contains_content(p1), "Page 1 not removed from box.")
        b.remove_content(p2)
        self.assertFalse(b.contains_content(p2), "Page 2 not removed from box.")

        self.assertEqual(len(b.contents.all()), 0, "Box should now be empty.")
开发者ID:pombredanne,项目名称:django-dogwood,代码行数:22,代码来源:tests.py

示例8: str

# 需要导入模块: from models import Box [as 别名]
# 或者: from models.Box import save [as 别名]
			box.name = name
			box.url = url
			box.message = message
			box.save()
			return simplejson.dumps( {'state': 'success', 'bb': bb, 'object_type':object_type, 'message': message, 'name': name, 'url': url, 'owner': request.user.username, 'pk':str(box.pk), 'box':box.box, 'planet': box.planet,  'modified': True } )

	for box in boxes:
		
		points = box['points']
		planet = str(box['planet']['x'])+','+str(box['planet']['y'])
		lockedAreas = Box.objects(planet=planet, box__geo_intersects=makeBox(points[0][0], points[0][1], points[2][0], points[2][1]) )
		if lockedAreas.count()>0:
			return simplejson.dumps( {'state': 'error', 'message': 'This area was already locked'} )

		b = Box(planet=planet, box=[points], owner=request.user.username, object_type=object_type, url=url, message=message, name=name, bb=bb)
		b.save()

		return simplejson.dumps( {'state': 'success', 'bb': bb, 'object_type':object_type, 'message': message, 'name': name, 'url': url, 'owner': request.user.username, 'pk':str(b.pk), 'box':b.box, 'planet': planet } )












开发者ID:arthur-test-account,项目名称:Romanesco,代码行数:20,代码来源:ajax.py

示例9: test_new_box

# 需要导入模块: from models import Box [as 别名]
# 或者: from models.Box import save [as 别名]
 def test_new_box(self):
     b = Box()
     b.save()
     self.assertTrue(b.pk > 0, "Box not created.")
开发者ID:pombredanne,项目名称:django-dogwood,代码行数:6,代码来源:tests.py


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