本文整理匯總了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)