本文整理汇总了Python中forms.EmailForm类的典型用法代码示例。如果您正苦于以下问题:Python EmailForm类的具体用法?Python EmailForm怎么用?Python EmailForm使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了EmailForm类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: reset_email
def reset_email():
if request.method == "POST":
form = EmailForm(request.form)
if form.validate():
ul = serv.login(g.user['email'],form.password.data)
if ul:
#TODO:发送确认邮件
try:
uri = serv.send_lock_request("user.confirm_email", ul.id)
up = g.db.query(UserProfile).filter(UserProfile.user_id==ul.id).one()
up.email = form.email.data
g.db.flush()
g.db.commit()
success = u"确认邮箱的邮件已经发出,请登录邮箱点击确认链接,然后才能使用新邮箱登陆"
msg = Message(u"登陆邮箱变更确认邮件", sender="[email protected]", recipients=["[email protected]"])
msg.html = "点击下面链接确认登陆邮件变更,点击后用新邮箱登陆爱普云平台<br/><a href=\"http://%s%s\">%s</a>"%(settings.SERVER, uri, uri)
g.mail.send(msg)
except Exception, e:
g.db.rollback()
log.error(print_debug(e))
errors = [u"未知异常"]
else:
errors = [u"登陆密码输入不正确"]
else:
errors = [v[0] for k, v in form.errors.iteritems()]
示例2: edit_details
def edit_details(request):
user = User.objects.get(username=request.user)
if request.method == "POST":
email = request.POST['email']
try:
existent_email = User.objects.get(email=email)
except:
existent_email = None
if existent_email:
return render(request, 'ArtVillage/edit_details.html', {"existent": True})
form = EmailForm(data=request.POST, instance=request.user)
try:
up = UserProfile.objects.get(user=request.user)
except:
up = None
if form.is_valid():
if email:
user = form.save(commit=False)
user.save()
return HttpResponseRedirect('/profile/' + user.username)
else:
return render(request, 'ArtVillage/edit_details.html', {})
else:
return render(request, 'ArtVillage/edit_details.html', {})
示例3: forgot_password
def forgot_password(request):
if request.method == 'POST':
form = EmailForm(request.POST)
login_form = LoginForm(request.POST)
if form.is_valid():
email = form.cleaned_data['email']
user = get_object_or_404(CustomUser, email=email)
salt = hashlib.sha1(str(random.random())).hexdigest()[:5]
user.activation_key = hashlib.sha1(salt+user.email).hexdigest()
#user.key_expires = timezone.now() + timezone.timedelta(100)
user.save()
plaintext = get_template('email/password_reset.txt')
htmly = get_template('email/password_reset.html')
d = Context({'user': user, 'site_url': site_url})
subject, from_email, to = 'Восстановление пароля', '[email protected]', user.email
text_content = plaintext.render(d)
html_content = htmly.render(d)
msg = EmailMultiAlternatives(subject, text_content, from_email, [to])
msg.attach_alternative(html_content, "text/html")
msg.send()
return HttpResponseRedirect(reverse('success_reset'))
else:
form = EmailForm()
login_form = LoginForm()
context = {'form': form, 'login_form': login_form}
return render(request, "forgot_password.html", context)
示例4: editprofile
def editprofile(request):
user = User.objects.get(username=request.user)
if request.method == "POST":
email = request.POST['email']
try:
existent_email = User.objects.get(email=email)
except:
existent_email = None
if existent_email:
return render(request, 'fhs/editprofile.html',{"existent": True})
form = EmailForm(data=request.POST, instance=request.user)
picform = UserProfileForm(data=request.POST, instance=request.user)
try:
up = UserProfile.objects.get(user=request.user)
except:
up = None
if form.is_valid() and picform.is_valid():
if email:
user = form.save(commit=False)
user.save()
if 'picture' in request.FILES:
up.picture = request.FILES['picture']
up.save()
return HttpResponseRedirect('/fhs/profile/'+user.username)
else:
return render(request, 'fhs/editprofile.html',{})
示例5: test_email
def test_email(request):
if request.method == 'GET':
form = EmailForm()
else:
form = EmailForm(data=request.POST)
if form.is_valid():
form.save()
return render_to_response('mail.html', {'form': form})
示例6: re_verify
def re_verify():
form = EmailForm(request.form)
if form.validate_on_submit():
send_verification_email(form.get_user())
flash('Check your email for verification!')
return redirect(url_for('home'))
return render_template('no_email_verification.html', form=form)
示例7: add_email_activation
def add_email_activation(request):
form = EmailForm(request.POST)
if not form.is_valid():
raise _Error.invalid_email(request.POST['email'])
email = form.cleaned_data['email']
token = create_token(email)
mailing.verify_email(email, token)
return {'email': email}
示例8: email
def email(request, conn=None, **kwargs):
"""
View to gather recipients, subject and message for sending email
announcements
"""
# Check that the appropriate web settings are available
if (not request.session.get('server_settings', False)
.get('email', False)):
return {'template': 'webadmin/noemail.html'}
context = {'template': 'webadmin/email.html'}
# Get experimenters and groups.
experimenter_list = list(conn.getObjects("Experimenter"))
group_list = list(conn.getObjects("ExperimenterGroup"))
# Sort experimenters and groups
experimenter_list.sort(key=lambda x: x.getFirstName().lower())
group_list.sort(key=lambda x: x.getName().lower())
if request.method == 'POST': # If the form has been submitted...
# ContactForm was defined in the the previous section
form = EmailForm(experimenter_list, group_list, conn, request,
data=request.POST.copy())
if form.is_valid(): # All validation rules pass
subject = form.cleaned_data['subject']
message = form.cleaned_data['message']
experimenters = form.cleaned_data['experimenters']
groups = form.cleaned_data['groups']
everyone = form.cleaned_data['everyone']
inactive = form.cleaned_data['inactive']
req = omero.cmd.SendEmailRequest(subject=subject, body=message,
groupIds=groups,
userIds=experimenters,
everyone=everyone,
inactive=inactive)
handle = conn.c.sf.submit(req)
if handle is not None:
request.session.modified = True
request.session['callback'][str(handle)] = {
'job_type': 'send_email',
'status': 'in progress', 'error': 0,
'start_time': datetime.datetime.now()}
form = EmailForm(experimenter_list, group_list, conn, request)
context['non_field_errors'] = ("Email sent."
"Check status in activities.")
else:
context['non_field_errors'] = "Email wasn't sent."
else:
form = EmailForm(experimenter_list, group_list, conn, request)
context['form'] = form
return context
示例9: patch
def patch(self, request, **kwargs):
doctor = get_object_or_404(User, pk=kwargs['pk']).doctor
data = QueryDict(request.body)
form = EmailForm(data, instance=doctor)
if form.is_valid():
form.save()
doctorJSON = serializers.serialize("json", [doctor])
return HttpResponse(doctorJSON, content_type='application/json')
return HttpResponse(status=500)
示例10: send_email
def send_email(request, sent=None):
""" Send an email to all club members. """
form = EmailForm()
template='send_email.html'
users = []
send_errors = []
if request.method == 'POST':
form = EmailForm(request.POST)
if form.is_valid():
form = form.cleaned_data
subject = form['subject']
message = form['message']
try:
users = User.objects.filter(
is_active=True,
userprofile__want_email=True,
)
except ObjectDoesNotExist:
error = "Can't pull up the user list!"
return error_404(request, error)
for user in users:
try:
user_email = user.email
send_mail(subject,
message,
SERVER_EMAIL,
[user_email],
fail_silently=False,
)
except SMTPException:
# Need to grab Exception and pass it to template
error = "There was an error sending mail!"
return error_404(request, error)
except:
error = "There was an error sending mail!"
return error_404(request, error)
return HttpResponseRedirect(reverse(sent_email))
else:
form = EmailForm(request.POST)
ctxt = {
'request' : request,
'form' : form,
'users' : users,
'page_name' : 'Email All Members',
'media_url' : MEDIA_URL,
}
return render_to_response(template, ctxt)
示例11: save_email
def save_email():
form = EmailForm(request.form)
if form.validate():
db = get_db()
db.execute('''INSERT INTO emails (email, registered)
VALUES (?, ?)''', (request.form.get('email'), datetime.utcnow().isoformat()))
db.commit()
return render_template('email.html', email=Markup.escape(form.email.data))
else:
return redirect("/")
示例12: email
def email(request):
if request.method == 'POST':
form = EmailForm(request.POST, error_class=AlertErrorList)
if form.is_valid():
result = EmailSender().send(form.cleaned_data["email"], form.cleaned_data['message'])
return HttpResponseRedirect('/')
else:
form = EmailForm(error_class=AlertErrorList)
return render_to_response('email/email.html',
{'form': form },
context_instance=RequestContext(request))
示例13: commit
def commit(request):
if request.method == "POST":
ef = EmailForm(request.POST)
if ef.is_valid():
s = Signup(email=ef.cleaned_data["email"])
s.save()
cats = ["volunteer", "outdoors", "food", "drink", "entertain", "winter", "rents"]
resp_dict = models.get_acts_from_cats(cats)
return render_to_response("home.html", resp_dict, RequestContext(request))
else:
ef = EmailForm()
return render_to_response("commit.html", {"form": ef}, RequestContext(request))
示例14: sign_in
def sign_in():
form = EmailForm()
if form.validate_on_submit():
email = form.email.data
try:
user = User.get(email=email)
except User.DoesNotExist:
#print ('errorrrrrrr!')
return render_template('sign_in.html', form=form, login_error=True, reg_url=url_for('reg'))
else:
log_user(user)
return redirect(url_for('index'))
return render_template('sign_in.html', form=form, login_error=False, reg_url=url_for('reg'))
示例15: frontend_change
def frontend_change(request):
uform = EmailForm(request.POST or None)
if uform.is_valid():
# form.save()
messages.info(request, 'An email has been sent, Please check')
return redirect('.')
return render_to_response('notification.html',
locals(),
RequestContext(request))