• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python cache_mapper.get_workout_canonical函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中wger.utils.cache.cache_mapper.get_workout_canonical函数的典型用法代码示例。如果您正苦于以下问题:Python get_workout_canonical函数的具体用法?Python get_workout_canonical怎么用?Python get_workout_canonical使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



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

示例1: test_canonical_form_cache

    def test_canonical_form_cache(self):
        '''
        Tests that the workout cache of the canonical form is correctly generated
        '''
        self.assertFalse(cache.get(cache_mapper.get_workout_canonical(1)))

        workout = Workout.objects.get(pk=1)
        workout.canonical_representation
        self.assertTrue(cache.get(cache_mapper.get_workout_canonical(1)))
开发者ID:boardman,项目名称:wger,代码行数:9,代码来源:test_workout_canonical.py


示例2: test_canonical_form_cache_delete

    def test_canonical_form_cache_delete(self):
        '''
        Tests the workout cache when deleting
        '''
        day = Day.objects.get(pk=1)
        day.canonical_representation
        self.assertTrue(cache.get(cache_mapper.get_workout_canonical(day.training_id)))

        day.delete()
        self.assertFalse(cache.get(cache_mapper.get_workout_canonical(day.training_id)))
开发者ID:dashdrum,项目名称:wger,代码行数:10,代码来源:test_day.py


示例3: test_canonical_form_cache_delete

    def test_canonical_form_cache_delete(self):
        '''
        Tests the workout cache when deleting
        '''
        workout = Workout.objects.get(pk=1)
        workout.canonical_representation
        self.assertTrue(cache.get(cache_mapper.get_workout_canonical(1)))

        workout.delete()
        self.assertFalse(cache.get(cache_mapper.get_workout_canonical(1)))
开发者ID:boardman,项目名称:wger,代码行数:10,代码来源:test_workout_canonical.py


示例4: test_canonical_form_cache_save

    def test_canonical_form_cache_save(self):
        '''
        Tests the workout cache when saving
        '''
        set = Set.objects.get(pk=1)
        set.exerciseday.training.canonical_representation
        self.assertTrue(cache.get(cache_mapper.get_workout_canonical(set.exerciseday.training_id)))

        set.save()
        self.assertFalse(cache.get(cache_mapper.get_workout_canonical(set.exerciseday.training_id)))
开发者ID:DeveloperMal,项目名称:wger,代码行数:10,代码来源:test_set.py


示例5: test_canonical_form_cache_delete

    def test_canonical_form_cache_delete(self):
        '''
        Tests the workout cache when deleting
        '''
        setting = Setting.objects.get(pk=1)
        workout_id = setting.set.exerciseday.training_id
        setting.set.exerciseday.training.canonical_representation
        self.assertTrue(cache.get(cache_mapper.get_workout_canonical(workout_id)))

        setting.delete()
        self.assertFalse(cache.get(cache_mapper.get_workout_canonical(workout_id)))
开发者ID:DeveloperMal,项目名称:wger,代码行数:11,代码来源:test_set.py


示例6: test_canonical_form_cache_save

    def test_canonical_form_cache_save(self):
        '''
        Tests the workout cache when saving
        '''
        exercise = Exercise.objects.get(pk=2)
        for set in exercise.set_set.all():
            set.exerciseday.training.canonical_representation
            workout_id = set.exerciseday.training_id
            self.assertTrue(cache.get(cache_mapper.get_workout_canonical(workout_id)))

            exercise.save()
            self.assertFalse(cache.get(cache_mapper.get_workout_canonical(workout_id)))
开发者ID:gelliravi,项目名称:wger,代码行数:12,代码来源:test_exercise.py


示例7: canonical_representation

    def canonical_representation(self):
        '''
        Returns a canonical representation of the workout

        This form makes it easier to cache and use everywhere where all or part
        of a workout structure is needed. As an additional benefit, the template
        caches are not needed anymore.
        '''
        workout_canonical_form = cache.get(cache_mapper.get_workout_canonical(self.pk))
        if not workout_canonical_form:
            day_canonical_repr = []
            muscles_front = []
            muscles_back = []
            muscles_front_secondary = []
            muscles_back_secondary = []

            # Sort list by weekday
            day_list = [i for i in self.day_set.select_related()]
            day_list.sort(key=lambda day: day.get_first_day_id)

            for day in day_list:
                canonical_repr_day = day.get_canonical_representation()

                # Collect all muscles
                for i in canonical_repr_day['muscles']['front']:
                    if i not in muscles_front:
                        muscles_front.append(i)
                for i in canonical_repr_day['muscles']['back']:
                    if i not in muscles_back:
                        muscles_back.append(i)
                for i in canonical_repr_day['muscles']['frontsecondary']:
                    if i not in muscles_front_secondary:
                        muscles_front_secondary.append(i)
                for i in canonical_repr_day['muscles']['backsecondary']:
                    if i not in muscles_back_secondary:
                        muscles_back_secondary.append(i)

                day_canonical_repr.append(canonical_repr_day)

            workout_canonical_form = {'obj': self,
                                      'muscles': {'front': muscles_front,
                                                  'back': muscles_back,
                                                  'frontsecondary': muscles_front_secondary,
                                                  'backsecondary': muscles_back_secondary},
                                      'day_list': day_canonical_repr}
            # Save to cache
            cache.set(cache_mapper.get_workout_canonical(self.pk), workout_canonical_form)

        return workout_canonical_form
开发者ID:DeveloperMal,项目名称:wger,代码行数:49,代码来源:models.py


示例8: test_canonical_form_cache_delete

    def test_canonical_form_cache_delete(self):
        '''
        Tests the workout cache when deleting
        '''
        exercise = Exercise.objects.get(pk=2)

        workout_ids = []
        for set in exercise.set_set.all():
            workout_id = set.exerciseday.training_id
            workout_ids.append(workout_id)
            set.exerciseday.training.canonical_representation
            self.assertTrue(cache.get(cache_mapper.get_workout_canonical(workout_id)))

        exercise.delete()
        for workout_id in workout_ids:
            self.assertFalse(cache.get(cache_mapper.get_workout_canonical(workout_id)))
开发者ID:gelliravi,项目名称:wger,代码行数:16,代码来源:test_exercise.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python language.load_language函数代码示例发布时间:2022-05-26
下一篇:
Python cache.reset_workout_canonical_form函数代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap