本文整理汇总了Python中apps.widgets.smartgrid.models.ActionMember.approval_status方法的典型用法代码示例。如果您正苦于以下问题:Python ActionMember.approval_status方法的具体用法?Python ActionMember.approval_status怎么用?Python ActionMember.approval_status使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类apps.widgets.smartgrid.models.ActionMember
的用法示例。
在下文中一共展示了ActionMember.approval_status方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: testFullSpectrum
# 需要导入模块: from apps.widgets.smartgrid.models import ActionMember [as 别名]
# 或者: from apps.widgets.smartgrid.models.ActionMember import approval_status [as 别名]
def testFullSpectrum(self):
"""Tests the predicates related to full spectrum."""
self.assertFalse(submitted_some_full_spectrum(self.user, count=1),
"submitted_some_full_spectrum(1) should be false")
self.assertFalse(approved_some_full_spectrum(self.user, count=1),
"approved_some_full_spectrum(1) should be false")
action_member_activity = ActionMember(user=self.user, action=self.activity)
action_member_activity.save()
self.assertFalse(submitted_some_full_spectrum(self.user, count=1),
"submitted_some_full_spectrum(1) should be false")
self.assertFalse(approved_some_full_spectrum(self.user, count=1),
"approved_some_full_spectrum(1) should be false")
action_member_commitment = ActionMember(user=self.user, action=self.commitment)
action_member_commitment.save()
action_member_event = ActionMember(user=self.user, action=self.event)
action_member_event.save()
self.assertTrue(submitted_some_full_spectrum(self.user, count=1),
"submitted_some_full_spectrum(1) should be true")
self.assertFalse(approved_some_full_spectrum(self.user, count=1),
"approved_some_full_spectrum(1) should be false")
action_member_activity.approval_status = 'approved'
action_member_activity.save()
self.assertFalse(approved_some_full_spectrum(self.user, count=1),
"approved_some_full_spectrum(1) should be false")
action_member_commitment.approval_status = 'approved'
action_member_commitment.save()
action_member_event.approval_status = 'approved'
action_member_event.save()
self.assertTrue(approved_some_full_spectrum(self.user, count=1),
"approved_some_full_spectrum(1) should be true")
示例2: testCompletionAddsPoints
# 需要导入模块: from apps.widgets.smartgrid.models import ActionMember [as 别名]
# 或者: from apps.widgets.smartgrid.models.ActionMember import approval_status [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))
示例3: testApproveAddsPoints
# 需要导入模块: from apps.widgets.smartgrid.models import ActionMember [as 别名]
# 或者: from apps.widgets.smartgrid.models.ActionMember import approval_status [as 别名]
def testApproveAddsPoints(self):
"""Test for verifying that approving a user awards them 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
round_last_awarded = entry.last_awarded_submission
activity_points = self.activity.point_value
activity_member = ActionMember(user=self.user, action=self.activity)
activity_member.save()
# Verify that nothing has changed.
self.assertEqual(points, self.user.profile.points())
entry = self.user.profile.scoreboardentry_set.get(round_name=self.current_round)
self.assertEqual(round_points, entry.points)
self.assertEqual(round_last_awarded, entry.last_awarded_submission)
activity_member.approval_status = "approved"
activity_member.save()
# Verify overall score changed.
new_points = self.user.profile.points()
self.assertEqual(new_points - points, activity_points)
# Verify round score changed.
entry = self.user.profile.scoreboardentry_set.get(round_name=self.current_round)
self.assertEqual(round_points + activity_points, entry.points)
self.assertTrue(abs(
activity_member.submission_date - entry.last_awarded_submission) < datetime.timedelta(
minutes=1))
示例4: testDeleteRemovesPoints
# 需要导入模块: from apps.widgets.smartgrid.models import ActionMember [as 别名]
# 或者: from apps.widgets.smartgrid.models.ActionMember import approval_status [as 别名]
def testDeleteRemovesPoints(self):
"""Test that deleting an approved ActionMember removes their 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
activity_member = ActionMember(user=self.user, action=self.activity)
activity_member.approval_status = "approved"
activity_member.save()
award_date = activity_member.award_date
activity_member.delete()
new_points = self.user.profile.points()
self.assertEqual(points, new_points)
self.assertTrue(self.user.profile.last_awarded_submission() is None)
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)
示例5: testRejectThenApprove
# 需要导入模块: from apps.widgets.smartgrid.models import ActionMember [as 别名]
# 或者: from apps.widgets.smartgrid.models.ActionMember import approval_status [as 别名]
def testRejectThenApprove(self):
"""Test that Reject then approve a user removes their points."""
points = self.user.get_profile().points()
activity_member = ActionMember(user=self.user, action=self.activity, submission_date=datetime.datetime.today())
activity_member.approval_status = "rejected"
activity_member.save()
self.assertEqual(len(mail.outbox), 1, "Check that the rejection sent an email.")
self.assertTrue(activity_member.award_date is None)
self.assertTrue(self.user.get_profile().last_awarded_submission() is None)
activity_member.approval_status = "approved"
activity_member.save()
new_points = self.user.get_profile().points()
self.assertEqual(points + activity_member.points_awarded, new_points)
示例6: testPopularActivities
# 需要导入模块: from apps.widgets.smartgrid.models import ActionMember [as 别名]
# 或者: from apps.widgets.smartgrid.models.ActionMember import approval_status [as 别名]
def testPopularActivities(self):
"""Check which activity is the most popular."""
activity_member = ActionMember(user=self.user, action=self.activity)
activity_member.approval_status = "approved"
activity_member.save()
activities = smartgrid.get_popular_actions("activity", "approved")
self.assertEqual(activities[0].title, self.activity.title)
示例7: testPopularCommitments
# 需要导入模块: from apps.widgets.smartgrid.models import ActionMember [as 别名]
# 或者: from apps.widgets.smartgrid.models.ActionMember import approval_status [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.")
示例8: complete_setup_activity
# 需要导入模块: from apps.widgets.smartgrid.models import ActionMember [as 别名]
# 或者: from apps.widgets.smartgrid.models.ActionMember import approval_status [as 别名]
def complete_setup_activity(user):
"""complete the setup activity."""
# error out if we can't find to the activity.
activity = get_setup_activity()
members = ActionMember.objects.filter(user=user, action=activity)
if not members:
# if points not awarded, do so.
member = ActionMember(action=activity, user=user)
member.approval_status = "approved"
member.save()
示例9: complete
# 需要导入模块: from apps.widgets.smartgrid.models import ActionMember [as 别名]
# 或者: from apps.widgets.smartgrid.models.ActionMember import approval_status [as 别名]
def complete(request, event):
"""complete the event and try to claim point."""
user = request.user
if request.method == "POST":
form = ActivityCodeForm(request.POST, request=request, action=event)
if form.is_valid():
# Approve the activity (confirmation code is validated in
# forms.ActivityTextForm.clean())
code = ConfirmationCode.objects.get(code=form.cleaned_data["response"].lower())
code.is_active = False
code.user = user
code.save()
try:
action_member = ActionMember.objects.get(user=user, action=event)
except ObjectDoesNotExist:
action_member = ActionMember(user=user, action=event)
action_member.approval_status = "approved"
value = event.point_value
action_member.social_email = form.cleaned_data["social_email"].lower()
try:
action_member.save()
except IntegrityError:
messages.error = 'Sorry, but it appears that you have already added this activity.'
return HttpResponseRedirect(
reverse("activity_task", args=(event.type, event.slug,)))
response = HttpResponseRedirect(
reverse("activity_task", args=(event.type, event.slug,)))
if value:
notification = "You just earned " + str(value) + " points."
response.set_cookie("task_notify", notification)
return response
# invalid form
# rebuild the form
form.form_title = "Get your points"
return render_to_response("task.html", {
"action": event,
"form": form,
"completed_count": 0,
"team_members": None,
"display_form": True,
"reminders": None,
}, context_instance=RequestContext(request))
return HttpResponseRedirect(reverse("activity_task", args=(event.type, event.slug,)))
示例10: testRejectionNotifications
# 需要导入模块: from apps.widgets.smartgrid.models import ActionMember [as 别名]
# 或者: from apps.widgets.smartgrid.models.ActionMember import approval_status [as 别名]
def testRejectionNotifications(self):
"""
Test that notifications are created by rejections and
are marked as read when the member changes back to pending.
"""
notifications = UserNotification.objects.count()
activity_member = ActionMember(user=self.user, action=self.activity,
submission_date=datetime.datetime.today())
activity_member.approval_status = "rejected"
activity_member.submission_date = datetime.datetime.today()
activity_member.save()
self.assertEqual(UserNotification.objects.count(), notifications + 1,
"New notification should have been created.")
notice = activity_member.notifications.all()[0]
self.assertTrue(notice.unread, "Notification should be unread.")
activity_member.approval_status = "pending"
activity_member.save()
notice = activity_member.notifications.all()[0]
self.assertFalse(notice.unread, "Notification should be marked as read.")
示例11: testNumTasksCompletedWithType
# 需要导入模块: from apps.widgets.smartgrid.models import ActionMember [as 别名]
# 或者: from apps.widgets.smartgrid.models.ActionMember import approval_status [as 别名]
def testNumTasksCompletedWithType(self):
"""test task completed."""
activity = Activity(
type="activity",
name="Test",
slug="test",
title="Test activity",
description="Variable points!",
expected_duration=10,
point_value=10,
pub_date=datetime.datetime.today(),
expire_date=datetime.datetime.today() + datetime.timedelta(days=7),
confirm_type="text",
)
activity.save()
# Test activities
member = ActionMember(user=self.user, action=activity, approval_status="pending")
member.save()
self.assertFalse(approved_some_of(self.user, 1, action_type="activity"),
"User with pending activity should not have completed a task.")
# Test within context of a quest
self.quest.unlock_conditions = "approved_some_of(1, action_type='activity')"
self.quest.save()
quests = get_quests(self.user)
self.assertTrue(self.quest not in quests,
"User should not be able to participate in this quest.")
# Check that the user can now add the quest.
member.approval_status = "approved"
member.save()
quests = get_quests(self.user)
self.assertTrue(self.quest in quests["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, action_type='activity')"
self.quest.save()
completed_quests = possibly_completed_quests(self.user)
self.assertTrue(self.quest not in completed_quests,
"User should not be able to complete the quest.")
self.quest.completion_conditions = "approved_some_of(1, action_type='activity')"
self.quest.save()
completed_quests = possibly_completed_quests(self.user)
self.assertTrue(self.quest in completed_quests, "User should have completed the quest.")
示例12: testAction
# 需要导入模块: from apps.widgets.smartgrid.models import ActionMember [as 别名]
# 或者: from apps.widgets.smartgrid.models.ActionMember import approval_status [as 别名]
def testAction(self):
"""Tests submitted_action and approved_action predicates."""
self.assertFalse(submitted_some(self.user, count=1), "Haven't submitted any yet")
action_member = ActionMember(user=self.user, action=self.activity)
action_member.save()
self.assertTrue(submitted_some(self.user, count=1), "Have submitted one.")
self.assertTrue(submitted_action(self.user, self.activity.slug),
"submitted_action should be true")
self.assertFalse(approved_action(self.user, self.activity.slug),
"approved_action should be false")
self.assertFalse(approved_some(self.user, count=1), "Haven't had it approved yet.")
action_member.approval_status = 'approved'
action_member.save()
self.assertTrue(approved_action(self.user, self.activity.slug),
"approved_action should be true")
self.assertTrue(approved_some(self.user, count=1), "Have had one approved.")
示例13: testCommitmentsNumCompleted
# 需要导入模块: from apps.widgets.smartgrid.models import ActionMember [as 别名]
# 或者: from apps.widgets.smartgrid.models.ActionMember import approval_status [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.")
示例14: testResource
# 需要导入模块: from apps.widgets.smartgrid.models import ActionMember [as 别名]
# 或者: from apps.widgets.smartgrid.models.ActionMember import approval_status [as 别名]
def testResource(self):
"""Tests the predicates related to resources."""
self.activity.related_resource = 'water'
self.activity.save()
self.event.related_resource = 'energy'
self.event.save()
self.commitment.related_resource = 'energy'
self.commitment.save()
self.assertFalse(submitted_all_of_resource(self.user, resource='water'),
"submitted_all_of_resource should be false")
self.assertFalse(submitted_some_of_resource(self.user, resource='water', count=1),
"submitted_some_of_resource should be false")
self.assertFalse(approved_some_of_resource(self.user, resource='water', count=1),
"approved_some_of_resource(water) should be false")
self.assertFalse(approved_all_of_resource(self.user, resource='water'),
"approved_all_of_resource(water) should be false")
action_member_activity = ActionMember(user=self.user, action=self.activity)
action_member_activity.save()
self.assertTrue(submitted_some_of_resource(self.user, resource='water', count=1),
"submitted_some_of_resource should be true")
self.assertTrue(submitted_all_of_resource(self.user, resource='water'),
"submitted_all_of_resource should be true")
self.assertFalse(submitted_some_of_resource(self.user, resource='energy', count=1),
"submitted_some_of_resource(energy, 1) should be false")
action_member_commitment = ActionMember(user=self.user, action=self.commitment)
action_member_commitment.save()
self.assertTrue(submitted_some_of_resource(self.user, resource='energy', count=1),
"submitted_some_of_resource(energy,1) should be true")
self.assertFalse(submitted_all_of_resource(self.user, resource='energy'),
"submitted_all_of_resource(energy) should be false")
action_member_event = ActionMember(user=self.user, action=self.event)
action_member_event.save()
self.assertTrue(submitted_some_of_resource(self.user, resource='energy', count=2),
"submitted_some_of_resource(energy,1) should be true")
self.assertTrue(submitted_all_of_resource(self.user, resource='energy'),
"submitted_all_of_resource(energy) should be true")
action_member_activity.approval_status = 'approved'
action_member_activity.save()
self.assertTrue(approved_some_of_resource(self.user, resource='water', count=1),
"approved_some_of_resource(water, 1) should be true")
self.assertTrue(approved_all_of_resource(self.user, resource='water'),
"approved_all_of_resource(water) should be true")
示例15: testType
# 需要导入模块: from apps.widgets.smartgrid.models import ActionMember [as 别名]
# 或者: from apps.widgets.smartgrid.models.ActionMember import approval_status [as 别名]
def testType(self):
"""Tests the predicates related to action_type."""
self.assertFalse(submitted_some_of_type(self.user, action_type='activity', count=1),
"submitted_some_of_type(activity,1) should be false")
self.assertFalse(submitted_some_of_type(self.user, action_type='commitment', count=1),
"submitted_some_of_type(commitment,1) should be false")
self.assertFalse(submitted_some_of_type(self.user, action_type='event', count=1),
"submitted_some_of_type(event,1) should be false")
self.assertFalse(submitted_all_of_type(self.user, action_type='activity'),
"submitted_all_of_type(activity) should be false")
self.assertFalse(submitted_all_of_type(self.user, action_type='commitment'),
"submitted_all_of_type(commitment) should be false")
self.assertFalse(submitted_all_of_type(self.user, action_type='event'),
"submitted_all_of_type(event) should be false")
action_member_activity = ActionMember(user=self.user, action=self.activity)
action_member_activity.save()
self.assertTrue(submitted_some_of_type(self.user, action_type='activity', count=1),
"submitted_some_of_type(activity,1) should be true")
self.assertFalse(submitted_some_of_type(self.user, action_type='commitment', count=1),
"submitted_some_of_type(commitment,1) should be false")
self.assertFalse(submitted_some_of_type(self.user, action_type='event', count=1),
"submitted_some_of_type(event,1) should be false")
self.assertTrue(submitted_all_of_type(self.user, action_type='activity'),
"submitted_all_of_type(activity) should be true")
self.assertFalse(submitted_all_of_type(self.user, action_type='commitment'),
"submitted_all_of_type(commitment) should be false")
self.assertFalse(submitted_all_of_type(self.user, action_type='event'),
"submitted_all_of_type(event) should be false")
self.assertFalse(approved_some_of_type(self.user, action_type='activity', count=1),
"approved_some_of_type(activity,1) should be false")
self.assertFalse(approved_all_of_type(self.user, action_type='activity'),
"approved_some_of_type(activity) should be false")
action_member_activity.approval_status = 'approved'
action_member_activity.save()
self.assertTrue(approved_some_of_type(self.user, action_type='activity', count=1),
"approved_some_of_type(activity,1) should be true")
self.assertTrue(approved_all_of_type(self.user, action_type='activity'),
"approved_some_of_type(activity) should be true")
self.assertFalse(approved_some_of_type(self.user, action_type='event', count=1),
"approved_some_of_type(event,1) should be false")
self.assertFalse(approved_all_of_type(self.user, action_type='event'),
"approved_some_of_type(event) should be false")