本文整理汇总了Python中apps.widgets.smartgrid.models.ActionMember.social_email2方法的典型用法代码示例。如果您正苦于以下问题:Python ActionMember.social_email2方法的具体用法?Python ActionMember.social_email2怎么用?Python ActionMember.social_email2使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类apps.widgets.smartgrid.models.ActionMember
的用法示例。
在下文中一共展示了ActionMember.social_email2方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: add
# 需要导入模块: from apps.widgets.smartgrid.models import ActionMember [as 别名]
# 或者: from apps.widgets.smartgrid.models.ActionMember import social_email2 [as 别名]
def add(request, commitment):
"""Commit the current user to the commitment."""
user = request.user
value = None
if request.method == "GET": # redirect to task page, only allow POST
return HttpResponseRedirect(
reverse("activity_task", args=(commitment.type, commitment.slug,)))
form = CommitmentCommentForm(request.POST, request=request, action=commitment)
if not form.is_valid():
return HttpResponseRedirect(
reverse("activity_task", args=(commitment.type, commitment.slug,)))
# now we have a valid form
if smartgrid.can_complete_commitment(user, commitment):
try:
member = user.actionmember_set.get(action=commitment, award_date=None)
except ObjectDoesNotExist:
# ignore the race condition
return HttpResponseRedirect(
reverse("activity_task", args=(commitment.type, commitment.slug,)))
#commitment end, award full point
member.award_date = datetime.datetime.today()
member.approval_status = "approved"
if form.cleaned_data["social_email"]:
member.social_email = form.cleaned_data["social_email"]
if form.cleaned_data["social_email2"]:
member.social_email2 = form.cleaned_data["social_email2"]
member.save()
value = commitment.point_value
elif smartgrid.can_add_commitment(user):
# User can commit to this commitment. allow to commit to completed commitment again
# as long as the pending does not reach max
member = ActionMember(user=user, action=commitment)
if form:
member.social_email = form.cleaned_data["social_email"]
member.social_email2 = form.cleaned_data["social_email2"]
try:
member.save()
value = score_mgr.signup_points()
except IntegrityError:
messages.error = 'Sorry, but it appears that you are already participating in ' \
'this commitment.'
return HttpResponseRedirect(
reverse("activity_task", args=(commitment.type, commitment.slug,)))
else: # user can not add more than 5 commitment
return HttpResponseRedirect(
reverse("activity_task", args=(commitment.type, commitment.slug,)))
response = HttpResponseRedirect(
reverse("activity_task", args=(commitment.type, commitment.slug,)))
notification = "You just earned " + str(value) + " points."
response.set_cookie("task_notify", notification)
return response