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


Python Tag.all方法代码示例

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


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

示例1: test_suggestion_tag_reverse

# 需要导入模块: from tags.models import Tag [as 别名]
# 或者: from tags.models.Tag import all [as 别名]
 def test_suggestion_tag_reverse(self):
     # Create a suggestion and tags but with a missing reverse reference.
     Reminder(key_name='a-b', title='a b', tags='a b'.split()).put()
     Reminder(key_name='b-c', title='b c', tags='b'.split()).put()
     Tag(key_name='a', suggestions='a-b'.split(), count=0).put()
     Tag(key_name='b', suggestions='b-c'.split(), count=0).put()
     self.assertEqual(Reminder.all().count(), 2)
     self.assertEqual(Tag.all().count(), 2)
     self.assertEqual(len(Tag.get_by_key_name('b').suggestions), 1)
     # Check that the missing tag-reminder reference is detected.
     response = self.client.get('/consistency/')
     self.assertTrue('suggestion_tag_reverse'
                     in response.context['problems'])
     self.assertTrue("Suggestion a-b references b but not reverse."
                     in response.content)
     # Simulate button click to fix this problem.
     response = self.client.post('/consistency/', {
             'suggestion_tag_reverse': "Create reverse references"})
     self.assertRedirects(response, '/consistency/')
     # Check that the tags are now existing.
     self.assertEqual(Reminder.all().count(), 2)
     self.assertEqual(Tag.all().count(), 2)
     self.assertEqual(len(Tag.get_by_key_name('b').suggestions), 2)
     response = self.client.get('/consistency/')
     self.assertFalse('suggestion_tag_reverse'
                      in response.context['problems'])
开发者ID:jcrocholl,项目名称:minderbot,代码行数:28,代码来源:tests.py

示例2: test_tag_suggestion_missing

# 需要导入模块: from tags.models import Tag [as 别名]
# 或者: from tags.models.Tag import all [as 别名]
 def test_tag_suggestion_missing(self):
     self.assertEqual(Tag.all().count(), 0)
     # Create tags but not all suggestions.
     Reminder(key_name='a-b', title='a b', tags='a b'.split()).put()
     Tag(key_name='a', count=2, suggestions='a-b a-c'.split()).put()
     Tag(key_name='b', count=2, suggestions='b-c'.split()).put()
     self.assertEqual(Tag.all().count(), 2)
     # Check that the missing suggestions are detected.
     response = self.client.get('/consistency/')
     self.assertTrue('tag_suggestion_missing'
                     in response.context['problems'])
     self.assertTrue("Tag a references missing suggestion a-c."
                     in response.content)
     self.assertTrue("Tag b references missing suggestion b-c."
                     in response.content)
     # Simulate button click to fix this problem.
     response = self.client.post('/consistency/', {
             'tag_suggestion_missing': "Create missing"})
     self.assertRedirects(response, '/consistency/')
     # Check that the references are now gone.
     self.assertEqual(Tag.all().count(), 1)
     self.assertEqual(Tag.get_by_key_name('a').count, 1)
     self.assertEqual(len(Tag.get_by_key_name('a').suggestions), 1)
     response = self.client.get('/consistency/')
     self.assertFalse('tag_suggestion_missing'
                      in response.context['problems'])
开发者ID:jcrocholl,项目名称:minderbot,代码行数:28,代码来源:tests.py

示例3: dump_app

# 需要导入模块: from tags.models import Tag [as 别名]
# 或者: from tags.models.Tag import all [as 别名]
def dump_app(request, app_name, format):
    if app_name == 'reminders':
        reminder_list = Reminder.all()
    elif app_name == 'tags':
        tag_list = Tag.all()
    template = 'dumpdata/%s.%s' % (app_name, format)
    return render_to_response(request, template, locals())
开发者ID:jcrocholl,项目名称:minderbot,代码行数:9,代码来源:views.py

示例4: test_tag_empty

