本文整理汇总了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)