• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python user.User类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: get

 def get(self,key):
     user      = User()
     userInfo = UserInfo()
     avatar =Avatar()
     user.delete(key)
     userInfo.delete(key)
     avatar.delete(key)
开发者ID:aviatorBeijing,项目名称:ptpy,代码行数:7,代码来源:user.py


示例2: group_member_setting

def group_member_setting(gid, memberid):
    appid = request.appid
    uid = request.uid

    if uid != memberid:
        raise ResponseMeta(400, "setting other is forbidden")

    obj = json.loads(request.data)
    if obj.has_key('quiet'):
        User.set_group_do_not_disturb(g.rds, appid, uid, gid, obj['quiet'])
    elif obj.has_key('do_not_disturb'):
        User.set_group_do_not_disturb(g.rds, appid, uid, gid, obj['do_not_disturb'])
    elif obj.has_key('nickname'):
        Group.update_nickname(g._db, gid, uid, obj['nickname'])
        v = {
            "group_id":gid,
            "timestamp":int(time.time()),
            "nickname":obj['nickname'],
            "member_id":uid
        }
        op = {"update_member_nickname":v}
        send_group_notification(appid, gid, op, None)        
    else:
        raise ResponseMeta(400, "no action")

    resp = {"success":True}
    return make_response(200, resp)
开发者ID:richmonkey,项目名称:gobelieve_api,代码行数:27,代码来源:client_group.py


示例3: unbind_device_token

def unbind_device_token():
    rds = g.rds
    appid = request.appid
    uid = request.uid
    obj = json.loads(request.data)

    device_token = obj.get("apns_device_token", "")
    pushkit_device_token = obj.get("pushkit_device_token", "")
    ng_device_token = obj.get("ng_device_token", "")
    xg_device_token = obj.get("xg_device_token", "")
    xm_device_token = obj.get("xm_device_token", "")
    hw_device_token = obj.get("hw_device_token", "")
    gcm_device_token = obj.get("gcm_device_token", "")
    jp_device_token = obj.get("jp_device_token", "")

    if not device_token and not pushkit_device_token \
       and not ng_device_token and not xg_device_token \
       and not xm_device_token and not hw_device_token \
       and not gcm_device_token and not jp_device_token:
        raise ResponseMeta(400, "invalid param")


    User.reset_user_device_token(rds, appid, uid,
                                 device_token, pushkit_device_token,
                                 ng_device_token, xg_device_token, 
                                 xm_device_token, hw_device_token,
                                 gcm_device_token, jp_device_token)

    return make_json_response({"success":True}, 200)
开发者ID:richmonkey,项目名称:gobelieve_api,代码行数:29,代码来源:push.py


示例4: createToken

    def createToken(self, args):
        self._start(args)
        # Do a check to see if any admins exist before proceeding.
        print('Create token: please authenticate...')
        
        while True:
            admin_username = raw_input('Enter admin username: ')
            admin_password = getpass.getpass('Enter admin password: ')
            if not User.users().get(username=admin_username).admin:
                print('Please sign in using administrator credentials.')
            elif not User.users().get(username=admin_username).authenticate(admin_password):
                print("Username/password don't match.")
            else:
                break

        username = raw_input('Enter username to create a token for: ')
        user = User.users().get(username=username)
        if user:
            try:
                token = Token(user=user)
                token.save()
                print(str('Token %s created for %s' % (token.token, username)))
            except Exception as e:
                print("EXCEPTION **** %s" % e)
                print('A token already exists for %s. Doing nothing.' % username)
        else:
            print('A user with username %s does not exist.' % username)
开发者ID:silverfernsys,项目名称:sremote,代码行数:27,代码来源:app.py


示例5: createUser

    def createUser(self, args):
        self._start(args)

        while True:
            username = raw_input('Enter email address: ')
            if User.users().get(username=username):
                print('Username already exists. Please pick another username.')
            else:
                break
            print('username: %s' % username)
        while True:
            is_admin = raw_input('Admininstrative user? (y/N): ')
            if (len(is_admin) == 0) or (is_admin.upper() == 'N'):
                admin = False
                break
            elif is_admin.upper() == 'Y':
                admin = True
                break
        while True:
            password_1 = getpass.getpass('Enter password: ')
            password_2 = getpass.getpass('Re-enter password: ')
            if password_1 != password_2:
                print('Passwords do not match.')
            else:
                break

        user = User(username, password_1, admin)
        user.save()
        # Db.instance().insert_user(username, password_1, admin)
        print('Successfully created user %s' % username)
开发者ID:silverfernsys,项目名称:sremote,代码行数:30,代码来源:app.py


示例6: register_user

def register_user():
	email = request.form['email']
	password = request.form['password']

	User.register(email, password)

	return render_template('profile.html', email=session['email'])
