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


Python User.check_exist方法代碼示例

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


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

示例1: add_team

# 需要導入模塊: from vilya.models.user import User [as 別名]
# 或者: from vilya.models.user.User import check_exist [as 別名]
def add_team(request):
    user = request.user
    if not user:
        return request.redirect("/")

    uid = request.get_form_var('uid') or ''
    name = request.get_form_var('name') or ''
    description = request.get_form_var('description') or ''

    errors = ""
    if request.method == "POST":
        teams = Team.gets()
        team_uid_pattern = re.compile(r'[a-zA-Z0-9\_]*')
        if not uid:
            error = 'uid_not_exists'
        elif not name:
            error = 'name_not_exists'
        elif uid != re.findall(team_uid_pattern, uid)[0]:
            error = 'invilid_uid'
        elif uid in [team.uid for team in teams]:
            error = 'uid_existed'
        elif User.check_exist(uid):
            error = 'user_id_existed'
        elif name in [team.name for team in teams]:
            error = 'name_existed'
        else:
            team = Team.add(uid, name, description)
            if team:
                team_created_signal.send(user.name,
                                         team_name=team.name,
                                         team_uid=team.uid)
                team.add_user(user, TEAM_OWNER)
                return request.redirect(team.url)

    return st('/teams/add_team.html', **locals())
開發者ID:000fan000,項目名稱:code,代碼行數:37,代碼來源:__init__.py

示例2: card_info

# 需要導入模塊: from vilya.models.user import User [as 別名]
# 或者: from vilya.models.user.User import check_exist [as 別名]
def card_info(request):
    user_or_team_id = request.get_form_var('user')
    team = Team.get_by_uid(user_or_team_id)
    user_existed = User.check_exist(user_or_team_id)
    if not team or user_existed:
        user = User(user_or_team_id)
        data = {
            'user': {'name': user_or_team_id, 'avatar': user.avatar_url,
                     'url': user.url,
                     'badges': [{'img': item.badge.get_image_url(),
                                 'name': item.badge.name,
                                 'reason': item.reason or item.badge.summary}
                                for item in user.get_badge_items()]}
        }
    else:
        members = team.user_ids[::-1]  # 根據團隊的時間排序
        displayed_users = [User(uid) for uid in team.user_ids[:8]]
        data = {
            'team': {
                'id': team.uid,
                'name': team.name,
                'url': team.url,
                'desc': team.short_description,
                'profile_url': team.profile_url(),
                'members': [{'uid': u.name, 'avatar_url': u.avatar_url}
                            for u in displayed_users],
                'member_count': len(members)
            }
        }
    return json.dumps(data)
開發者ID:000fan000,項目名稱:code,代碼行數:32,代碼來源:__init__.py

示例3: _q_lookup

# 需要導入模塊: from vilya.models.user import User [as 別名]
# 或者: from vilya.models.user.User import check_exist [as 別名]
def _q_lookup(request, name):
    if name == 'static':
        return StaticUI(request)
    if name == 'fair':
        return FairUI(request)
    if CodeDoubanProject.exists(name):
        return CodeUI(name)
    if User.check_exist(name):
        return UserPrefixedRepoAdapter(name)
開發者ID:000fan000,項目名稱:code,代碼行數:11,代碼來源:__init__.py

示例4: people

# 需要導入模塊: from vilya.models.user import User [as 別名]
# 或者: from vilya.models.user.User import check_exist [as 別名]
 def people(self, request):
     current_user = request.user
     badge = self.badge
     if not current_user:
         return request.redirect("/badge/%s/" % badge.id)
     if current_user.name not in ["liwanjin", "xutao"]:
         return request.redirect("/badge/%s/" % badge.id)
     if request.method != "POST":
         return request.redirect("/badge/%s/" % badge.id)
     name = request.get_form_var("name")
     reason = request.get_form_var("reason")
     if not name:
         return request.redirect("/badge/%s/" % badge.id)
     if not User.check_exist(name):
         return request.redirect("/badge/%s/" % badge.id)
     badge.award(name, reason=reason)
     return request.redirect("/badge/%s/" % badge.id)
開發者ID:leeccong,項目名稱:code,代碼行數:19,代碼來源:badge.py

示例5: _q_lookup

# 需要導入模塊: from vilya.models.user import User [as 別名]
# 或者: from vilya.models.user.User import check_exist [as 別名]
 def _q_lookup(self, request, alias):
     if User.check_exist(alias):
         return PullsByAuthorUI(self.proj_name, alias)
     raise TraversalError
開發者ID:000fan000,項目名稱:code,代碼行數:6,代碼來源:pull.py


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