本文整理汇总了Python中treemap.models.Plot.refresh_from_db方法的典型用法代码示例。如果您正苦于以下问题:Python Plot.refresh_from_db方法的具体用法?Python Plot.refresh_from_db怎么用?Python Plot.refresh_from_db使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类treemap.models.Plot
的用法示例。
在下文中一共展示了Plot.refresh_from_db方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: UpdateTestCase
# 需要导入模块: from treemap.models import Plot [as 别名]
# 或者: from treemap.models.Plot import refresh_from_db [as 别名]
class UpdateTestCase(LocalMediaTestCase):
def setUp(self):
super(UpdateTestCase, self).setUp()
self.image = self.load_resource('tree1.gif')
self.test_start = timezone.now()
self.point = Point(-8515941.0, 4953519.0)
self.instance = make_instance(point=self.point)
self.user = make_commander_user(self.instance)
self.plot = Plot(geom=self.point, instance=self.instance)
self.plot.save_with_user(self.user)
def max_audit_for_model_type(self, models):
if isinstance(models, basestring):
models = [models]
audits = Audit.objects.filter(model__in=models)\
.order_by('-created')
if audits:
return audits[0]
def clear_updated_at(self):
# to_timestamp(0) is the unix epoch 1970-1-1 00:00
execute_sql(
"UPDATE treemap_mapfeature SET updated_at = to_timestamp(0);")
def clear_and_set_and_reload(self):
self.clear_updated_at()
set_map_feature_updated_at()
self.plot.refresh_from_db()
示例2: UpdatedFieldsTest
# 需要导入模块: from treemap.models import Plot [as 别名]
# 或者: from treemap.models.Plot import refresh_from_db [as 别名]
class UpdatedFieldsTest(LocalMediaTestCase):
def setUp(self):
super(UpdatedFieldsTest, self).setUp()
self.point = Point(-8515941.0, 4953519.0)
self.instance = make_instance(point=self.point)
self.user = make_commander_user(self.instance)
self.fellow = make_commander_user(self.instance, 'other-commander')
self.plot = Plot(geom=self.point, instance=self.instance)
self.plot.save_with_user(self.user)
self.plot.refresh_from_db()
self.initial_updated = self.plot.updated_at
def test_initial_updated_by(self):
self.assertEqual(self.plot.updated_by, self.user)
def test_update_sets_updated(self):
self.plot.width = 22
self.plot.save_with_user(self.fellow)
self.assertGreater(self.plot.updated_at, self.initial_updated)
self.assertEqual(self.plot.updated_by, self.fellow)
def test_add_tree_sets_updated(self):
tree = Tree(diameter=10, plot=self.plot, instance=self.instance)
tree.save_with_user(self.fellow)
self.plot.refresh_from_db()
self.assertGreater(self.plot.updated_at, self.initial_updated)
self.assertEqual(self.plot.updated_by, self.fellow)
def test_update_tree_sets_updated(self):
tree = Tree(diameter=10, plot=self.plot, instance=self.instance)
tree.save_with_user(self.user)
self.plot.refresh_from_db()
self.inital_updated = self.plot.updated_at
tree.height = 22
tree.save_with_user(self.fellow)
self.plot.refresh_from_db()
self.assertGreater(self.plot.updated_at, self.initial_updated)
self.assertEqual(self.plot.updated_by, self.fellow)
def test_delete_tree_sets_updated(self):
tree = Tree(diameter=10, plot=self.plot, instance=self.instance)
tree.save_with_user(self.user)
self.plot.refresh_from_db()
self.inital_updated = self.plot.updated_at
tree.delete_with_user(self.fellow)
self.plot.refresh_from_db()
self.assertGreater(self.plot.updated_at, self.initial_updated)
self.assertEqual(self.plot.updated_by, self.fellow)
def test_add_photo_sets_updated(self):
tree = Tree(diameter=10, plot=self.plot, instance=self.instance)
tree.save_with_user(self.user)
photo = TreePhoto(instance=self.instance,
map_feature=self.plot, tree=tree)
photo.set_image(self.load_resource('tree1.gif'))
photo.save_with_user(self.fellow)
self.plot.refresh_from_db()
self.assertGreater(self.plot.updated_at, self.initial_updated)
self.assertEqual(self.plot.updated_by, self.fellow)