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


Python Team.get_by_uid方法代碼示例

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


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

示例1: card_info

# 需要導入模塊: from vilya.models.team import Team [as 別名]
# 或者: from vilya.models.team.Team import get_by_uid [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

示例2: settings

# 需要導入模塊: from vilya.models.team import Team [as 別名]
# 或者: from vilya.models.team.Team import get_by_uid [as 別名]
    def settings(self, request):
        user = request.user
        team = Team.get_by_uid(self.team_uid)
        if not team:
            raise TraversalError
        projects = team.projects

        input_uid = request.get_form_var("uid", "")
        input_name = request.get_form_var("name", "")
        input_description = request.get_form_var("description", "")

        error = ""
        if request.method == "POST":
            if not user:
                return request.redirect("/")

            if not team.is_owner(user.name):
                return request.redirect(team.url)

            teams = Team.gets()
            team_uid_pattern = re.compile(r"[a-zA-Z0-9\_]*")
            if not input_uid:
                error = "uid_not_exists"
            elif not input_name:
                error = "name_not_exists"
            elif input_uid != re.findall(team_uid_pattern, input_uid)[0]:
                error = "invilid_uid"
            elif input_uid in [t.uid for t in teams] and team.uid != input_uid:
                error = "uid_existed"
            elif input_name in [t.name for t in teams] and team.name != input_name:
                error = "name_existed"
            else:
                team.update(input_uid, input_name, input_description)
                return request.redirect("/hub/team/%s/settings" % input_uid)
        return st("/teams/team_settings.html", **locals())
開發者ID:leeccong,項目名稱:code,代碼行數:37,代碼來源:team.py

示例3: add_user

# 需要導入模塊: from vilya.models.team import Team [as 別名]
# 或者: from vilya.models.team.Team import get_by_uid [as 別名]
    def add_user(self, request):
        user = request.user
        team = Team.get_by_uid(self.team_uid)
        if not user or not team:
            return dict(r=1, error="team不存在")

        user_id = request.get_form_var("user_id", "")
        identity = int(request.get_form_var("identity", 0))

        if not team.is_owner(user.name) or identity not in TEAM_IDENTITY_INFO.keys():
            return dict(r=1, error="沒有權限")

        rl = TeamUserRelationship.get(team_id=team.id, user_id=user_id)
        if not rl:
            team.add_user(User(user_id), identity)
        elif identity == rl.identity:
            return dict(r=1, error="該用戶已存在")
        elif rl.is_owner and team.n_owners == 1:
            return dict(r=1, error="隻剩一個creator, 不能改變身份")
        else:
            rl.identity = identity
            rl.save()

        avatar_url = User(user_id).avatar_url
        team_add_member_signal.send(
            user.name,
            team_uid=team.uid,
            team_name=team.name,
            receiver=user_id,
            identity=TEAM_IDENTITY_INFO[identity]["name"],
        )
        return dict(r=0, uid=user_id, avatar_url=avatar_url)
開發者ID:leeccong,項目名稱:code,代碼行數:34,代碼來源:team.py

示例4: _get_team_by_uid

# 需要導入模塊: from vilya.models.team import Team [as 別名]
# 或者: from vilya.models.team.Team import get_by_uid [as 別名]
def _get_team_by_uid(uid):
    _team = Team.get_by_uid(uid)
    team = dict(
        id=_team.id,
        uid=_team.uid,
        name=_team.name,
    )
    return team
開發者ID:000fan000,項目名稱:code,代碼行數:10,代碼來源:timeline.py

示例5: leave

# 需要導入模塊: from vilya.models.team import Team [as 別名]
# 或者: from vilya.models.team.Team import get_by_uid [as 別名]
    def leave(self, request):
        user = request.user
        team = Team.get_by_uid(self.team_uid)
        if not user or not team:
            return dict(r=1)

        team.remove_user(user)
        return dict(r=0)
開發者ID:leeccong,項目名稱:code,代碼行數:10,代碼來源:team.py

示例6: __init__

# 需要導入模塊: from vilya.models.team import Team [as 別名]
# 或者: from vilya.models.team.Team import get_by_uid [as 別名]
    def __init__(self, team_uid, issue_number):
        self.target = Team.get_by_uid(team_uid)
        self.issue_number = issue_number

        team_issue = TeamIssue.get(self.target.id, number=self.issue_number)
        self.issue_id = team_issue.issue_id
        self.issue = Issue.get_cached_issue(self.issue_id)
        self.issue_template = "issue/team_issue.html"
開發者ID:leeccong,項目名稱:code,代碼行數:10,代碼來源:team.py

示例7: judge_user

# 需要導入模塊: from vilya.models.team import Team [as 別名]
# 或者: from vilya.models.team.Team import get_by_uid [as 別名]
def judge_user(name):
    from vilya.models.team import Team
    if CodeUser.get(name=name):
        return "people"
    else:
        if Team.get_by_uid(name):
            return "team"
        else:
            return "people"
開發者ID:000fan000,項目名稱:code,代碼行數:11,代碼來源:user.py

示例8: join