开发者ID:asimonia,项目名称:web-blog,代码行数:7,代码来源:app.py


示例7: get

 def get(self):
     uname = self.get_current_user()
     user = User.get_user_by_name(uname)
     order = get_order()
     story = Story.get_by_porder(order)
     sid = self.get_argument("sid",None)
     if sid is not None:
         story=Story.get_by_sid(sid)
     article = Article.get_all_Astory(200)
     usedStory = Story.get_all_story()
     temp = []
     for one in usedStory:
         if one.porder > 0 and one.porder <= order:
             temp.append(one)
     usedStory = temp
     reArticles = Article.get_all(200)
     Rarticle = sorted(reArticles,BaseHandler.rank)
     Ruser = User.get_all_user(100)
     if len(Rarticle) > 6:
         Rarticle=Rarticle[:6]
     if len(usedStory)>3:
         usedStory=usedStory[:3]
     if len(Ruser)>9:
         Ruser=Ruser[:9]
     self.render("story.html",user=user,Rarticle=Rarticle,Article=article,usedStory=usedStory,Ruser=Ruser,story=story)
开发者ID:oujiaqi,项目名称:suiyue,代码行数:25,代码来源:story.py


示例8: add_group_member

def add_group_member(gid):
    appid = request.appid
    obj = json.loads(request.data)
    inviter = None
    if type(obj) is dict:
        if 'members' in obj:
            members = obj['members']
            inviter = obj.get('inviter')
        else:
            members = [obj]
    else:
        members = obj

    if len(members) == 0:
        return ""
    
    group = Group.get_group(g._db, gid)
    if not group:
        raise ResponseMeta(400, "group non exists")
    
    # 支持members参数为对象数组
    memberIDs = map(lambda m:m['uid'] if type(m) == dict else m, members)
    
    g._db.begin()
    for member_id in memberIDs:
        try:
            Group.add_group_member(g._db, gid, member_id)
            # 可能是重新加入群
            User.reset_group_synckey(g.rds, appid, member_id, gid)
        except umysql.SQLError, e:
            #1062 duplicate member
            if e[0] != 1062:
                raise
开发者ID:richmonkey,项目名称:gobelieve_api,代码行数:33,代码来源:group.py


示例9: group_member_setting

def group_member_setting(gid, memberid):
    appid = request.appid
    uid = memberid

    group = Group.get_group(g._db, gid)
    if not group:
        raise ResponseMeta(400, "group non exists")
    
    obj = json.loads(request.data)
    if obj.has_key('do_not_disturb'):
        User.set_group_do_not_disturb(g.rds, appid, uid, gid, obj['do_not_disturb'])
    elif obj.has_key('nickname'):
        Group.update_nickname(g._db, gid, uid, obj['nickname'])
        v = {
            "group_id":gid,
            "group_name":group['name'],
            "timestamp":int(time.time()),
            "nickname":obj['nickname'],
            "member_id":uid
        }
        op = {"update_member_nickname":v}
        send_group_notification(appid, gid, op, None)
    elif obj.has_key('mute'):
        mute = 1 if obj['mute'] else 0
        Group.update_mute(g._db, gid, uid, mute)
        content = "%d,%d,%d" % (gid, memberid, mute)
        publish_message(g.rds, "group_member_mute", content)
    else:
        raise ResponseMeta(400, "no action")

    resp = {"success":True}
    return make_response(200, resp)
开发者ID:richmonkey,项目名称:gobelieve_api,代码行数:32,代码来源:group.py


示例10: from_user

 def from_user(self, receivers=None, text=None, *_):
     if receivers is None:
         return ERR_NORECIPIENT(self.command, self.actor)
     if text is None:
         return ERR_NOTEXTTOSEND(self.actor)
     resp = []
     # TODO: check for ERR_TOOMANYTARGETS
     for receiver in receivers.split(','):
         if Channel.exists(receiver):
             users = [user
                      for user in Channel.get(receiver).users
                      if user is not self.user]
             resp.append(M(
                 ActorCollection(users),
                 self.command, str(receiver), text,
                 prefix=str(self.user)))
         elif User.exists(receiver):
             resp.append(M(
                 Actor.by_user(User.get(receiver)),
                 self.command, str(receiver), text,
                 prefix=str(self.user)))
         # TODO: Implement wildcards
         # TODO: check for ERR_WILDTOPLEVEL, RPL_AWAY, ERR_NOTOPLEVEL
         else:
             resp.append(ERR_NOSUCHNICK(receiver, self.actor))
     return resp
开发者ID:Cloudxtreme,项目名称:python-ircd,代码行数:26,代码来源:privmsg.py


示例11: client_orders_distribute

