• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python user.User类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中vilya.models.user.User的典型用法代码示例。如果您正苦于以下问题:Python User类的具体用法?Python User怎么用?Python User使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



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

示例1: _q_index

def _q_index(request):
    context = {}
    if request.method == "POST":
        name = request.get_form_var('name')
        password = request.get_form_var('password')
        email = request.get_form_var('email')
        description = request.get_form_var('description')

        # Forced mail format must be correct
        if not _validate_email(email):
            context['name'] = name
            context['not_validate_email'] = True
            context['password'] = password
            context['email'] = email
            context['description'] = description
            return st('users/new.html', **context)

        user = User.add(name=name,
                        password=password,
                        description=description,
                        email=email)
        if user:
            context['user'] = user
            user.set_session(request)
            request.user = user
            return request.redirect('/')
    users = User.gets_by()
    context['users'] = users
    return st('users/index.html', **context)
开发者ID:377262688,项目名称:code,代码行数:29,代码来源:__init__.py


示例2: test_get_user_new_badges

 def test_get_user_new_badges(self):
     user = User("qingfeng")
     with new_badge(user.username) as badge:
         badge.award(item_id=user.username)
         eq_(len(user.get_new_badges()), 1)
         user.clear_new_badges()
         eq_(len(user.get_new_badges()), 0)
开发者ID:sdgdsffdsfff,项目名称:code-1,代码行数:7,代码来源:test_badge.py


示例3: card_info

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,代码行数:30,代码来源:__init__.py


示例4: _q_index

def _q_index(request):
    context = {}
    if request.method == "POST":
        name = request.get_form_var("name")
        password = request.get_form_var("password")
        email = request.get_form_var("email")
        description = request.get_form_var("description")

        # Forced mail format must be correct
        if not _validate_email(email):
            context["name"] = name
            context["not_validate_email"] = True
            context["password"] = password
            context["email"] = email
            context["description"] = description
            return st("users/new.html", **context)

        user = User.add(name=name, password=password, description=description, email=email)
        if user:
            context["user"] = user
            user.set_session(request)
            request.user = user
            return request.redirect("/")
    users = User.gets_by()
    context["users"] = users
    return st("users/index.html", **context)
开发者ID:leeccong,项目名称:code,代码行数:26,代码来源:__init__.py


示例5: irc_receiver_filter

 def irc_receiver_filter(receivers, target):
     from vilya.models.user import User
     rs = set()
     for receiver in receivers:
         user = User(receiver)
         if user and user.notify_irc(target):
             rs.add(receiver)
     return rs
开发者ID:000fan000,项目名称:code,代码行数:8,代码来源:irc.py


示例6: test_user_with_email_from_outside_douba

 def test_user_with_email_from_outside_douba(self):
     u = User('testu', '[email protected]')
     assert u.name == 'testu'
     assert 'douvatar' in u.avatar_url
     assert u.get_badges() == []
     assert u.email == '[email protected]'
     assert u.username == 'testu'
     assert u.url == '/people/testu/'
开发者ID:000fan000,项目名称:code,代码行数:8,代码来源:test_user.py


示例7: test_simple_user

 def test_simple_user(self):
     u = User('testu')
     assert u.name == 'testu'
     assert 'douvatar' in u.avatar_url
     assert u.get_badges() == []
     assert u.email == '[email protected]'
     assert u.username == 'testu'
     assert u.url == '/people/testu/'
开发者ID:000fan000,项目名称:code,代码行数:8,代码来源:test_user.py


示例8: add_participant

    def add_participant(self, username):
        participants = self.participants
        if username and username not in participants:
            participants.append(username)
            self.set_props_item('participants', participants)

            user = User(username)
            user.add_participated_pull_request(self.id)
        return self.participants
开发者ID:leeccong,项目名称:code,代码行数:9,代码来源:ticket.py


示例9: addrs_by_usernames

 def addrs_by_usernames(usernames, target=None):
     addrs = set()
     for username in usernames:
         user = User(username) if username else None
         if user:
             if (target and user.notify_email(target)) or not target:
                 addrs.add(user.email)
                 addrs = addrs.union(user.settings.notif_other_emails)
     return addrs
开发者ID:000fan000,项目名称:code,代码行数:9,代码来源:mailer.py


示例10: run

    def run(self):
        while True:
            username = raw_input('username(%s): ' % getpass.getuser())
            if username == '': 
                username = getpass.getuser()
            if not re.match(r'[A-Za-z\.0-9]+', username):
                print 'Invalid Username'
            else: break
        while True:
            email = raw_input('email: ')
            if not re.match(r'[A-Za-z\.0-9\+][email protected]\w+(\.\w+)*', email):
                print 'Invalid email'
            else: break
        while True:
            passwd = getpass.getpass('password: ')
            rpasswd = getpass.getpass('repeat: ')
            if passwd != rpasswd:
                print 'Password not matching!'
            else: break

        from vilya.models.user import User
        user = User()
        user.username = username
        user.email = email
        user.admin = True
        user.active = True
        user.set_password(passwd)
        user.save()
        print 'Super user created!'