# 需要導入模塊: from vilya.models.team import Team [as 別名]
# 或者: from vilya.models.team.Team import get_by_uid [as 別名]
    def join(self, request):
        user = request.user
        team = Team.get_by_uid(self.team_uid)
        if not user or not team:
            return dict(r=1)

        team.add_user(user, TEAM_MEMBER)
        team_joined_signal.send(user.name, team_id=team.id, team_uid=team.uid, team_name=team.name)
        return dict(r=0)
開發者ID:leeccong,項目名稱:code,代碼行數:11,代碼來源:team.py

示例9: _q_index

# 需要導入模塊: from vilya.models.team import Team [as 別名]
# 或者: from vilya.models.team.Team import get_by_uid [as 別名]
 def _q_index(self, request):
     user = request.user
     team = Team.get_by_uid(self.team_uid)
     if not team:
         raise TraversalError
     projects = team.projects
     is_admin = False
     if user and team.is_owner(user.name):
         is_admin = True
     return st("/teams/team.html", **locals())
開發者ID:leeccong,項目名稱:code,代碼行數:12,代碼來源:team.py

示例10: _q_lookup

# 需要導入模塊: from vilya.models.team import Team [as 別名]
# 或者: from vilya.models.team.Team import get_by_uid [as 別名]
 def _q_lookup(self, request, num):
     if not num.isdigit():
         raise TraversalError
     num = int(num)
     team = Team.get_by_uid(self.team_uid)
     actions = get_team_feed(team.id).get_actions(start=num,
                                                  stop=num+PAGE_ACTIONS_COUNT-1)
     length = len(actions)
     render_html = render_actions(actions, show_avatar=True)
     return {'result': render_html, 'length': length}
開發者ID:000fan000,項目名稱:code,代碼行數:12,代碼來源:team.py

示例11: remove

# 需要導入模塊: from vilya.models.team import Team [as 別名]
# 或者: from vilya.models.team.Team import get_by_uid [as 別名]
    def remove(self, request):
        team = Team.get_by_uid(self.team_uid)
        if not team:
            return dict(r=1)

        user = request.user
        if not user or not team.is_owner(user.name):
            return dict(r=1)

        team.delete()
        return {"r": 0}
開發者ID:leeccong,項目名稱:code,代碼行數:13,代碼來源:team.py

示例12: news

# 需要導入模塊: from vilya.models.team import Team [as 別名]
# 或者: from vilya.models.team.Team import get_by_uid [as 別名]
 def news(self, request):
     user = request.user
     team = Team.get_by_uid(self.team_uid)
     if not team:
         raise TraversalError
     feed = get_team_feed(team.id)
     actions = feed.get_actions(stop=PAGE_ACTIONS_COUNT - 1)
     projects = team.projects
     is_admin = False
     if user and team.is_owner(user.name):
         is_admin = True
     return st("/teams/news.html", **locals())
開發者ID:leeccong,項目名稱:code,代碼行數:14,代碼來源:team.py

示例13: destroy

# 需要導入模塊: from vilya.models.team import Team [as 別名]
# 或者: from vilya.models.team.Team import get_by_uid [as 別名]
 def destroy(self, request):
     project = self.project
     group_name = request.get_form_var('group', '')
     if not group_name:
         return request.redirect("%ssettings/" % project.url)
     team, _, group = group_name.rpartition('/')
     t = Team.get_by_uid(team)
     if not t:
         return request.redirect("%ssettings/" % project.url)
     g = TeamGroup.get(team_id=t.id, name=group)
     if not g:
         return request.redirect("%ssettings/" % project.url)
     g.remove_project(project_id=project.id)
     return request.redirect("%ssettings/" % project.url)
開發者ID:000fan000,項目名稱:code,代碼行數:16,代碼來源:settings.py

示例14: remove_project

# 需要導入模塊: from vilya.models.team import Team [as 別名]
# 或者: from vilya.models.team.Team import get_by_uid [as 別名]
    def remove_project(self, request):
        user = request.user
        team = Team.get_by_uid(self.team_uid)
        if not user or not team:
            return dict(r=1)

        if not team.is_owner(user.name):
            return dict(r=1)

        project_name = request.get_form_var("project_name", "")
        project = CodeDoubanProject.get_by_name(project_name)
        if not project:
            return dict(r=1)

        team.remove_project(project)
        return dict(r=0)
開發者ID:leeccong,項目名稱:code,代碼行數:18,代碼來源:team.py

示例15: upload_profile

# 需要導入模塊: from vilya.models.team import Team [as 別名]
# 或者: from vilya.models.team.Team import get_by_uid [as 別名]
    def upload_profile(self, request):
        user = request.user
        team = Team.get_by_uid(self.team_uid)
        if not user and not team:
            return dict(r=1)
        if team and not team.is_owner(user.name):
            return dict(r=1)

        upload_url = request.get_form_var("url", "")
        hash_png = request.get_form_var("hash", "")
        profile = {"origin": upload_url}
        if upload_url and hash_png:
            rsize_url = "{0}/r/{1}?w=100&h=100".format(UPLOAD_URL, hash_png)
            r = requests.get(rsize_url)
            r.raise_for_status()
            profile.update({"icon": r.text})
        team.profile = profile
        return dict(r=0)
開發者ID:leeccong,項目名稱:code,代碼行數:20,代碼來源:team.py


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