当前位置: 首页>>代码示例>>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;未经允许,请勿转载。