当前位置: 首页>>代码示例>>Python>>正文


Python Team.save方法代码示例

本文整理汇总了Python中models.team.Team.save方法的典型用法代码示例。如果您正苦于以下问题:Python Team.save方法的具体用法?Python Team.save怎么用?Python Team.save使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在models.team.Team的用法示例。


在下文中一共展示了Team.save方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: create_client

# 需要导入模块: from models.team import Team [as 别名]
# 或者: from models.team.Team import save [as 别名]
def create_client(user, params):
    name = params.get("name", "")
    if not name or len(name) > 30:
        return {"error_code":20251, "msg":"name invalid"}

    #team = Team.select().where(Team.user == user, Team.name == name).first()
    team = Team.select().where(Team.user == user).first()
    if team:
        return {"error_code":20252, "msg":"team is exists and must one"}

    team_id = GUID.guid()
    team = Team()
    team.id = team_id
    team.user = user
    team.name = name
    team.status = "normal"
    team.team_type = 'client'
    team.logo = widget.logo()
    team.save(force_insert=True)

    user.to_req = True
    user.identify = "c%s" % team.id
    user.save()

    team_profile = TeamProfile()
    team_profile.team = team
    team_profile.save()

    #Member.create(user=user, team=team, mtype='owner')
    return {"error_code":0, "msg":"ok"}
开发者ID:wdvill,项目名称:cloud_admin,代码行数:32,代码来源:user.py

示例2: _process_project

# 需要导入模块: from models.team import Team [as 别名]
# 或者: from models.team.Team import save [as 别名]
 def _process_project(self, project):
     team = Team.objects(team_id=project.namespace.id).first()
     # We reset team statistics when we first encounter it
     if team and project.namespace.id not in self.teams_seen:
         team.delete()
         team = None
         self.teams_seen.add(project.namespace.id)
     if not team:
         team = Team(team_id=project.namespace.id)
     for (lang, total) in self._lang_stats(project).items():
         if lang in team.languages:
             team.languages[lang] += total
         else:
             team.languages[lang] = total
     team.save()
开发者ID:globocom,项目名称:vitrine,代码行数:17,代码来源:worker.py

示例3: post

# 需要导入模块: from models.team import Team [as 别名]
# 或者: from models.team.Team import save [as 别名]
    def post(self, *args, **kwargs):
        if 'user' not in kwargs or args:
            self.raise401()
        name = self.get_argument('name', None)
        description = self.get_argument('description', None)
        url = self.get_argument('url', None)
        leader = self.get_argument('leader', None)
        members = self.get_argument('members', None)
        tags = self.get_argument('tags', None)

        try:
            # todo - better arguments handler
            url = url.strip()
            url = url if url else None
            members_list = []
            team_leader = kwargs['user']
            if leader:
                team_leader = User.objects(username=leader).first()
            if members:
                for member in parse_listed_strs(members):
                    u = User.objects(username=member).first()
                    if not u or u == team_leader:
                        continue
                    members_list.append(u)
            members_list.append(team_leader)
            tags_list = parse_listed_strs(tags)
            team = Team(
                name=name, description=description,
                url=url, leader=team_leader,
                members=members_list, tags=tags_list)
            team.save()
            team_data = document_to_json(team, filter_set=_FILTER)
            self.set_status(201)
            self.write(team_data)
        except Exception as e:
            reason = e.message
            self.raise400(reason=reason)
开发者ID:hitigon,项目名称:warehouse,代码行数:39,代码来源:team.py

示例4: register

# 需要导入模块: from models.team import Team [as 别名]
# 或者: from models.team.Team import save [as 别名]
def register(params, device):
    rtype = params.get('rtype', None)
    name = params.get('name', None)
    phone = params.get('phone', None)
    password = params.get('password', None)
    vcode = params.get('vcode', None)
    uname = params.get('username', '')
    cname = params.get('cname', '')
    notice = params.get('notice', "true")

    if not phone or not password or not vcode or not name or not rtype or not notice or not rtype.isdigit():
        return {"error_code":20021, "msg":"parameters required"}

    rtype = int(rtype)
    if not validate.is_phone(phone):
        return {"error_code":20022, "msg":"phone invalid"}

    # freelancer: 1, client: 2, client_person: 3
    if rtype not in [1, 2, 3]:
        return {"error_code":20022, "msg":"user type invalid"}

    if rtype == 2 and not cname or len(cname) > 100:
        return {"error_code":20022, "msg":"user type invalid or cname too long"}

    if not validate.is_verify_code(vcode):
        return {"error_code":20024, "msg":"verify code invalid"}
    
    if User.select().where(User.phone == phone).first():
        return {"error_code":20025, "msg":"user is exists"}

    if rtype != 1:
        username = phone
    else:
        # freelancer do not use username, just use phone to register
        # username = uname
        username = phone
    
    if not utils.is_username(username):
        return {"error_code":20023, "msg":"username invalid"}

    if User.select().where(User.username == username).first():
        return {"error_code":20025, "msg":"user is exists"}

    res = verify_code(phone=phone, code=vcode)
    if res['error_code'] != 0:
        return res
    
    user_id = GUID.guid()
    team_id = GUID.guid()
    with database.atomic() as txn:
        try:
            pwd, salt = generate_password(password.encode('utf-8'))
            user = User()
            user.id = user_id
            user.username = username
            user.password = pwd
            user.salt = salt
            user.phone = phone
            #user.verifycode = vcode
            user.save(force_insert=True)

            profile = Profile()
            profile.user = user
            profile.name = name
            profile.avatar = widget.avatar()

            if notice == "true":
                profile.is_notice = True
            profile.save()

            party = Party()
            party.user = user
            party.vip = False
            party.connects = 60
            party.agency_connects = 60
            party.save()

            margin = Margin()
            margin.user = user
            margin.save()

            if rtype == 1:
                user.identify = 'f%s' % user.id
                user.app_identify = 'f%s' % user.id
                user.status = "unactive"
                user.to_dev = True
                user.to_req = False
                user.save()

                queue.to_queue({"type":"user_register", "user_id":user.id})
            else:
                team = Team()
                team.id = team_id
                team.user = user
                if rtype == 2:
                    team.name = cname
                else:
                    team.name = "个人需求方"
                team.team_type = 'client'
                team.status = "normal"
#.........这里部分代码省略.........
开发者ID:wdvill,项目名称:cloud_admin,代码行数:103,代码来源:user.py


注:本文中的models.team.Team.save方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。