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

Python models.Users类代码示例

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

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



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

示例1: check

def check(request):

    searchInput = request.POST.get('searchInput')
    if searchInput is not '':
        users = Users.objects.filter(username=searchInput)

        if len(users) > 0:

            user_id = users[0].userId # is working
            return HttpResponseRedirect(reverse('photos:view1', kwargs={'userId': user_id}))
        else:
            r = requests.get('https://api.instagram.com/v1/users/search?access_token=1497402817.1fb234f.1b8969bb3b304945a6782ae574069017&q={}'.format(searchInput))
            response = r.json()

            for user in response['data']:
                if user['username'] == searchInput and len(user['username']) == len(searchInput):
                    userId = user['id']
                    username = user['username']

                    newUser = Users(userId = userId, username=username)
                    newUser.save()

                    return HttpResponseRedirect(reverse('photos:view1', kwargs={'userId': userId}))

    return render(request, 'photos/search.html', {
        'error_message': "Please input a valid username.",
    })
开发者ID:MAHostalek,项目名称:BootcampInitialProjects,代码行数:27,代码来源:views.py


示例2: facebook_user_query

def facebook_user_query(
    field,
    datastore_key,
    user=None,
    google_token=None,
    facebook_token=None,
    default=None,
    force_update=False,
    format_f=lambda x: x,
):
    """This does the work for functions like check_locale and check_timezone.
  It's a common pattern to query Facebook for 1 piece of info if it's not 
  already in the database, update it if different and then return the result."""
    # First find the user
    if not user:
        if google_token:
            user = Users.all().filter("google_token = ", google_token).get()
        elif facebook_token:
            user = Users.all().filter("facebook_token = ", facebook_token).get()
    # Next check the existing data
    if user and not force_update:
        existing = getattr(user, datastore_key)
        # Todo - more useful check for existing being OK
        if existing != None:
            return format_f(existing), False
    # No good, ask Facebook
    graph = facebook.GraphAPI(facebook_token or (user and user.facebook_token))
    try:
        results = graph.get_object("me", fields=field)
    except GraphAPIError, err:
        return None, parse_facebook_error(err)
开发者ID:kzar,项目名称:CalenDerp,代码行数:31,代码来源:calenderp.py


示例3: facebook_authorized

def facebook_authorized(resp):
    next_url = request.args.get('next') or url_for('index')
    if resp is None:
        flash('You denied the login')
        return redirect(next_url)

    session['fb_access_token'] = (resp['access_token'], '')

    me = facebook.get('/me')
    user = Users.query.filter_by(fb_id=me.data['id']).first()
    
    if user is None:
      fb_id = me.data['id']
      
      if me.data['username']:
        fb_username = me.data['username']
      else:
        fb_username = me.data['name']

      fb_email = me.data['email']

      user = Users(fb_username, 'temp',fb_email)
      user.fb_id = me.data['id']
      user.activate  = True
      user.created = datetime.utcnow()
      db.session.add(user)
      db.session.commit()
    session['user_id'] = user.uid

    flash('You are now logged in as %s' % user.username)
    return redirect(url_for('index'))
开发者ID:homoludens,项目名称:EventMap,代码行数:31,代码来源:views.py


示例4: registreer

def registreer(request):
    #user = Users(Voornaam='', Achternaam='', Email='', Wachtwoord='', Rechten='0')
    #user.save()
    if request.method == 'POST':
        # create a form instance and populate it with data from the request:
        formregistreer = Registreer(request.POST)
        # check whether it's valid:
        if formregistreer.is_valid():
            voornaam = formregistreer.cleaned_data['voornaam']
            achternaam = formregistreer.cleaned_data['achternaam']
            email = formregistreer.cleaned_data['email']
            wachtwoord = formregistreer.cleaned_data['wachtwoord']
            try:
                selectedEerder=Users.objects.get(Email=email)
                formregistreer.errors[""] = ErrorList([u"Het opgegeven email adres is al geregistreerd!"])
            except Users.DoesNotExist:
                if(formregistreer.cleaned_data['wachtwoord'] == formregistreer.cleaned_data['Herhaal_wachtwoord']):
                    voeg_toe = Users(Voornaam=voornaam, Achternaam=achternaam, Email=email, Wachtwoord=wachtwoord, Rechten='0')
                    voeg_toe.save()
                    return HttpResponseRedirect('/login/')
                else:
                    formregistreer.errors[""] = ErrorList([u"De opgegeven wachtwoorden komen niet overeen!"])
    else:
        formregistreer = Registreer()
    return render_to_response('registreer.html',{'registreer': formregistreer},
                              context_instance=RequestContext(request))
开发者ID:A-Maze,项目名称:A-Pc,代码行数:26,代码来源:login.py


示例5: get_user

def get_user(user):
    """ Get a user from the datastore """
    user_db = Users.get_by_id(user.user_id())
    if user_db is None:
        user_db = Users(id=user.user_id(),email=user.email())
        user_db.put()
    return user_db
