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


Python EmailForm.is_valid方法代码示例

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


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

示例1: edit_details

# 需要导入模块: from forms import EmailForm [as 别名]
# 或者: from forms.EmailForm import is_valid [as 别名]
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', {})
开发者ID:katya1995,项目名称:ArtVillage,代码行数:28,代码来源:views.py

示例2: forgot_password

# 需要导入模块: from forms import EmailForm [as 别名]
# 或者: from forms.EmailForm import is_valid [as 别名]
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)
开发者ID:alexanderzor,项目名称:clw,代码行数:30,代码来源:views.py

示例3: editprofile

# 需要导入模块: from forms import EmailForm [as 别名]
# 或者: from forms.EmailForm import is_valid [as 别名]
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',{})
开发者ID:georgikoyrushki95,项目名称:ehealth_backup-backup_fhs-,代码行数:30,代码来源:views.py

示例4: test_email

# 需要导入模块: from forms import EmailForm [as 别名]
# 或者: from forms.EmailForm import is_valid [as 别名]
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})
开发者ID:Mondego,项目名称:pyreco,代码行数:10,代码来源:allPythonContent.py

示例5: add_email_activation

# 需要导入模块: from forms import EmailForm [as 别名]
# 或者: from forms.EmailForm import is_valid [as 别名]
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}
开发者ID:vitaliyharchenko,项目名称:sportcourts,代码行数:10,代码来源:views.py

示例6: email

# 需要导入模块: from forms import EmailForm [as 别名]
# 或者: from forms.EmailForm import is_valid [as 别名]
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
开发者ID:stelfrich,项目名称:openmicroscopy,代码行数:58,代码来源:views.py

示例7: patch

# 需要导入模块: from forms import EmailForm [as 别名]
# 或者: from forms.EmailForm import is_valid [as 别名]
    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)
开发者ID:eashmore,项目名称:drchrono-birthdays,代码行数:12,代码来源:views.py

示例8: send_email

# 需要导入模块: from forms import EmailForm [as 别名]
# 或者: from forms.EmailForm import is_valid [as 别名]
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)
开发者ID:petevg,项目名称:bostonmycologicalclub,代码行数:57,代码来源:views.py

示例9: email

# 需要导入模块: from forms import EmailForm [as 别名]
# 或者: from forms.EmailForm import is_valid [as 别名]
def email(request):
    # 管理者グループの指定(ネルフ)
    admin_group = Group.objects.get(name='nerv')
    admin_list = admin_group.user_set.filter(is_active=True).exclude(profile__nickname=None)
    if request.method == 'POST':
        form = EmailForm(request.POST)
        try:
            form.is_valid()
            site = Site.objects.get_current()
            ctx_dict = {
                'site': site,
                'sender': form.cleaned_data['sender'],
                'subject': form.cleaned_data['subject'],
                'body': form.cleaned_data['body']
            }
            subject = render_to_string('contact/email_subject.txt', ctx_dict)
            subject = ''.join(subject.splitlines())
            body = render_to_string('contact/email.txt', ctx_dict)
            recivers = admin_list.exclude(email='')
            for reciver in recivers:
                reciver.email_user(subject, body, from_email=form.cleaned_data['sender'])
            message = u"メールを送信しました"
            messages.success(request, message, fail_silently=True)
        except ValidationError as e:
            message = u"日本語が含まれていない文章は送信できません"
            messages.error(request, message)
        except:
            message = u"エラーが発生しました"
            messages.error(request, message)

    else:
        form = EmailForm()
    kwargs = {
        'template': r'contact/email_form.html',
        'extra_context': {
            'form': form,
            'admin_group': admin_group,
            'admin_list': admin_list,
        },
    }
    return simple.direct_to_template(request, **kwargs)
开发者ID:kawazrepos,项目名称:Kawaz2nd,代码行数:43,代码来源:views.py

示例10: email

# 需要导入模块: from forms import EmailForm [as 别名]
# 或者: from forms.EmailForm import is_valid [as 别名]
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))
开发者ID:adamfeuer,项目名称:ArtOfGratitude_app,代码行数:14,代码来源:views.py

示例11: commit

# 需要导入模块: from forms import EmailForm [as 别名]
# 或者: from forms.EmailForm import is_valid [as 别名]
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))
开发者ID:NSkelsey,项目名称:whatdoIdo,代码行数:14,代码来源:views.py

示例12: connect

# 需要导入模块: from forms import EmailForm [as 别名]
# 或者: from forms.EmailForm import is_valid [as 别名]
def connect(request):
    if request.method == 'POST':
        email_form = EmailForm(request.POST)
        search_form = UserSearchForm(request.POST)
        email_form.is_valid()
        search_form.is_valid()
        address = email_form.cleaned_data['email']
        searched_user = search_form.cleaned_data['lastName']
        if address:
            data = getoutput('echo "{}" >> emails && echo "Complete!"'.format(address)).split('\n')
            return render(request, 'connect.html', {'email_form':email_form, 'email':True , 'data':data, 'search_form':search_form})
            pass
        elif searched_user:
            regUsers = User.objects.raw('SELECT * from auth_user where last_name like "%%{}%%";'.format(searched_user))
            return render(request, 'connect.html', {'email_form':email_form, 'regUsers':regUsers, 'search_form':search_form})
        else:
            return render(request, 'connect.html', {'email_form':email_form, 'search_form':search_form})
    else:
        email_form = EmailForm()
        search_form = UserSearchForm()
    return render(request, 'connect.html', {'email_form':email_form, 'search_form':search_form})
开发者ID:JohnHammond,项目名称:cdx_2016,代码行数:23,代码来源:views.py

示例13: email

# 需要导入模块: from forms import EmailForm [as 别名]
# 或者: from forms.EmailForm import is_valid [as 别名]
def email(request):
	if request.method == "POST":
		form = EmailForm(request.POST)
		if form.is_valid():
			send_a_letter.delay(form.cleaned_data["sender"],form.cleaned_data["recipient"],
				form.cleaned_data["subject"],form.cleaned_data["message"])
			return HttpResponse("all sent. thanks.")
	else:
		form = EmailForm()
	
	return render(request, 'examples/email.html', {
		'form' : form
	})
开发者ID:Mondego,项目名称:pyreco,代码行数:15,代码来源:allPythonContent.py

示例14: frontend_change

# 需要导入模块: from forms import EmailForm [as 别名]
# 或者: from forms.EmailForm import is_valid [as 别名]
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))
开发者ID:becomingGuru,项目名称:baba,代码行数:15,代码来源:views.py

示例15: send_email

# 需要导入模块: from forms import EmailForm [as 别名]
# 或者: from forms.EmailForm import is_valid [as 别名]
def send_email(request):
    """ Send a new email. """
    email_form = EmailForm(user=request.user)

    if request.method == "POST":
        email_form = EmailForm(request.POST,user=request.user)
        if email_form.is_valid():
            print email_form.cleaned_data['required_fields']
            from_account = email_form.cleaned_data['from_account']

            send_templated_email(request.user, email_form.contacts, from_account, email_form.cleaned_data['subject'], email_form.cleaned_data['html'], email_form.cleaned_data['text'])
            messages.success(request, "%s sent" % email_form.cleaned_data['subject'])
            # return redirect("index")
    return render(request, "emails/send.html", {"form": email_form})
开发者ID:jscott1989,项目名称:holloway,代码行数:16,代码来源:views.py


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