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


Python EmailForm.save方法代码示例

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


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

示例1: test_email

# 需要导入模块: from forms import EmailForm [as 别名]
# 或者: from forms.EmailForm import save [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

示例2: patch

# 需要导入模块: from forms import EmailForm [as 别名]
# 或者: from forms.EmailForm import save [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

示例3: editprofile

# 需要导入模块: from forms import EmailForm [as 别名]
# 或者: from forms.EmailForm import save [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: edit_details

# 需要导入模块: from forms import EmailForm [as 别名]
# 或者: from forms.EmailForm import save [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

示例5: register

# 需要导入模块: from forms import EmailForm [as 别名]
# 或者: from forms.EmailForm import save [as 别名]
def register(request):
    # A HTTP POST?
    if request.method == 'POST':
        form = EmailForm(request.POST)

        # Have we been provided with a valid form?
        if form.is_valid():
            # Save the new category to the database.
            form.save(commit=True)

            # Now call the index() view.
            # The user will be shown the homepage.
            return HttpResponseRedirect('/fb/login/')
        else:
            # The supplied form contained errors - just print them to the terminal.
            print form.errors
    else:
        # If the request was not a POST, display the form to enter details.
        form = EmailForm()

    # Bad form (or form details), no form supplied...
    # Render the form with error messages (if any).
    return render(request, 'fb/register.html', {'form': form})
开发者ID:shekhar-singh,项目名称:learning,代码行数:25,代码来源:views.py

示例6: new_automation

# 需要导入模块: from forms import EmailForm [as 别名]
# 或者: from forms.EmailForm import save [as 别名]
def new_automation(request, alert_type):
    alert_type = get_object_or_404(AlertType, slug=alert_type, unit__in=request.units)

    if request.method == 'POST':
        form = EmailForm(request.POST)
        if form.is_valid():
            if AlertEmailTemplate.objects.filter(alerttype=alert_type, hidden=False, threshold=form.cleaned_data['threshold']).count() > 0:
                errors = form._errors.setdefault("threshold", ErrorList())
                errors.append(u'An e-mail with this threshold already exists.' )
            else:
                f = form.save(commit=False)
                f.alerttype = alert_type
                f.created_by = request.user.username            
                f.save()
                messages.success(request, "Created new automated email for %s." % alert_type.code)
                l = LogEntry(userid=request.user.username,
                      description="Created new automated email %s." % alert_type.code,
                      related_object=form.instance)
                l.save()            
                return HttpResponseRedirect(reverse('alerts.views.view_automation', kwargs={'alert_type':alert_type.slug}))
    else:
        form = EmailForm()

    sample_alert = Alert.objects.filter(alerttype=alert_type, hidden=False)[0]

    email_tags = [
        ("person.name","The name of the student that has triggered the alert"),
        ("person.first_name", "The first name of the student."),
        ("person.last_name", "The last name of the student."),
        ("person.middle_name", "The middle name of the student."),
        ("person.emplid", "The student's emplid."),
        ("person.email", "The student's email."),
        ("person.title", "The student's title."),
        ("description","The description of the alert.")
    ]
    
    for k, v in sample_alert.details.iteritems():
        email_tags.append( ("details."+k, "For example, (" + str(v) + ")") )
    
    return render(request, 'alerts/new_automation.html', { 'alert_type':alert_type, 'form': form, 'email_tags':email_tags })
开发者ID:avacariu,项目名称:coursys,代码行数:42,代码来源:views.py


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