def client_orders_distribute():
    if request.method == 'POST':
        order_id = request.values.get('order_id', '')
        operator = request.values.get('operater_ids', '')
        order = ClientOrder.get(order_id)
        if operator:
            operater_users = User.gets(operator.split(','))
            to_users = operater_users
            for k in order.medium_orders:
                k.operaters = operater_users
                k.save()
        else:
            for k in order.medium_orders:
                k.operaters = []
                k.save()
            to_users = []
        if to_users:
            context = {"to_users": to_users + [g.user],
                       "operater_users": operater_users,
                       "action_msg": u'分配执行人员',
                       "info": '',
                       "order": order}
            outsource_distribute_signal.send(
                current_app._get_current_object(), context=context)
        return redirect(url_for('outsource.client_orders_distribute'))

    orders = [k for k in ClientOrder.query.all() if k.medium_orders and k.contract != '']
    operaters = User.gets_by_team_type(
        TEAM_TYPE_OPERATER) + User.gets_by_team_type(TEAM_TYPE_OPERATER_LEADER)
    return display_orders(orders, 'client_orders_distribute.html', title=u"客户订单分配", operaters=operaters)
开发者ID:giveme168,项目名称:braavos,代码行数:30,代码来源:outsource.py


示例12: get

 def get(self):
     uname = self.get_current_user()
     user = User.get_user_by_name(uname)
     order = get_order()
     card = Card.get_by_porder(order)
     cid = self.get_argument("cid",None)
     if cid is not None:
         card=Card.get_by_cid(cid)
     article = Article.get_all_Acard(200)
     usedCard = Card.get_all_card()
     temp = []
     for one in usedCard:
         if 0 < one.porder and one.porder <= order:
             temp.append(one)
     usedCard = temp
     reArticles = Article.get_all(200)
     Rarticle = sorted(reArticles,BaseHandler.rank)
     if len(Rarticle) > 6:
         Rarticle = Rarticle[:6]
     Ruser = User.get_all_user(100)
     if len(Ruser)>9:
         Ruser = Ruser[:9]
     if len(usedCard)>3:
         usedCard = usedCard[:3]
     self.render("card.html",user=user,Rarticle=Rarticle,Article=article,usedCard=usedCard,Ruser=Ruser,card=card)
开发者ID:oujiaqi,项目名称:suiyue,代码行数:25,代码来源:card.py


示例13: getUserObject

 def getUserObject(self, user = None):
     
     from google.appengine.api import users
     from models.user import User
     
     if user == None:
         user = users.get_current_user()
     
     userId = self.getUserId(user)
     if not userId:
         return None
     
     query = User.all()
     query.filter("id =", userId)
     userObject = query.get()
     
     if userObject == None:
         if type(user) == users.User:
             userObject = User(
                 id = userId,
                 username = user.nickname().split('@')[0],
                 name = user.nickname().split('@')[0]
             )
         else:
             userObject = User(
                 id = userId,
                 username = userId,
                 name = userId
             )
         userObject.put()
     
     return userObject
开发者ID:peej,项目名称:to.uri.st,代码行数:32,代码来源:controller.py


示例14: post

 def post(self):
     email = self.request.get('email'),
     User.create_user(email, unique_properties=['email'],
                     password_raw=self.request.get('password'),
                     email=email,
                     name= self.request.get('name'),
                     image= self.request.get('image'))
开发者ID:evertoncastro,项目名称:sud-message,代码行数:7,代码来源:main.py


示例15: _do_login

    def _do_login(self, response):
        username = self.get_argument("username", None)
        password = self.get_argument("password", None)
        if not username or not password:
            # do something
            self.flash.error = "You must enter a username and password to proceed. Please try again."
            return 
        pw = hashlib.sha1(password).hexdigest()
        username = User.normalize(username)
        user = User.lookup(username)
        #check the password.
        if not user or user['password'] != pw:
            # do something
            self.flash.error = "Login not valid"
            return
        # check if user is suspended.
        if user.is_suspended() :
            self.flash.error = "Sorry the account you specified has been suspended."
            return    
        user.history.last_login = datetime.datetime.utcnow()
        Mongo.db.ui['users'].update({'_id': username}, {
                                                    '$set' : {'history.last_login': user.history.last_login},
                                                    '$inc' : {'history.num_logins' : 1}
                                                    })        
        #add to the session.
        self.session['username'] = user._id
        #check keep_logged_in
        if self.get_argument("keep_logged_in", False) == "on" :
            self.session['keep_logged_in'] = True
            
        self.set_current_user(user)
#        self.session['current_user']= user._id
        self.flash.notice = "Welcome, %s" % user._id
        self.write(username)
        self.finish("finished")
开发者ID:hc990,项目名称:let,代码行数:35,代码来源:account_control.py


