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


Python Plot.refresh_from_db方法代码示例

本文整理汇总了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()
开发者ID:OpenTreeMap,项目名称:otm-core,代码行数:31,代码来源:test_cached_audit_info.py

示例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)
开发者ID:OpenTreeMap,项目名称:otm-core,代码行数:65,代码来源:test_map_feature.py


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