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


Python ActionMember.image方法代码示例

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


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

示例1: add

# 需要导入模块: from apps.widgets.smartgrid.models import ActionMember [as 别名]
# 或者: from apps.widgets.smartgrid.models.ActionMember import image [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


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