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


Python Department.get_by_id方法代码示例

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


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

示例1: edit_extractor

# 需要导入模块: from comport.department.models import Department [as 别名]
# 或者: from comport.department.models.Department import get_by_id [as 别名]
def edit_extractor(extractor_id):
    extractor = Extractor.get_by_id(extractor_id)
    if not extractor:
        abort(404)

    form = EditExtractorForm(request.form, departments=[d.id for d in extractor.departments])
    form.departments.choices = [(d.id, d.name) for d in Department.query.order_by('name')]

    if request.method == 'POST':
        extractor.departments = [Department.get_by_id(int(d)) for d in form.departments.data]
        extractor.save()
        flash('Extractor updated.', 'info')
        return redirect(url_for('admin.admin_dashboard'))

    return render_template("admin/editExtractor.html", form=form, extractor=extractor)
开发者ID:carolynjoneslee,项目名称:comport,代码行数:17,代码来源:views.py

示例2: edit_user

# 需要导入模块: from comport.department.models import Department [as 别名]
# 或者: from comport.department.models.Department import get_by_id [as 别名]
def edit_user(user_id):
    user = User.get_by_id(user_id)
    if not user:
        abort(404)

    form = EditUserForm(request.form, departments=[d.id for d in user.departments])
    form.departments.choices = [(d.id, d.name) for d in Department.query.order_by('name')]

    if request.method == 'POST':
        user.departments = [Department.get_by_id(int(d)) for d in form.departments.data]
        user.save()
        flash('User updated.', 'info')
        return redirect(url_for('admin.admin_dashboard'))

    return render_template("admin/editUser.html", form=form, user=user)
开发者ID:carolynjoneslee,项目名称:comport,代码行数:17,代码来源:views.py

示例3: register

# 需要导入模块: from comport.department.models import Department [as 别名]
# 或者: from comport.department.models.Department import get_by_id [as 别名]
def register():
    form = RegisterForm(request.form, csrf_enabled=False)
    if form.validate_on_submit():
        invite_code = Invite_Code.query.filter_by(code=form.invite_code.data).first()
        invite_code.used = True
        invite_code.save()

        new_user = User.create(
            username=form.username.data,
            email=form.email.data,
            password=form.password.data,
            active=True
        )

        new_user.departments.append(Department.get_by_id(invite_code.department_id))

        flash("Thank you for registering. You can now log in.", 'success')
        return redirect(url_for('public.home'))
    else:
        flash_errors(form)
    return render_template('public/register.html', form=form)
开发者ID:codeforamerica,项目名称:comport,代码行数:23,代码来源:views.py


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