# 需要导入模块: from tags.models import Tag [as 别名]
# 或者: from tags.models.Tag import all [as 别名]
 def test_tag_empty(self):
     # Create a tag without reminder references.
     self.assertEqual(Tag.all().count(), 0)
     Tag(key_name='a', suggestions=[], count=0).put()
     self.assertEqual(Tag.all().count(), 1)
     # Check that the empty tag is detected.
     response = self.client.get('/consistency/')
     self.assertTrue('tag_empty' in response.context['problems'])
     self.assertTrue("Tag a does not reference any suggestions."
                     in response.content)
     # Simulate button click to fix this problem.
     response = self.client.post('/consistency/',
                                 {'tag_empty': "Create missing tags"})
     self.assertRedirects(response, '/consistency/')
     # Check that the tags are now existing.
     self.assertEqual(Tag.all().count(), 0)
     response = self.client.get('/consistency/')
     self.assertFalse('tag_empty' in response.context['problems'])
开发者ID:jcrocholl,项目名称:minderbot,代码行数:20,代码来源:tests.py

示例5: test_suggestion_tag_missing

# 需要导入模块: from tags.models import Tag [as 别名]
# 或者: from tags.models.Tag import all [as 别名]
 def test_suggestion_tag_missing(self):
     self.assertEqual(Tag.all().count(), 0)
     # Create a reminder but not the tags.
     Reminder(key_name='a-b', title='a b', tags='a b'.split()).put()
     # Check that the missing tags are detected.
     response = self.client.get('/consistency/')
     self.assertTrue('suggestion_tag_missing'
                     in response.context['problems'])
     self.assertTrue("Suggestion a-b references missing tag a."
                     in response.content)
     self.assertTrue("Suggestion a-b references missing tag b."
                     in response.content)
     # Simulate button click to fix this problem.
     response = self.client.post('/consistency/', {
             'suggestion_tag_missing': "Create missing tags"})
     self.assertRedirects(response, '/consistency/')
     # Check that the tags are now existing.
     self.assertEqual(Tag.all().count(), 2)
     response = self.client.get('/consistency/')
     self.assertFalse('suggestion_tag_missing'
                      in response.context['problems'])
开发者ID:jcrocholl,项目名称:minderbot,代码行数:23,代码来源:tests.py

示例6: index

# 需要导入模块: from tags.models import Tag [as 别名]
# 或者: from tags.models.Tag import all [as 别名]
def index(request):
    """
    Display the current system status.
    """
    # Simple form to add new suggestions.
    suggestion_form = SuggestionForm(request.POST or None)
    if suggestion_form.is_valid():
        return submit_suggestion(request, suggestion_form)

    # Recent time intervals.
    day = datetime.now() - timedelta(hours=24)
    week = datetime.now() - timedelta(days=7)

    # Show newest suggestions.
    suggestion_count = Reminder.all().filter('owner', None).count()
    suggestion_count_24h = (Reminder.all().filter('owner', None)
                            .filter('created >', day).count())
    suggestion_count_7d = (Reminder.all().filter('owner', None)
                           .filter('created >', week).count())
    suggestion_list = (Reminder.all().filter('owner', None)
                       .order('-created').fetch(RECENT_LIMIT))

    # Show newest tags.
    tag_count = Tag.all().count()
    tag_count_24h = Tag.all().filter('created >', day).count()
    tag_count_7d = Tag.all().filter('created >', week).count()
    tag_list = Tag.all().order('-created').fetch(RECENT_LIMIT * 4)

    # Registered user accounts.
    user_count = User.all().count()
    user_count_24h = User.all().filter('date_joined >', day).count()
    user_count_7d = User.all().filter('date_joined >', week).count()
    user_list = User.all().order('-date_joined').fetch(RECENT_LIMIT)

    # Show newest feedback.
    # feedback_count = Feedback.all().count()
    # feedback_count_24h = Feedback.all().filter('submitted >', day).count()
    # feedback_count_7d = Feedback.all().filter('submitted >', week).count()
    # feedback_list = Feedback.all().order('-submitted').fetch(RECENT_LIMIT)
    return render_to_response(request, 'dashboard/index.html', locals())
开发者ID:jcrocholl,项目名称:minderbot,代码行数:42,代码来源:views.py


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