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


Python user.User类代码示例

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


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


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