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


Python ActionMember.social_email方法代码示例

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


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

示例1: complete

# 需要导入模块: from apps.widgets.smartgrid.models import ActionMember [as 别名]
# 或者: from apps.widgets.smartgrid.models.ActionMember import social_email [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,)))
开发者ID:KendyllD,项目名称:boukenda-project,代码行数:55,代码来源:view_events.py

示例2: testSocialBonusAchievement

# 需要导入模块: from apps.widgets.smartgrid.models import ActionMember [as 别名]
# 或者: from apps.widgets.smartgrid.models.ActionMember import social_email [as 别名]
    def testSocialBonusAchievement(self):
        """Check that the social bonus appears in the my achievements list."""
        # Create a second test user.
        user2 = User.objects.create_user("user2", "[email protected]")
        event = Event.objects.create(
            title="Test event",
            slug="test-event",
            description="Testing!",
            duration=10,
            point_value=10,
            social_bonus=10,
            pub_date=datetime.datetime.today(),
            expire_date=datetime.datetime.today() + datetime.timedelta(days=7),
            type="event",
            event_date=datetime.datetime.today(),
        )

        # Create membership for the two users.
        m = ActionMember(
            user=self.user,
            action=event,
            approval_status="approved",
        )
        m.social_email = "[email protected]"
        m.save()

        m2 = ActionMember(
            user=user2,
            action=event,
            approval_status="approved",
        )
        m2.social_email = "[email protected]"
        m2.save()

        response = self.client.get(reverse("profile_index"))
        self.assertContains(response, reverse("activity_task", args=(event.type, event.slug,)))
        entry = "Event: Test event (Social Bonus)"
        self.assertContains(response, entry, count=1,
            msg_prefix="Achievements should contain a social bonus entry")
开发者ID:gregorylburgess,项目名称:makahiki,代码行数:41,代码来源:tests.py

示例3: add

# 需要导入模块: from apps.widgets.smartgrid.models import ActionMember [as 别名]
# 或者: from apps.widgets.smartgrid.models.ActionMember import social_email [as 别名]
def add(request, activity):
    """Creates a request for points for an activity."""

    user = request.user

    if request.method == "POST":
        form = _get_form(request, activity)

        if form.is_valid():
            try:
                action_member = ActionMember.objects.get(user=user, action=activity)
            except ObjectDoesNotExist:
                action_member = ActionMember(user=user, action=activity,
                                             submission_date=datetime.datetime.today())

            # Attach image if it is an image form.
            if "image_response" in form.cleaned_data:
                if activity.confirm_type == "free_image":
                    action_member.response = form.cleaned_data["response"]

                path = activity_image_file_path(user=user,
                    filename=request.FILES['image_response'].name)
                action_member.image = path

                action_member.image.storage.save(path, request.FILES["image_response"])

                action_member.approval_status = "pending"
            # Attach text prompt question if one is provided
            elif "question" in form.cleaned_data:
                action_member.question = LibraryTextPromptQuestion.objects.get(
                    pk=form.cleaned_data["question"])
                action_member.response = form.cleaned_data["response"]
                action_member.approval_status = "pending"

            elif activity.confirm_type == "free":
                action_member.response = form.cleaned_data["response"]
                action_member.approval_status = "pending"

            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=(activity.type, activity.slug,)))

            response = HttpResponseRedirect(
                reverse("activity_task", args=(activity.type, activity.slug,)))

            return response

        # invalid form
        # rebuild the form
        form.form_title = "Get your points"
        if activity.confirm_type == "text":
            qid = form.data["question"]
            question = LibraryTextPromptQuestion.objects.get(pk=qid)
            form.action_question = question
        return render_to_response("task.html", {
            "action": activity,
            "form": form,
            "completed_count": 0,
            "team_members": None,
            "display_form": True,
            "reminders": None,
            }, context_instance=RequestContext(request))

    return HttpResponseRedirect(reverse("activity_task", args=(activity.type, activity.slug,)))
开发者ID:MakahikiKTUH,项目名称:makahiki-ktuh-devray,代码行数:70,代码来源:view_activities.py

示例4: attend_code

# 需要导入模块: from apps.widgets.smartgrid.models import ActionMember [as 别名]
# 或者: from apps.widgets.smartgrid.models.ActionMember import social_email [as 别名]
def attend_code(request):
    """Claim the attendance code or the Bonus Points code"""

    user = request.user
    action_member = None
    message = None
    social_email = None

    if request.is_ajax() and request.method == "POST":
        form = EventCodeForm(request.POST)
        if form.is_valid():
            message, social_email, code, is_bonus = _check_attend_code(user, form)

            if message:
                return HttpResponse(json.dumps({
                    "message": message,
                    "social_email": social_email
                }), mimetype="application/json")

            if not is_bonus:  # It was an event code.
                try:
                    action_member = ActionMember.objects.get(user=user, action=code.action)
                except ObjectDoesNotExist:
                    action_member = ActionMember(user=user, action=code.action)

                action_member.approval_status = "approved"
                value = code.action.point_value

                if "social_email" in form.cleaned_data and \
                    form.cleaned_data["social_email"] != "Email":
                    action_member.social_email = form.cleaned_data["social_email"].lower()

                # Model save method will award the points.
                action_member.save()
            else:  # It was a bonus point code.
                profile = user.get_profile()
                value = code.point_value
                s = "Bonus Points: claimed {0} points".format(value)
                profile.add_points(value,
                                   datetime.datetime.today(),
                                   s)
                code.claim_date = datetime.datetime.now()

            code.is_active = False
            code.user = user
            code.save()

            notification = "You just earned " + str(value) + " points."
            if not is_bonus:
                response = HttpResponse(json.dumps({
                            "redirectUrl": reverse("activity_task",
                                                   args=(code.action.type, code.action.slug))
                            }), mimetype="application/json")
                response.set_cookie("task_notify", notification)
            else:
                response = HttpResponse(json.dumps({
                            "redirectUrl": reverse("learn_index")}),
                                        mimetype="application/json")
                response.set_cookie("bonus_notify", notification)
                UserNotification.create_info_notification(user, s)
            return response

        # At this point there is a form validation error.
        return HttpResponse(json.dumps({
            "message": "Please input code."
        }), mimetype="application/json")

    raise Http404
开发者ID:KendyllD,项目名称:boukenda-project,代码行数:70,代码来源:view_events.py

示例5: add

# 需要导入模块: from apps.widgets.smartgrid.models import ActionMember [as 别名]
# 或者: from apps.widgets.smartgrid.models.ActionMember import social_email [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, user=request.user.username)
    if not form.is_valid():
        # invalid form
        request.session["form_dict"] = form.data
        request.session["form_errors"] = form.errors

        return HttpResponseRedirect(
            reverse("activity_task",
                    args=(commitment.type, commitment.slug,)) + "?display_form=True")

    # 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"].lower()
        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"].lower()

        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
开发者ID:csdl,项目名称:makahiki,代码行数:66,代码来源:view_commitments.py


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