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

Python models.UserInfo类代码示例

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

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



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

示例1: register

def register(request):
    if request.method == 'POST': # If the form has been submitted...
        row = UserInfo(email_id = request.POST['email'], password = request.POST['pwd'],
                           full_name = request.POST['fullname'])
        row.save()
        email = request.POST['email'];
    return HttpResponseRedirect('alternative')
开发者ID:sattti161,项目名称:mysite,代码行数:7,代码来源:views.py


示例2: loginView

def loginView(request):
    context = get_context(request)
    
    # Forget AccountAccesses to merge if user goes somewhere then back to login.
    if 'merge_access' in request.session:
        del request.session['merge_access']
    if 'merge_access_info' in request.session:
        del request.session['merge_access_info']
    
    if request.user.is_authenticated():
        try:
            access = request.user.accountaccess_set.all()[0]
        except IndexError:
            access = None
        else:
            client = access.api_client
            user_info = client.get_profile_info(raw_token=access.access_token)
            context['info'] = user_info

            user = request.user
            try:
                user_profile = UserProfile.objects.get(user=user)
            except UserProfile.DoesNotExist:
                new_user_info = UserInfo()
                new_user_info.save()
                user_profile, just_created = UserProfile.objects.get_or_create(user=user, user_info=new_user_info)

                # I'm not sure if this condition is necessary.
                if just_created:
                    standarize_user_info(user_info)
                    if 'gender' in user_info:
                        user_profile.gender = user_info['gender']
                    user.save()
                    user_profile.save()
    return render(request, 'login.html', context)
开发者ID:Mrowqa,项目名称:aplikacjawww,代码行数:35,代码来源:auth.py


示例3: current_user_info

 def current_user_info(self):
     
     if self.user_info is None:
         """Get the current user by lookup if we can"""
         if self.username:
             self.user_info = UserInfo.get_by_username(self.username)
         
         """Gets the current user. This involves a query. Its more efficient to perform 
         lookups with the username and verify that the user_info is current."""
         if self.google_user is not None:
             users_query = UserInfo.query( UserInfo.google_user==self.google_user)
             self.user_info = users_query.get()
         
         if self.oauth_user_id is not None:
             users_query = UserInfo.query( UserInfo.oauth_user_id==self.oauth_user_id)
             self.user_info = users_query.get()
         
         if self.user_info and self.username is None:
             self.username = self.user_info.username
         
         
     if self.user_info is not None and self.is_user_info_current(self.user_info):
         return self.user_info
     else:
         return None
开发者ID:Gabicoware,项目名称:txtbranch,代码行数:25,代码来源:controllers.py


示例4: set_username

 def set_username(self,username):
     errors = []
             
     match = re.search(r'^[\d\w_\-]+$', username)
     
     isvalid = match and 4 <= len(username) and len(username) <= 20;
     
     if not isvalid:
         errors.append('invalid_name')
     else:
         user_info = self.current_user_info()
         if user_info is None:
             user_info_key = UserInfo.create_key(username)
             
             #in the circumstances of a collision whoever asked last is the winner
             #of course if fifty 'Daniels' pile up then we have an issue
             user_info = user_info_key.get()
             if user_info is None:
                 user_info = UserInfo.put_new(username,oauth_user_id=self.oauth_user_id,google_user=self.google_user)
             else:
                 errors.append('other_has_name')
     
     if len(errors) == 0:
         return True, user_info
     else:
         return False, errors
开发者ID:Gabicoware,项目名称:txtbranch,代码行数:26,代码来源:controllers.py


示例5: register_new_user

def register_new_user(email, password):
    user = UserInfo(
        email=email,
        password=password,
        id=email
    )
    user.put()
开发者ID:rushiagr,项目名称:resumappGAE,代码行数:7,代码来源:views.py


示例6: login

def login():
    if 'Authorization' in request.headers:
        user = UserInfo.get_with_token(request.headers['Authorization'])
        if user is not None:
            login_user(user)
            response = {}
            response['code'] = 0
            response['cell'] = user.cell
            response['token'] = user.token
            return json.dumps(response)
            # return "User: "+user.cell+"  successfully logged in by token"
    try:
        cell = request.json['cell']
        pwd = request.json['password']
        user = UserInfo.get_with_cell(cell=cell)
        if (user is not None) and (user.password == pwd):
            login_user(user, remember=True)
            response = {}
            response['code'] = 0
            response['cell'] = cell
            response['token'] = user.token
            return json.dumps(response)
        else:
            response = {'code': 1}
            return json.dumps(response)

    except (KeyError, TypeError, ValueError):
        response = {'code': -2}
        return json.dumps(response)
