當前位置: 首頁>>代碼示例>>Python>>正文


Python models.Account方法代碼示例

本文整理匯總了Python中account.models.Account方法的典型用法代碼示例。如果您正苦於以下問題:Python models.Account方法的具體用法?Python models.Account怎麽用?Python models.Account使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在account.models的用法示例。


在下文中一共展示了models.Account方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: form_valid

# 需要導入模塊: from account import models [as 別名]
# 或者: from account.models import Account [as 別名]
def form_valid(self, form):
        if "ask" not in self.request.POST:
            return super(AskForHelpMixin, self).form_valid(form)

        receiver_profiles = []
        request, user = [self.request, self.request.user]
        question = Question.objects.get(id=form.question_id)
        username = user_display(user)

        for key, value in form.cleaned_data.items():
            if key in ["experts", "users"] and value:
                profile_ids = map(int, re.split("\D+", value))
                receiver_profiles.extend(Profile.objects.filter(
                    id__in=profile_ids).select_related("user"))
            elif key == "email" and value:
                m = EMAIL_PATTERN.match(request.POST["email"])
                if m:
                    receiver_profile = Profile(user=User(email=m.group()),
                                               name=m.group("username"))
                    receiver_profile.user.account = Account()
                    receiver_profile.user.get_absolute_url = void
                    receiver_profiles.append(receiver_profile)
                else:
                    kwargs = {"user": username, "email": request.POST["email"]}
                    add_message("email-error", request, **kwargs)

        for receiver_profile in receiver_profiles:
            receiver = receiver_profile.user

            receiver_name = user_display(receiver_profile)

            if receiver != user:
                mail_helper(request, receiver, user, question, receiver_name,
                            username)
                kwargs = {"user": username, "receiver": receiver_name}
                add_message("email-sent", request, **kwargs)
            else:
                add_message("ask-warning", request, user=username)

        return HttpResponseRedirect(request.path) 
開發者ID:blaze33,項目名稱:newco-legacy,代碼行數:42,代碼來源:views.py


注:本文中的account.models.Account方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。