开发者ID:naiyt,项目名称:trellorss-gae,代码行数:7,代码来源:utils.py


示例6: check

def check(request):
    name = request.POST['username']
    chat = ChatRoom.objects.get(name="DRRR")
    try:
        ic = request.POST['icon']
    except:
        ic = {}
    if not Users.objects.filter(username = name):
        #return HttpResponse(Users.objects.filter(username = name))
        if not ic:
            # better to stay on the same page
            return HttpResponse("Please select an icon")
        else:
            new = Users(username = name,
                       icon = ic)
            new.save()
            return render_to_response('room.html', {'user': new, 'chat': chat})
    else:
        u = Users.objects.get(username = name)
        if u.icon == ic:
            return render_to_response('room.html', {'user': u, 'chat': chat})
        else:
            u.icon = ic
            u.save()
            return render_to_response('room.html', {'user': u, 'chat': chat})
开发者ID:Fransacreblue,项目名称:DRRR-Node,代码行数:25,代码来源:views.py


示例7: facebook_authorized

def facebook_authorized(resp):
    next_url = request.args.get("next") or url_for("index")
    if resp is None:
        flash("You denied the facebook login")
        return redirect(next_url)

    session["fb_access_token"] = (resp["access_token"], "")

    me = facebook.get("/me")
    user = Users.query.filter_by(fb_id=me.data["id"]).first()

    if user:
        if me.data["username"]:
            fb_username = me.data["username"]
        else:
            fb_username = me.data["name"]

        fb_email = me.data["email"]

        role = 1
        user = Users(fb_username, "temp", fb_email, role)
        user.fb_id = me.data["id"]
        user.activate = True
        user.created = datetime.utcnow()
        db.session.add(user)
        db.session.commit()
        session["user_id"] = user.uid

        flash("You are now logged in as %s" % user.username)
        return redirect(url_for("index"))
开发者ID:priestd09,项目名称:flaskCamel,代码行数:30,代码来源:views.py


示例8: create

def create(request):

    if request.method=='POST':
        name = request.POST['username']
        email = request.POST['email']
        sex = request.POST['sex']
        mobile_number = request.POST['mobile_number']
        exam_city = request.POST['exam_city']
        current_city = request.POST['current_city']
        exam_date = request.POST['exam_date']

        if exam_date == '' or name == '' or email == '' or mobile_number == '' :
            return render_to_response('share/create.html')
        else :
            new_obj = Users(name = name, email = email, sex = sex, mobile_number = mobile_number,exam_city_id = exam_city,exam_date = exam_date, current_city = current_city)
            new_obj.save()
            if "requested_to" in request.session:

                obj = Request(requester = new_obj.id,requested_to = request.session["requested_to"])
                obj.save()
                del request.session["requested_to"]
                return HttpResponseRedirect('/thanks/')
            return HttpResponseRedirect('/thankyou/')
    if "exam_city" in request.session:
        return render_to_response('share/create.html',{'exists':1,'exam_date':request.session["exam_date"]})

    return render_to_response('share/create.html',{'exists':0})
开发者ID:avinashbangar,项目名称:student-partner-service,代码行数:27,代码来源:views.py


示例9: register

def register(request):
    if request.method == "POST":
        first_name = request.POST['first_name']
        last_name = request.POST['last_name']
        email = request.POST['email']
        password = request.POST['password1']
        c_password = request.POST['password2']

        if Users.objects.filter(email=email):
            messages.error(request, "Ruh Roh! Email is already in use.")
            return redirect(reverse('main'))

        result = Users.objects.register(first_name = first_name, last_name =last_name, email=email, password1=password, password2 = c_password)
        if result[0]:
            print "No Pass! {}".format(result[1])
            for row in result[1]:
                messages.error(request, row)
            return redirect(reverse('main'))
        else:
            hashed = Users.objects.create_password(password)
            user = Users(first_name = first_name, last_name = last_name, email= email, password = hashed)
            user.save()
            try:
                u = Users.objects.get(email=email)
            except:
                return HttpResponse("Ruh Roh! Something went wrong.v Please contact site administrator.")

            request.session['first_name'] = u.first_name
            request.session['uid'] = u.id
            messages.success(request,"Successfully registered! (or logged in)")
            return redirect(reverse('success'))
    else:
        return redirect(reverse('index'))
    pass
开发者ID:symaselbbircs,项目名称:cd-work,代码行数:34,代码来源:views.py


示例10: add_user_in_db

def add_user_in_db(session_id, username, game, field, status=0, status_first=1):
    """create user in database for registration in game
    
    Arguments:
    - `session`: uniq session 
    - `user`: name user from form
    - `game`: id game
    - `field`: id fields
    - `status`: status of user on site
    """
    # check session_id in database
    users = Users.objects(session=session_id) 
    if not users:
        new_user = Users(user_name=username, 
                         session=session_id,
                         game=game,
                         field_battle=field,
                         status=status,
                         status_first=status_first)
        new_user.save()
    else:
        user = Users.objects.get(session=session_id)
        user.game = game
        user.user_name = username
        user.field_battle = field
        user.status = status
        user.status_first = status_first
        user.last_time = datetime.datetime.now()
        user.save()
        game.time_begin = datetime.datetime.now()
        game.time_end = datetime.datetime.now()
        game.save()
    return True