开发者ID:BenZstory,项目名称:walplay_backend,代码行数:29,代码来源:views.py


示例7: get

    def get(self, mode = ''):
        if mode == 'login':
            if 'allowed' in self.request.cookies and \
                    self.request.cookies['allowed'].count('_'):
                _twitter_id, _login_hash = \
                    self.request.cookies['allowed'].split('_', 1)
        
                user_info = UserInfo.all().filter('twitter_id =', _twitter_id).get()
                if user_info and _sha512(user_info.acc_key) == _login_hash:
                    self.session = Session()
                    self.session['twitter_id'] = _twitter_id
                    return self.redirect('/home')

            auth = _oauth_handler()
            auth_url = auth.get_authorization_url()
            memcache.set(auth.request_token.key,
                         auth.request_token.secret,
                         3600)
            return self.redirect(auth_url)

        elif mode == 'verify':
            auth = _oauth_handler()
            ver = self.request.get('oauth_verifier')
            req_key = self.request.get('oauth_token')
            req_sec = memcache.get(req_key)
            auth.set_request_token(req_key, req_sec)
            acc_token = auth.get_access_token(ver)

            api = tweepy.API(auth_handler = auth)
            me = api.me()

            if not UserInfo.all().filter('twitter_id =', str(me.id)).get():
                user_info = UserInfo(twitter_id = str(me.id),
                                     screen_name = me.screen_name,
                                     name = me.name,
                                     image = me.profile_image_url,
                                     acc_key = acc_token.key,
                                     acc_sec = acc_token.secret)
                user_info.put()

            self.session = Session()
            self.session.delete_item('twitter_id')
            self.session['twitter_id'] = str(me.id)

            c = SimpleCookie()
            c['allowed'] = '%d_%s' % (me.id, _sha512(acc_token.key))
            c['allowed']['path'] = '/auth'
            c['allowed']['expires'] = 86400 * 10
            self.response.headers.add_header('Set-Cookie', c.output(header = ''))

            return self.redirect('/home')

        elif mode == 'logout':
            user_info = _login_user(self)
            if user_info:
                self.session = Session()
                self.session.delete_item('twitter_id')

            return self.redirect('/')
开发者ID:setomits,项目名称:imf-tweet,代码行数:59,代码来源:handlers.py


示例8: test_signals

 def test_signals(self):
     old_count = LogEntry.objects.count()
     userobject = UserInfo(name='testname', \
                           surname='testsurname', \
                           birthday='2010-02-17', \
                           about='test', \
                           contacts='test');
     userobject.save()
     self.assertNotEqual(old_count, LogEntry.objects.count())
开发者ID:dtarasiuk,项目名称:zdjango,代码行数:9,代码来源:tests.py


示例9: post

	def post(self):
		userinfo = self.currentuser
		if userinfo == None:
			userinfo = UserInfo()
		
		userinfo.nickname = cgi.escape(self.request.get('nickname'))
		if is_empty(userinfo.nickname):
			self.render_edit("nickname can't be empty")
			return
		
		email = cgi.escape(self.request.get('email'))
		avatar = self.request.get('avatar')
		first_login = self.request.get('first_login')
		
		if avatar != '':
			avatar = images.resize(avatar, 128)
			userinfo.avatar = db.Blob(avatar)
			
		if email == '':
			email = 'none'
		userinfo.email = email

		if first_login != '':
			userinfo.lastposted = date.today()
			userinfo.lastvoted = userinfo.lastposted
			
		userinfo.put()
		self.redirect('/')
开发者ID:paulsc,项目名称:lunchdiscussion,代码行数:28,代码来源:views.py


示例10: get

 def get(self):
   user = users.get_current_user()
   if user:
     code = self.request.get("code")
     if code:
       old_userinfos = UserInfo.all().filter('user =', user).fetch(500)
       db.delete(old_userinfos)
       fs, credentials = self._get_new_fs_and_credentials()
       try:
         user_token = fs.get_access_token(code)
         userinfo = UserInfo(user = user, token = user_token, secret = None, is_ready=False, is_authorized=True, level_max=int(3 * constants.level_const))
       except DownloadError, err:
         if str(err).find('ApplicationError: 5') >= 0:
           pass # if something bad happens on OAuth, then it currently just redirects to the signup page
                #TODO find a better way to handle this case, but it's not clear there is a simple way to do it without messing up a bunch of code
         else:
           raise err
       try:
         manage_foursquare_data.update_user_info(userinfo)
         manage_foursquare_data.fetch_and_store_checkins_next(userinfo, limit=50)
       except foursquare.FoursquareRemoteException, err:
         if str(err).find('403 Forbidden') >= 0:
           pass # if a user tries to sign up while my app is blocked, then it currently just redirects to the signup page
                #TODO find a better way to handle this case, but it's not clear there is a simple way to do it without messing up a bunch of code
         else:
           raise err
       except DownloadError:
         pass #TODO make this better, but I'd rather throw the user back to the main page to try again than show the user an error.
开发者ID:neostoic,项目名称:where-do-you-go,代码行数:28,代码来源:handlers.py


示例11: flush

def flush():
    ndb.delete_multi(School.query().fetch(keys_only=True))
    ndb.delete_multi(QuestionInstance.query().fetch(keys_only=True))
    ndb.delete_multi(State_Questions.query().fetch(keys_only=True))
    ndb.delete_multi(Topic_States.query().fetch(keys_only=True))
    ndb.delete_multi(Question.query().fetch(keys_only=True))
    ndb.delete_multi(State.query().fetch(keys_only=True))
    ndb.delete_multi(Address.query().fetch(keys_only=True))
    ndb.delete_multi(Teacher.query().fetch(keys_only=True))
    ndb.delete_multi(Class.query().fetch(keys_only=True))
    ndb.delete_multi(Assessment_Record.query().fetch(keys_only=True))
    ndb.delete_multi(Student.query().fetch(keys_only=True))
    ndb.delete_multi(UserInfo.query().fetch(keys_only=True))
    ndb.delete_multi(Student_Assessments.query().fetch(keys_only=True))
    ndb.delete_multi(Assessment.query().fetch(keys_only=True))
    ndb.delete_multi(Subject.query().fetch(keys_only=True))
    ndb.delete_multi(Topic_Questions.query().fetch(keys_only=True))
    ndb.delete_multi(State_Questions.query().fetch(keys_only=True))
    ndb.delete_multi(Topic_States.query().fetch(keys_only=True))
    ndb.delete_multi(Subject_Topics.query().fetch(keys_only=True))
    ndb.delete_multi(Student_Assessments.query().fetch(keys_only=True))
    ndb.delete_multi(Topic.query().fetch(keys_only=True))
    ndb.delete_multi(User.query().fetch(keys_only=True))
    ndb.delete_multi(Assessment_Record.query().fetch(keys_only=True))
    ndb.delete_multi(State_Types.query().fetch(keys_only=True))
开发者ID:anks315,项目名称:Assesment2,代码行数:25,代码来源:dummydata3.py


示例12: checkIdAndEmail

def checkIdAndEmail(userId, email):
  query = UserInfo.all()
  query.filter('userId = ', userId).filter('email = ', email)
  if query.count() == 0:
    return False;
  else:
    return True;
开发者ID:proming,项目名称:gaemarks,代码行数:7,代码来源:userApi.py


示例13: checkEmail

def checkEmail(email):
  query = UserInfo.all()
  query.filter('email = ', email)
  if query.count() == 0:
    return False;
  else:
    return True;
开发者ID:proming,项目名称:gaemarks,代码行数:7,代码来源:userApi.py


示例14: checkUserId

def checkUserId(userId):
  query = UserInfo.all()
  query.filter('userId = ', userId)
  if query.count() == 0:
    return False;
  else:
    return True;
开发者ID:proming,项目名称:gaemarks,代码行数:7,代码来源:userApi.py


示例15: authService

def authService(userId, passwd):
  query = UserInfo.all()
  query.filter('userId = ', userId).filter('passwd = ', passwd)
  if query.count() == 0:
    return False;
  else:
    return True;
开发者ID:proming,项目名称:gaemarks,代码行数:7,代码来源:userApi.py


示例16: __init__

    def __init__(self):
        self.user = users.get_current_user()
        userinfo_query = UserInfo.all().filter('ownerid =',self.user)
        self.userinfo = userinfo_query.get()

        if self.userinfo is None:
            userinfo = UserInfo()
            userinfo.ownerid = self.user

        self.template_values = {
            'user' : self.user,
            'nickname' : self.user.nickname(),
            }

        key = ""
        template_path = ""
开发者ID:mkouhei,项目名称:ihealthcheck,代码行数:16,代码来源:control.py


示例17: submit_bm

def submit_bm(feed, user, title, url, comment):
    bm = Bookmarks()

    result = urlfetch.fetch(url=url, follow_redirects=True, allow_truncated=True, deadline=60)
    if result.status_code == 200 and result.final_url:
        a = result.final_url
    elif result.status_code == 500:
        pass
    else:
        a = url

    url_candidate = a.lstrip().rstrip().split('?utm_source')[0].split('&feature')[0]

    url_parsed = urlparse(url_candidate)
    query = parse_qs(url_parsed.query)
    name = url_parsed.path.split('/')[-1]
    ext = name.split('.')[-1].lower()

    bm.title = url_candidate if title == '' or None else title

    if url_parsed.netloc == 'www.youtube.com':
        bm.url = 'http://www.youtube.com/watch?v=%s' % query["v"][0]
        bm.comment = """<embed
        width="640" height="360"
        src="http://www.youtube.com/v/%s"
        type="application/x-shockwave-flash">
        </embed>""" % query["v"][0]

    elif url_parsed.netloc == 'vimeo.com':
        bm.url = 'http://vimeo.com/%s' % name
        bm.comment = '''<iframe src="http://player.vimeo.com/video/%s?color=ffffff"
        width="640" height="360" frameborder="0" webkitAllowFullScreen mozallowfullscreen
        allowFullScreen></iframe>''' % name

    elif ext in ['jpg', 'png', 'jpeg', 'gif']:
        bm.url = url_candidate
        blob_key = upload_to_blobstore(url_candidate, ext)
        bm.comment = '<img src="%s" />' % images.get_serving_url(blob_key, size=1600)
    else:
        bm.comment = comment
        bm.url = url_candidate

    bm.domain = url_parsed.netloc
    bm.user = user
    bm.feed = feed
    bm.put()
    Bookmarks.index_bm(bm.key)

    copie = Bookmarks.query(Bookmarks.url == bm.url,
                            Bookmarks.user == user)

    if copie.get():
        ndb.delete_multi([cp.key for cp in copie])

    ui = UserInfo.get_or_insert(str(user.user_id()), user=user)
    if feed is None and ui.mys is True:
        deferred.defer(util.send_bm, bm.key, _queue="email")
    elif feed is not None and feed.get().notify == 'email':
        deferred.defer(util.send_bm, bm.key, _queue="email")
开发者ID:presveva,项目名称:gaeicious,代码行数:59,代码来源:submit.py


示例18: get

 def get(self):
   user = users.get_current_user()
   if user:
     userinfo = UserInfo.all().filter('user =', user).get() #.order('-created')
     if userinfo:
         self.response.out.write(str(userinfo.is_ready) + ',' + str(userinfo.checkin_count))
         return
   self.response.out.write("")
开发者ID:ubilabs,项目名称:where-do-you-go,代码行数:8,代码来源:handlers.py


示例19: get_like_value

 def get_like_value(self,branch):
     userinfo = UserInfo.get_by_username(self.username)    
     if userinfo and self.is_user_info_current(userinfo):
         like_key = Like.create_key(branch.key,self.username)
         like = like_key.get();
         if like:
             return like.value
     return 0
开发者ID:Gabicoware,项目名称:txtbranch,代码行数:8,代码来源:controllers.py


示例20: post

 def post(self):
     user = users.get_current_user()
     upload_files = self.get_uploads('file')
     blob_info = upload_files[0]
     ui = UserInfo.query(UserInfo.user == user).get()
     ui.delicious = blob_info.key()
     ui.put()
     self.redirect('/')
     deferred.defer(delicious, ui.delicious, user, _queue="delicious")
开发者ID:russomi,项目名称:gaeicious,代码行数:9,代码来源:submit.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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