开发者ID:shanzi,项目名称:code-vilya,代码行数:29,代码来源:admin.py


示例11: _q_index

 def _q_index(self, request):
     name = self.name
     your_projects = CodeDoubanProject.get_projects(owner=name, sortby="lru")
     actions = get_user_feed(name).get_actions(0, 20)
     user = User(name)
     teams = Team.get_by_user_id(user.name)
     badge_items = user.get_badge_items()
     followers_count = user.followers_count
     following_count = user.following_count
     if user and user.username == name and user.get_new_badges():
         user.clear_new_badges()
     return st("people.html", **locals())
开发者ID:leeccong,项目名称:code,代码行数:12,代码来源:people.py


示例12: test_get_user_submitted_pull_requests

    def test_get_user_submitted_pull_requests(self):
        title = 'test title'
        desc = 'test desc'
        u = User('testu%s' % time.time())
        p1_t1 = Ticket.add(self.proj1.id, title, desc, u.username)
        assert u.get_user_submit_pull_requests() != []
        assert u.n_user_open_submit_pull_requests == 1

        p1_t1.close('testuser')
        assert u.get_user_submit_pull_requests() == []
        assert u.n_user_open_submit_pull_requests == 0

        assert u.n_open_pull_requests == 0
开发者ID:leeccong,项目名称:code,代码行数:13,代码来源:test_user_pull_requests.py


示例13: get_related_user_inbox_feeds

 def get_related_user_inbox_feeds(self):
     ''' user_timeline of actor, actor's followers, project owner,
         project's watchers, extra_receivers '''
     sender = User(self._sender)
     followers = sender.get_followers() if sender else []
     project = self._project
     if project:
         proj_users = [u.username for u in project.get_watch_users()]
         proj_users.append(project.owner.username)
     else:
         proj_users = []
     receivers = {self._sender} | set(followers) | set(proj_users) | self._receivers  # noqa
     return [get_user_inbox(r) for r in receivers]
开发者ID:leeccong,项目名称:code,代码行数:13,代码来源:feed.py


示例14: get_git_path_info

def get_git_path_info(path):
    path_split = path.split("/")
    git_name = path_split[1]
    # raw path: project_id.git
    if git_name.endswith('.git'):
        project = Project.get_by_name(git_name[:-4])
        if project:
            path_split[1] = "%s.git" % project.id
            return '/'.join(path_split)
    else:
        owner_name, git_name = path_split[1:3]
        # user project: user/project.git
        user = User.get_by_name(owner_name)
        if user:
            project = Project.get_by_name_and_owner(git_name[:-4], user.id)
            if project:
                path_split[1] = ""
                path_split[2] = "%s.git" % project.id
                return '/'.join(path_split[1:])
            return
        # org project: org/project.git
        org = Organization.get_by_name(owner_name)
        if org:
            project = Project.get_by_name_and_owner(git_name[:-4], user.id)
            if project:
                path_split[1] = ""
                path_split[2] = "%s.git" % project.id
                return '/'.join(path_split[1:])
开发者ID:377262688,项目名称:code,代码行数:28,代码来源:smart_httpd.py


示例15: add_team

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,代码行数:35,代码来源:__init__.py


示例16: check_permission

 def check_permission(self, request, proj_name):
     project = CodeDoubanProject.get_by_name(proj_name)
     user = request.user
     if not project or \
        not user and project.intern_banned or \
        user and user.is_intern and project.intern_banned \
        and not project.is_admin(user.username):
         return request.redirect(User.create_login_url(request.url))
开发者ID:000fan000,项目名称:code,代码行数:8,代码来源:__init__.py


示例17: owner_name

 def owner_name(self):
     from vilya.models.user import User
     from vilya.models.organization import Organization
     if self.kind == KIND_USER:
         user = User.get_by(id=self.owner_id)
         return user.name
     else:
         org = Organization.get_by(id=self.owner_id)
         return org.name
开发者ID:377262688,项目名称:code,代码行数:9,代码来源:project.py


示例18: __token_grant_by_password

def __token_grant_by_password(apikey):
    username = __check_request_required_var('username')
    password = __check_request_required_var('password')
    user = User.get_by_name(username)
    if not DEVELOP_MODE and user and not user.validate_password(password):
        raise InvalidRequest(err.username_password_mismatch)

    token = ApiToken.add(apikey.client_id, username)
    return json.dumps(token.token_dict())
开发者ID:000fan000,项目名称:code,代码行数:9,代码来源:oauth.py


示例19: _q_lookup

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,代码行数:9,代码来源:__init__.py


示例20: api_list_user

def api_list_user(users):
    rs = []
    for username in users:
        user = User.get_by_name(username)
        rs.append({'username': user.username,
                   'avatar_url': user.avatar_url,
                   'email': user.email,
                   'url': user.url, })
    return rs
开发者ID:377262688,项目名称:code,代码行数:9,代码来源:utils.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python visvis.clf函数代码示例发布时间:2022-05-27
下一篇:
Python vecutil.list2vec函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap