本文整理汇总了Python中apps.widgets.smartgrid.models.ActionMember.award_date方法的典型用法代码示例。如果您正苦于以下问题:Python ActionMember.award_date方法的具体用法?Python ActionMember.award_date怎么用?Python ActionMember.award_date使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类apps.widgets.smartgrid.models.ActionMember
的用法示例。
在下文中一共展示了ActionMember.award_date方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: testCommitmentAchievement
# 需要导入模块: from apps.widgets.smartgrid.models import ActionMember [as 别名]
# 或者: from apps.widgets.smartgrid.models.ActionMember import award_date [as 别名]
def testCommitmentAchievement(self):
"""Check that the user's commitment achievements are loaded."""
commitment = Commitment(
title="Test commitment",
description="A commitment!",
point_value=10,
type="commitment",
slug="test-commitment",
)
commitment.save()
# Test that profile page has a pending activity.
member = ActionMember(user=self.user, action=commitment)
member.save()
response = self.client.get(reverse("profile_index"))
self.assertContains(response,
reverse("activity_task", args=(commitment.type, commitment.slug,)))
self.assertContains(response, "In Progress")
self.assertContains(response, "Commitment:")
self.assertNotContains(response, "You have nothing in progress or pending.")
# Test that the profile page has a rejected activity
member.award_date = datetime.datetime.today()
member.save()
response = self.client.get(reverse("profile_index"))
self.assertContains(response,
reverse("activity_task", args=(commitment.type, commitment.slug,)))
self.assertNotContains(response, "You have not been awarded anything yet!")
self.assertNotContains(response, "In Progress")
示例2: testDeleteRemovesPoints
# 需要导入模块: from apps.widgets.smartgrid.models import ActionMember [as 别名]
# 或者: from apps.widgets.smartgrid.models.ActionMember import award_date [as 别名]
def testDeleteRemovesPoints(self):
"""Test that deleting a commitment member after it is completed removes the user's
points."""
points = self.user.profile.points()
# Setup to check round points.
(entry, _) = self.user.profile.scoreboardentry_set.get_or_create(
round_name=self.current_round)
round_points = entry.points
commitment_member = ActionMember(user=self.user, action=self.commitment,
completion_date=datetime.datetime.today())
commitment_member.save()
commitment_member.award_date = datetime.datetime.today()
commitment_member.approval_status = "approved"
commitment_member.save()
award_date = commitment_member.award_date
commitment_member.delete()
# Verify nothing has changed.
profile = self.user.profile
self.assertTrue(
profile.last_awarded_submission() is None or
profile.last_awarded_submission() < award_date)
self.assertEqual(points, profile.points())
entry = self.user.profile.scoreboardentry_set.get(round_name=self.current_round)
self.assertEqual(round_points, entry.points)
self.assertTrue(
entry.last_awarded_submission is None or entry.last_awarded_submission < award_date)
示例3: testCompletionAddsPoints
# 需要导入模块: from apps.widgets.smartgrid.models import ActionMember [as 别名]
# 或者: from apps.widgets.smartgrid.models.ActionMember import award_date [as 别名]
def testCompletionAddsPoints(self):
"""Tests that completing a task adds points."""
points = self.user.profile.points()
# Setup to check round points.
(entry, _) = self.user.profile.scoreboardentry_set.get_or_create(
round_name=self.current_round)
round_points = entry.points
commitment_member = ActionMember(user=self.user, action=self.commitment,
completion_date=datetime.datetime.today())
commitment_member.save()
# Check that the user's signup point.
self.assertEqual(points + score_mgr.signup_points(), self.user.profile.points())
entry = self.user.profile.scoreboardentry_set.get(round_name=self.current_round)
self.assertEqual(round_points + score_mgr.signup_points(), entry.points)
commitment_member.award_date = datetime.datetime.today()
commitment_member.approval_status = "approved"
commitment_member.save()
points += commitment_member.action.commitment.point_value
self.assertEqual(points + score_mgr.signup_points(), self.user.profile.points())
self.assertEqual(self.user.profile.last_awarded_submission(),
commitment_member.award_date)
entry = self.user.profile.scoreboardentry_set.get(round_name=self.current_round)
round_points += commitment_member.action.commitment.point_value
self.assertEqual(round_points + score_mgr.signup_points(), entry.points)
self.assertTrue(
abs(entry.last_awarded_submission - commitment_member.award_date) < datetime.timedelta(
minutes=1))
示例4: testPopularCommitments
# 需要导入模块: from apps.widgets.smartgrid.models import ActionMember [as 别名]
# 或者: from apps.widgets.smartgrid.models.ActionMember import award_date [as 别名]
def testPopularCommitments(self):
"""Tests that we can retrieve the most popular commitments."""
commitment_member = ActionMember(user=self.user, action=self.commitment)
commitment_member.award_date = datetime.datetime.today()
commitment_member.approval_status = "approved"
commitment_member.save()
commitments = smartgrid.get_popular_actions("commitment", "approved")
self.assertEqual(commitments[0].title, self.commitment.title)
self.assertEqual(commitments[0].completions, 1, "Most popular commitment should have one completion.")
示例5: testHasCommitment
# 需要导入模块: from apps.widgets.smartgrid.models import ActionMember [as 别名]
# 或者: from apps.widgets.smartgrid.models.ActionMember import award_date [as 别名]
def testHasCommitment(self):
"""Tests that has_action works for a commitment in progress."""
commitment = Commitment(
title="Test commitment",
type="commitment",
name="Test",
slug="test-commitment",
description="A commitment!",
point_value=10,
)
commitment.save()
# Test as an unlock condition.
self.quest.unlock_conditions = "submitted_action(slug='test-commitment')"
self.quest.save()
self.assertTrue(self.quest not in get_quests(self.user),
"User should not be able to participate in this quest.")
member = ActionMember(user=self.user, action=commitment)
member.save()
self.assertTrue(submitted_action(self.user, slug='test-commitment'),
"User should have a commitment in progress.")
self.assertTrue(submitted_some_of(self.user, action_type="commitment"),
"User should have a commitment in progress.")
self.assertTrue(self.quest in get_quests(self.user)["available_quests"],
"User should be able to participate in this quest.")
self.quest.unlock_conditions = "submitted_some_of(action_type='commitment')"
self.quest.save()
self.assertTrue(self.quest in get_quests(self.user)["available_quests"],
"User should be able to participate in this quest.")
member.award_date = datetime.datetime.today()
member.save()
self.assertTrue(submitted_action(self.user, slug='test-commitment'),
"User should have a completed commitment.")
self.assertTrue(submitted_some_of(self.user, action_type="commitment"),
"User should have a completed commitment.")
# Test as a completion condition
self.quest.accept(self.user)
self.quest.completion_conditions = "not submitted_action(slug='test-commitment')"
self.quest.save()
self.assertTrue(self.quest not in possibly_completed_quests(self.user),
"User should not be able to complete this quest.")
self.quest.completion_conditions = "not submitted_some_of(action_type='commitment')"
self.quest.save()
self.assertTrue(self.quest not in possibly_completed_quests(self.user),
"User should not be able to complete this quest.")
self.quest.completion_conditions = "submitted_action(slug='test-commitment')"
self.quest.save()
self.assertTrue(self.quest in possibly_completed_quests(self.user),
"User should be able to complete this quest.")
示例6: testCommitmentsNumCompleted
# 需要导入模块: from apps.widgets.smartgrid.models import ActionMember [as 别名]
# 或者: from apps.widgets.smartgrid.models.ActionMember import award_date [as 别名]
def testCommitmentsNumCompleted(self):
"""Tests that approved_some_of works for a completed commitment."""
commitment = Commitment(
title="Test commitment",
type="commitment",
slug="test",
name="Test",
description="A commitment!",
point_value=10,
)
commitment.save()
member = ActionMember(user=self.user, action=commitment)
member.save()
self.assertFalse(approved_some_of(self.user, 1),
"User with commitment in progress should not have completed a task.")
# Test as an unlock condition
self.quest.unlock_conditions = "approved_some_of(1)"
self.quest.save()
self.assertTrue(self.quest not in get_quests(self.user),
"User should not be able to participate in this quest.")
member.award_date = datetime.datetime.today()
member.approval_status = "approved"
member.save()
self.assertTrue(approved_some_of(self.user, 1),
"User that has a completed commitment did not complete a task.")
self.assertTrue(self.quest in get_quests(self.user)["available_quests"],
"User should be able to participate in this quest.")
# Test as a completion condition
self.quest.accept(self.user)
self.quest.completion_conditions = "approved_some_of(2)"
self.quest.save()
self.assertTrue(self.quest not in possibly_completed_quests(self.user),
"User should not be able to complete this quest.")
self.quest.completion_conditions = "approved_some_of(1)"
self.quest.save()
self.assertTrue(self.quest in possibly_completed_quests(self.user),
"User should be able to complete this quest.")