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


Python Contact.group方法代码示例

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


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

示例1: create

# 需要导入模块: from models import Contact [as 别名]
# 或者: from models.Contact import group [as 别名]
def create():
    form = ContactForm()
    if form.validate_on_submit():
        new_contact = Contact()
        new_name = Name()
        new_contact.email = form.email.data
        new_name.first_name = form.first_name.data
        new_name.last_name = form.last_name.data
        new_contact.name = new_name
        new_contact.group = form.group.data
        new_contact.known_from = form.known_from.data
        new_contact.general_comment = form.general_note.data
        new_contact.current_status = form.status.data
        for language in form.languages.data:
            if language:
                new_contact.tags.append(language)
        other_tags = form.other_tags.data.replace(', ', ',').split(',')
        for tag in other_tags:
            new_contact.tags.append(tag)
        try:
            new_contact.save()
            flash_string = '<a href=\"/{}\">{} {}</a> was added to the database.'
            flash_string = flash_string.format(new_contact.email, new_contact.name.first_name,
                                               new_contact.name.last_name)
            flash(Markup(flash_string))
            update_p_dict()
            return redirect(url_for('index'))
        except NotUniqueError:
            msg = "That email address is already in use.  <a href=\"/" + form.email.data + "\">View Entry.</a>"
            form.email.errors.append(Markup(msg))
        except Exception as e:
            flash("There were database-raised errors in the form.  Specifically, " + e.message)

    return render_template('create_contact.html', form=form)
开发者ID:deecewan,项目名称:based,代码行数:36,代码来源:views.py

示例2: create

# 需要导入模块: from models import Contact [as 别名]
# 或者: from models.Contact import group [as 别名]
def create():
    form = ContactForm()
    if form.validate_on_submit():
        new_contact = Contact()
        new_name = Name()
        new_contact.email = form.email.data
        new_name.first_name = form.first_name.data
        new_name.last_name = form.last_name.data
        new_contact.name = new_name
        new_contact.group = form.group.data
        for language in form.languages.data:
            if language:
                new_contact.tags.append(language)
        other_tags = form.other_tags.data.replace(", ", ",").split(",")
        for tag in other_tags:
            new_contact.tags.append(tag)
        try:
            new_contact.save()
            print new_contact.name.first_name, new_contact.name.last_name
            flash_string = '<a href="/{}">{} {}</a> was added to the database.'
            print flash_string
            flash_string = flash_string.format(
                new_contact.email, new_contact.name.first_name, new_contact.name.last_name
            )
            flash(Markup(flash_string))
            return redirect(url_for("index"))
        except Exception as e:
            print "Errors in the form"
            flash("There were errors in the form.  Specifically, " + e.message)

    return render_template("create_contact.html", form=form)
开发者ID:skatingskull,项目名称:based,代码行数:33,代码来源:views.py


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