本文整理汇总了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)
示例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())
示例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)
示例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
示例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)
示例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"
示例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"
示例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)
示例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())
示例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}
示例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}
示例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())
示例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)
示例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)
示例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)