开发者ID:le087,项目名称:naval-battle,代码行数:33,代码来源:utils.py


示例11: test_basic_addition

    def test_basic_addition(self):
        """
        Tests that 1 + 1 always equals 2.
        """
        u=Users(first_name='111',last_name='222',password='123456',appellation='5555',email='[email protected]',id_no='130102198403261218',mobile_phone=13653319585)
        u.save()
        self.assertEqual((u.id>0),True)
				
开发者ID:imaxu,项目名称:dazatuweb,代码行数:7,代码来源:tests.py


示例12: phonebook

def phonebook(request):
    html = ''
    
    for i in Users.get_phones([251, 298, 911, 256, 257, 250, 300, 240]):
        html += '%s - %s<br/>' % (i.extension, i.name)

    html = '<html><body>%s</body></html>' % html
    return render_to_response('pbx/index.html', {'phones': Users.get_phones([251, 298, 911, 256, 257, 250, 300, 240])})
开发者ID:alateas,项目名称:astertools,代码行数:8,代码来源:views.py


示例13: purge

def purge():
    '''
    Truncate all tables
    '''
    Users.delete().execute()
    Inventory.delete().execute()
    AccessRights.delete().execute()
    Credentials.delete().execute()
开发者ID:pschmitt,项目名称:callipyge,代码行数:8,代码来源:callipygectl.py


示例14: addUser

    def addUser(self, name, lastonLineTime, onlineStatus, ip):
        existUser = Users.objects.filter(name=name)
        if len(existUser) != 0:
            raise Exception("the Users is already exits")

        newUser = Users(name=name, ip=ip, onlineStatus=True, lastonLineTime=lastonLineTime)

        newUser.save()
开发者ID:Boelroy,项目名称:PushNotify,代码行数:8,代码来源:UserUtil.py


示例15: _get_users_by_page

def _get_users_by_page():
    """

    :return:users, page
    """
    total = Users.count_all()
    page = Page(total, _get_page_index(), 5)
    users = Users.find_by('order by created_at desc limit ?,?', page.offset, page.limit)
    return users, page
开发者ID:edwingoo,项目名称:mywebapp,代码行数:9,代码来源:urls.py


示例16: addUser

def addUser(username, department, name, course, password, voted=False):
	'''Registers new user with the system including signature key generation and registration'''
	#generate private key
	key = RSA.generate(2048)
	encryptedPrivateKey = cryptography.symmetricEncrypt(key.exportKey(), password)

	p1 = Users(username=username, voted=voted, department=department, name=name, course=course, encryptedPrivateKey=encryptedPrivateKey)
	p1.save()
	return key.publickey().exportKey()
开发者ID:Nj-0,项目名称:gems,代码行数:9,代码来源:databaseManager.py


示例17: delete

    def delete(self, id):
        jail = Users.first(id=id)
        msg = "The user could not be deleted."
        if jail:
            if Users.delete(jail):
                msg = "User deleted."

        cherrypy.session['flash'] = msg
        raise cherrypy.HTTPRedirect('/users')
开发者ID:masom,项目名称:Puck,代码行数:9,代码来源:users.py


示例18: get

 def get(self):
     count = Users.all().count()
     
     if count > 0:
         users = Users.all().fetch(count)
         for user in users:
             taskqueue.add(url='/birthdays', params={"email": user.email, "access_token": user.accessToken})
             
     else:
         self.response.out.write("No users")
开发者ID:mikechernev,项目名称:Facebook-bDay-Remainder,代码行数:10,代码来源:main.py


示例19: register_user

def register_user(name, username, email, password, utype, admin=False):
	user = Users(name, username, email, password, utype=utype, admin=admin)
	token = utils.generate_string(length=64)
	user.email_token = token
	with app.app_context():
		db.session.add(user)
		db.session.commit()
		join_activity = UserActivity(user.uid, 0)
		db.session.add(join_activity)
		db.session.commit()
		db.session.close()
	return True
开发者ID:EasyCTF,项目名称:openctf-docker,代码行数:12,代码来源:user.py


示例20: Mike

class Mike(webapp2.RequestHandler):
    def get(self):
        count = Users.all().count()
        
        if count > 0:
            users = Users.all()
            users.filter("facebookID = ", "691580472")
            users.fetch(1)
            for user in users:
                taskqueue.add(url='/mike', params={"email": user.email, "access_token": user.accessToken})
                
        else:
开发者ID:mikechernev,项目名称:Facebook-bDay-Remainder,代码行数:12,代码来源:main.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python models.Usuario类代码示例发布时间:2022-05-27
下一篇:
Python models.UserProfile类代码示例发布时间: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