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


Python User.objects方法代码示例

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


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

示例1: school

# 需要导入模块: from user.models import User [as 别名]
# 或者: from user.models.User import objects [as 别名]
def school():
    if request.method == 'GET':
        # fields to be hidden come here
        field_args = {'user': {'widget': wtforms.widgets.HiddenInput()}}
        return cruder(request, School, 'school.html', 'school', 'School', field_args)

    else:
        obj_form = model_form(School)
        form = obj_form(request.form)
        sid = form.save().id
        User.objects(id=g.user.get_id()).update_one(set__school=request.form['school_name'])
        User.objects(id=g.user.get_id()).update_one(set__schoolid=str(sid))
        g.user.reload()
        if request.args['s'] == 't':
            return render_template('complete.html')
        return redirect(url_for('.school', m='r', id=str(sid)))
开发者ID:nikitph,项目名称:Ashrm,代码行数:18,代码来源:views.py

示例2: profile

# 需要导入模块: from user.models import User [as 别名]
# 或者: from user.models.User import objects [as 别名]
def profile():
    if request.method == 'GET':
        return render_template('profile.html')

    else:
        User.objects(id=g.user.get_id()).update_one(set__phone=request.form['phone'])
        User.objects(id=g.user.get_id()).update_one(set__address=request.form['address'])
        User.objects(id=g.user.get_id()).update_one(set__image=request.form['image'])
    return redirect(url_for('.student', m='l'))
开发者ID:nikitph,项目名称:Ashrm,代码行数:11,代码来源:views.py

示例3: bulknotify

# 需要导入模块: from user.models import User [as 别名]
# 或者: from user.models.User import objects [as 别名]
def bulknotify():
    if request.method == 'GET':
        field_args = {'school': {'widget': wtforms.widgets.HiddenInput()}}
        list_args = {'school': {'widget': wtforms.widgets.HiddenInput()}}
        return cruder(request, BulkNotification, 'bulknotify.html', 'bulknotify', 'Bulk Notification', field_args,
                      list_args, g.user.schoolid)

    else:
        obj_form = model_form(BulkNotification)
        form = obj_form(request.form)
        id = str(form.save().id)
        x = Student.objects.only('email')
        rcp = []
        response = {"subject": form['subject'].data, "id": id}
        # socketio.emit('notification', response, namespace='/test')
        notif = Notification(subject=form['subject'].data, url=id, read=False)
        User.objects(id=g.user.get_id()).update_one(add_to_set__notif=notif)
        g.user.reload()

        for s in x:
            rcp.append(str(s.email))

        task = email.apply_async(args=[form['subject'].data, form['body'].data, rcp])
        return redirect(url_for('.bulknotify', m='r', id=id))
开发者ID:nikitph,项目名称:Ashrm,代码行数:26,代码来源:views.py

示例4: run

# 需要导入模块: from user.models import User [as 别名]
# 或者: from user.models.User import objects [as 别名]
 def run(self, **kwargs):
     try:
         pwd = encrypt_password(kwargs['password'])
         User.objects(email=kwargs['email']).first().update(set__password=pwd)
     except Exception, e:
         print ('Error resetting user password: %s' % e)
开发者ID:loctv,项目名称:flask-server-starter,代码行数:8,代码来源:script.py


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