示例16: signup

def signup():
    if current_user.is_authenticated():
        return redirect(url_for('tickets'))
    form = SignupForm(request.form, next=request.args.get('next'))

    if request.method == 'POST' and form.validate():
        user = User(form.email.data, form.name.data)
        user.set_password(form.password.data)
        db.session.add(user)
        try:
            db.session.commit()
        except IntegrityError, e:
            app.logger.warn('Adding user raised %r, assuming duplicate email', e)
            flash("This email address %s is already in use. Please log in, or reset your password if you've forgotten it." % (form.email.data))
            return redirect(url_for('login'))
        login_user(user)

        # send a welcome email.
        msg = Message("Welcome to Electromagnetic Field",
                sender=app.config['TICKETS_EMAIL'],
                recipients=[user.email])
        msg.body = render_template("welcome-email.txt", user=user)
        mail.send(msg)

        return redirect(form.next.data or url_for('tickets'))
开发者ID:Jonty,项目名称:Website,代码行数:25,代码来源:users.py


示例17: index

def index():
    if not g.user.is_super_admin():
        abort(403)
    form = FrameworkOrderForm(request.form)
    if request.method == 'POST' and form.validate():
        order = FrameworkOrder.add(group=Group.get(form.group.data),
                                   agents=Agent.gets(form.agents.data),
                                   description=form.description.data,
                                   money=int(
                                       round(float(form.money.data or 0))),
                                   client_start=form.client_start.data,
                                   client_end=form.client_end.data,
                                   reminde_date=form.reminde_date.data,
                                   direct_sales=User.gets(
                                       form.direct_sales.data),
                                   agent_sales=User.gets(form.agent_sales.data),
                                   contract_type=form.contract_type.data,
                                   creator=g.user,
                                   contract_status=2,
                                   contract=request.values.get('contract'),
                                   create_time=datetime.now())
        order.add_comment(g.user, u"导入了框架订单")
        flash(u'导入框架订单成功', 'success')
        return redirect(order.info_path())
    else:
        form.client_start.data = datetime.now().date()
        form.client_end.data = datetime.now().date()
        form.reminde_date.data = datetime.now().date()
    return tpl('insert_framework_order.html', form=form)
开发者ID:giveme168,项目名称:braavos,代码行数:29,代码来源:insert_framework_orders.py


示例18: get

 def get(self, param):
     """ => user.list """
     swbkuerzel = self.get_current_user()
     #self.write("get (param): " + str(param))
     user = User(swbkuerzel)
     self.render("user_list.html", users=user.find_all())
     self.flush()
开发者ID:pythononwheels,项目名称:diary,代码行数:7,代码来源:user_handler.py


示例19: users

def users():
    form = NewUserForm()

    if form.validate_on_submit():
        email, name = form.email.data, form.name.data
        user = User(email, name)

        db.session.add(user)
        db.session.commit()
        app.logger.info('%s manually created new user with email %s and id: %s',
                        current_user.id, email, user.id)

        code = user.login_code(app.config['SECRET_KEY'])
        msg = Message('Welcome to the EMF website',
                      sender=app.config['CONTACT_EMAIL'],
                      recipients=[email])
        msg.body = render_template('emails/manually-added-user.txt',
                                   user=user, code=code)
        mail.send(msg)

        flash('Created account for: %s' % name)
        return redirect(url_for('.users'))

    users = User.query.order_by(User.id).options(joinedload(User.permissions)).all()
    return render_template('admin/users/users.html', users=users, form=form)
开发者ID:dominicgs,项目名称:Website,代码行数:25,代码来源:users.py


示例20: get

	def get(self):
		template_params={}
		contact_user_email= self.request.get('contact_user_email')
		nick_name= self.request.get('nick_name')
		user = None
		if self.request.cookies.get('our_token'):    #the cookie that should contain the access token!
			user = User.checkToken(self.request.cookies.get('our_token'))
		if not user:
			html = template.render("web/templates/index.html", {})
			self.response.write(html)
			return
		userCon= User.checkIfUesr(contact_user_email)
		if userCon is None:
			return
#		contactlist= Contact.getAllContactsPerUser(user)
#		for c in contactlist:
#			if c..contact_user_email is contact_user_email:
#				return
		contact=Contact()
		contact.contact_user_email=contact_user_email
		contact.nick_name=nick_name
		contact.user=user.key
		contact.put()
		self.response.set_cookie('our_token', str(user.key.id()))
		self.response.write(json.dumps({'status':'OK'}))
		return
开发者ID:babaniassaf,项目名称:ShareLink,代码行数:26,代码来源:contactspage.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python user.UserModel类代码示例发布时间:2022-05-27
下一篇:
Python transforms.send_json_response函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap