當前位置: 首頁>>代碼示例>>Python>>正文


Python User.get_by_auth_id方法代碼示例

本文整理匯總了Python中gae_django.auth.models.User.get_by_auth_id方法的典型用法代碼示例。如果您正苦於以下問題:Python User.get_by_auth_id方法的具體用法?Python User.get_by_auth_id怎麽用?Python User.get_by_auth_id使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在gae_django.auth.models.User的用法示例。


在下文中一共展示了User.get_by_auth_id方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: delete_email

# 需要導入模塊: from gae_django.auth.models import User [as 別名]
# 或者: from gae_django.auth.models.User import get_by_auth_id [as 別名]
def delete_email(request, username, email):
    
    # the ID we are to delete
    auth_id = 'email:%s' % email
    
    user = User.get_by_auth_id('own:%s' % username)
    e_user = User.get_by_auth_id(auth_id)

    if user is None or e_user is None:
        raise Http404("User not found")
    
    if user != request.user or user != e_user:
        http403 = HttpResponse("This ain't you!")
        http403.status = 403
        return http403
    
    if request.method == "POST":
        # delete the email from the user
        user.auth_ids.remove(auth_id)
        user.unique_model.delete_multi(['User.auth_id:%s' % auth_id])
        user.put()
        return HttpResponseRedirect(
            reverse('member-profile', kwargs={'username':request.user.username})
        )
        
    

    return render_to_response('people/delete_email.html', 
        {'email': email}, 
        context_instance=RequestContext(request))
開發者ID:kmooney,項目名稱:julython.org,代碼行數:32,代碼來源:views.py

示例2: post

# 需要導入模塊: from gae_django.auth.models import User [as 別名]
# 或者: from gae_django.auth.models.User import get_by_auth_id [as 別名]
 def post(self):
     """Create a project from the api.
     
     Example::
     
         {
             "url": "http://github.com/defunkt/github",
             "name": "github",
             "description": "You're lookin' at it.",
             "watchers": 5,
             "forks": 2,
             "private": 1,
             "email": "[email protected]",
             "account": "twitter_name",
         },
     """
     form = self.parse_form()
     if not form.is_valid():
         return self.respond_json(form.errors, status_code=400)
     
     # Lookup the user by email or account
     email = form.cleaned_data.pop('email', None)
     account = form.cleaned_data.pop('account', None)
     user = None
     if email:
         user = User.get_by_auth_id('email:%s' % email)
     elif account:
         user = User.get_by_auth_id('twitter:%s' % account)
     
     created = False
     project_url = form.cleaned_data['url']
     project_key = Project.make_key(project_url)
     project = project_key.get()
     
     if project is None:
         created = True
         project = Project(key=project_key, **form.cleaned_data)
         project.put()
     
     @ndb.transactional    
     def txn():
         count = getattr(user, 'total', 0)
         projects = set(getattr(user, 'projects', []))
         user.total = count + 10
         user.projects = list(projects.add(project_url))
         user.put()
         return user
     
     if created and user:
         txn()
     
     self.respond_json({'project': self.serialize(project)}, status_code=201 if created else 200)
開發者ID:digideskio,項目名稱:julython.org,代碼行數:54,代碼來源:api.py

示例3: edit_address

# 需要導入模塊: from gae_django.auth.models import User [as 別名]
# 或者: from gae_django.auth.models.User import get_by_auth_id [as 別名]
def edit_address(request, username, template_name='people/edit_address.html'):
    from forms import EditAddressForm

    user = User.get_by_auth_id('own:%s' % username)

    if user == None:
        raise Http404("User not found")

    if user.key != request.user.key:
        http403 = HttpResponse("This ain't you!")
        http403.status = 403
        return http403

    form = EditAddressForm(request.POST or None, user=user)

    if form.is_valid():
        for key, value in form.cleaned_data.iteritems():
            setattr(user,key,value)
            user.put()
        return HttpResponseRedirect(
            reverse('member-profile',
                kwargs={'username':request.user.username}
            )
        )
    

    return render_to_response(template_name, 
        {'form':form},
        context_instance=RequestContext(request))
開發者ID:kmooney,項目名稱:julython.org,代碼行數:31,代碼來源:views.py

示例4: edit_profile

# 需要導入模塊: from gae_django.auth.models import User [as 別名]
# 或者: from gae_django.auth.models.User import get_by_auth_id [as 別名]
def edit_profile(request, username, template_name='people/edit.html'):
    from forms import EditUserForm
    user = User.get_by_auth_id('twitter:%s' % username)

    if user == None:
        raise Http404("User not found")
    
    if user.key != request.user.key:
        http403 = HttpResponse("This ain't you!")
        http403.status = 403
        return http403
    

    form = EditUserForm(request.POST or None, user=request.user)
    if form.is_valid():
        for key in form.cleaned_data:
            if key == 'email':
                continue
            setattr(user, key, form.cleaned_data.get(key))
        slugify(user.location)
        user.put()
        return HttpResponseRedirect(
            reverse('member-profile', 
                    kwargs={'username':request.user.username}
                   )
        )
        
    

    return render_to_response(template_name, 
        {'form':form}, 
        context_instance=RequestContext(request))
開發者ID:florinmatei,項目名稱:julython.org,代碼行數:34,代碼來源:views.py

示例5: test_testing_mode_off_user_points

# 需要導入模塊: from gae_django.auth.models import User [as 別名]
# 或者: from gae_django.auth.models.User import get_by_auth_id [as 別名]
 def test_testing_mode_off_user_points(self):
     settings.TESTING = False
     user = self.make_user('chris')
     user.add_auth_id('email:[email protected]')
     self.app.post('/api/v1/github', self.POST)
     u = User.get_by_auth_id('email:[email protected]')
     total = getattr(u, 'total', None)
     self.assertEqual(total, None)
開發者ID:florinmatei,項目名稱:julython.org,代碼行數:10,代碼來源:test_api.py

示例6: fix_player_counts

# 需要導入模塊: from gae_django.auth.models import User [as 別名]
# 或者: from gae_django.auth.models.User import get_by_auth_id [as 別名]
def fix_player_counts(auth_id):
    """Fix a single user counts."""
    user = User.get_by_auth_id(auth_id)
    
    ranges = _get_date_ranges()
    
    for start, end in ranges:
        count = Commit.query(ancestor=user.key).filter(Commit.timestamp >= start, Commit.timestamp < end).count(1000)
        Accumulator.add_count('own:%s' % user.username, start, count, reset=True)
開發者ID:ChrisOelmueller,項目名稱:julython.org,代碼行數:11,代碼來源:cron.py

示例7: test_testing_mode_off

# 需要導入模塊: from gae_django.auth.models import User [as 別名]
# 或者: from gae_django.auth.models.User import get_by_auth_id [as 別名]
 def test_testing_mode_off(self):
     settings.TESTING = False
     user = self.make_user('marcus')
     user.add_auth_id('email:[email protected]')
     self.app.post('/api/v1/bitbucket', self.POST)
     u = User.get_by_auth_id('email:[email protected]')
     p_key = Project.make_key('https://bitbucket.org/marcus/project-x/')
     # project should not be created
     self.assertEqual(p_key.get(), None)
開發者ID:florinmatei,項目名稱:julython.org,代碼行數:11,代碼來源:test_api.py

示例8: user_profile

# 需要導入模塊: from gae_django.auth.models import User [as 別名]
# 或者: from gae_django.auth.models.User import get_by_auth_id [as 別名]
def user_profile(request, username):
    user = User.get_by_auth_id('own:%s' % username)
    if user == None:
        raise Http404("User not found")

    commits = Commit.query(ancestor=user.key).order(-Commit.timestamp).fetch(100)

    return render_to_response('people/profile.html', 
        {"commits":commits, 'profile':user}, 
        context_instance=RequestContext(request)) 
開發者ID:kmooney,項目名稱:julython.org,代碼行數:12,代碼來源:views.py

示例9: wrapper

# 需要導入模塊: from gae_django.auth.models import User [as 別名]
# 或者: from gae_django.auth.models.User import get_by_auth_id [as 別名]
        def wrapper(self, *args, **kwargs):
            if login_required:
                if self.auth is None:
                    abort(401)
                
            if registration_required:
                # check to see if the user is registered.
                user = User.get_by_auth_id(self.auth)
                if not user:
                    abort(403)

            return func(self, *args, **kwargs)
開發者ID:digideskio,項目名稱:julython.org,代碼行數:14,代碼來源:api.py

示例10: people_projects

# 需要導入模塊: from gae_django.auth.models import User [as 別名]
# 或者: from gae_django.auth.models.User import get_by_auth_id [as 別名]
def people_projects(request, username):
    user = User.get_by_auth_id('own:%s' % username)
    if user == None:
        raise Http404("User not found")
    
    if getattr(user, 'projects', None) == None:
        projects = [] 
    else: 
        projects = user.projects
        projects = ndb.get_multi([Project.make_key(project) for project in projects])

    return render_to_response('people/people_projects.html', 
        {"projects":projects, 'profile':user}, 
        context_instance=RequestContext(request)) 
開發者ID:kmooney,項目名稱:julython.org,代碼行數:16,代碼來源:views.py

示例11: people_projects

# 需要導入模塊: from gae_django.auth.models import User [as 別名]
# 或者: from gae_django.auth.models.User import get_by_auth_id [as 別名]
def people_projects(request, username):
    user = User.get_by_auth_id('twitter:%s' % username)
    if user == None:
        raise Http404("User not found")
    
    if getattr(user, 'projects', None) == None:
        projects = [] 
    else: 
        projects = user.projects
        projects = [Project.get_or_create(url=project)[1] for project in projects]

    return render_to_response('people/people_projects.html', 
        {"projects":projects, 'profile':user}, 
        context_instance=RequestContext(request)) 
開發者ID:gdub,項目名稱:julython.org,代碼行數:16,代碼來源:views.py

示例12: edit_profile

# 需要導入模塊: from gae_django.auth.models import User [as 別名]
# 或者: from gae_django.auth.models.User import get_by_auth_id [as 別名]
def edit_profile(request, username, template_name='people/edit.html'):
    from forms import EditUserForm
    user = User.get_by_auth_id('own:%s' % username)

    if user == None:
        raise Http404("User not found")
    
    if user.key != request.user.key:
        http403 = HttpResponse("This ain't you!")
        http403.status = 403
        return http403
    
    existing_slug = str(user.location_slug)
    existing_team = str(getattr(user, 'team_slug', ''))
    form = EditUserForm(request.POST or None, user=request.user)
    if form.is_valid():
        for key, value in form.cleaned_data.iteritems():
            if key == 'email':
                # Don't save the email to the profile
                continue
            if key == 'team':
                # slugify the team to allow easy lookups
                setattr(user, 'team_slug', slugify(value))
            setattr(user, key, value)
        user.put()
        
        if user.location_slug != existing_slug:
            # Defer a couple tasks to update the locations
            deferred.defer(fix_location, str(user.location_slug))
            deferred.defer(fix_location, existing_slug)
            
        if getattr(user, 'team_slug', '') != existing_team:
            # Defer a couple tasks to update the teams
            deferred.defer(fix_team, str(user.team_slug))
            deferred.defer(fix_team, existing_team)
            
        return HttpResponseRedirect(
            reverse('member-profile',
                    kwargs={'username':request.user.username}
                   )
        )

    return render_to_response(template_name,
        {'form':form},
        context_instance=RequestContext(request))
開發者ID:kmooney,項目名稱:julython.org,代碼行數:47,代碼來源:views.py

示例13: handle_filter

# 需要導入模塊: from gae_django.auth.models import User [as 別名]
# 或者: from gae_django.auth.models.User import get_by_auth_id [as 別名]
 def handle_filter(self, query, filter_string):
     """Allow for filtering by user or project"""
     if filter_string.startswith('#'):
         # we're looking for a project strip the hash tag first
         project_name = filter_string[1:]
         logging.error('Handle Projects!!! %s', project_name)
         raise
     elif filter_string.startswith('@'):
         username = 'twitter:%s' % filter_string[1:]
     else:
         username = filter_string
         
     logging.info('looking up commits for user: %s', username)
     user = User.get_by_auth_id(username)
     if user is None:
         abort(404)
         
     return self.model.query(ancestor=user.key)
開發者ID:digideskio,項目名稱:julython.org,代碼行數:20,代碼來源:api.py

示例14: create_by_auth_id

# 需要導入模塊: from gae_django.auth.models import User [as 別名]
# 或者: from gae_django.auth.models.User import get_by_auth_id [as 別名]
 def create_by_auth_id(cls, auth_id, commits, project=None):
     user = User.get_by_auth_id(auth_id)
     if user:
         return cls.create_by_user(user, commits, project=project)
     return cls.create_orphan(commits, project=project)
開發者ID:digideskio,項目名稱:julython.org,代碼行數:7,代碼來源:models.py

示例15: test_project_url

# 需要導入模塊: from gae_django.auth.models import User [as 別名]
# 或者: from gae_django.auth.models.User import get_by_auth_id [as 別名]
 def test_project_url(self):
     user = self.make_user('marcus')
     user.add_auth_id('email:[email protected]')
     self.app.post('/api/v1/bitbucket', self.POST)
     user = User.get_by_auth_id('email:[email protected]')
     self.assertTrue('https://some.other.org/marcus/project-x/' in user.projects)
開發者ID:ChrisOelmueller,項目名稱:julython.org,代碼行數:8,代碼來源:test_api.py


注:本文中的gae_django.auth.models.User.get_by_auth_id方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。