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