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


Python User.select方法代码示例

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


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

示例1: group

# 需要导入模块: from streetsign_server.models import User [as 别名]
# 或者: from streetsign_server.models.User import select [as 别名]
def group(groupid):
    ''' edit one user group. '''

    try:
        thisgroup = Group.get(id=groupid)
    except:
        flash('Invalid group ID')
        return redirect(request.referrer if request.referrer else '/')

    if request.method == 'POST':
        if request.form.get('action', 'none') == 'delete':
            UserGroup.delete().where(UserGroup.group == thisgroup).execute()
            thisgroup.delete_instance()
            flash('group:'+ thisgroup.name +' deleted.')
            return redirect(url_for('users_and_groups'))

        if request.form.get('action', 'none') == 'update':
            thisgroup.name = request.form.get('groupname', thisgroup.name)
            thisgroup.save()

            groupusers = request.form.getlist('groupusers')
            thisgroup.set_users(groupusers)
            flash('saved')

    return render_template('group.html', group=thisgroup, allusers=User.select())
开发者ID:Fivebread,项目名称:streetsign,代码行数:27,代码来源:users_and_auth.py

示例2: feedpage

# 需要导入模块: from streetsign_server.models import User [as 别名]
# 或者: from streetsign_server.models.User import select [as 别名]
def feedpage(feedid):
    ''' the back end settings for one feed. '''

    try:
        feed = Feed.get(id=feedid)
        user = user_session.get_user()
    except user_session.NotLoggedIn:
        user = User()
    except:
        flash('invalid feed id! (' + str(feedid) + ')')
        return redirect(url_for('feeds'))

    if request.method == 'POST':
        if not user_session.logged_in():
            flash("You're not logged in!")
            return redirect(url_for('feeds'))

        if not user.is_admin:
            flash('Sorry! Only Admins can change these details.')
            return redirect(request.referrer)

        action = request.form.get('action', 'none')

        if action == 'edit':
            feed.name = request.form.get('title', feed.name).strip()

            inlist = request.form.getlist

            feed.post_types = ', '.join(inlist('post_types'))

            feed.set_authors(by_id(User, inlist('authors')))
            feed.set_publishers(by_id(User, inlist('publishers')))
            feed.set_author_groups(by_id(Group, inlist('author_groups')))
            feed.set_publisher_groups(by_id(Group, inlist('publisher_groups')))

            feed.save()
            flash('Saved')
        elif action == 'delete':

            for post in feed.posts:
                post_type_module = post_types.load(post.type)
                delete_post_and_run_callback(post, post_type_module)

            feed.delete_instance(True, True) # cascade/recursive delete.
            flash('Deleted')
            return redirect(url_for('feeds'))

    return render_template('feed.html',
                           feed=feed,
                           user=user,
                           all_posttypes=post_types.types(),
                           allusers=User.select(),
                           allgroups=Group.select()
                          )
开发者ID:Fivebread,项目名称:streetsign,代码行数:56,代码来源:feeds_and_posts.py

示例3: users_and_groups

# 需要导入模块: from streetsign_server.models import User [as 别名]
# 或者: from streetsign_server.models.User import select [as 别名]
def users_and_groups():
    ''' list of all users and groups (HTML page). '''

    if request.method == 'POST':
        action = request.form.get('action', 'creategroup')

        if action == 'creategroup':
            if not request.form.get('name', '').strip():
                flash("I'm not making you an un-named group!")
                return redirect(url_for('users_and_groups'))

            Group.create(name=request.form.get('name', 'blank').strip())


    return render_template('users_and_groups.html',
                           users=User.select(),
                           groups=Group.select())
开发者ID:Fivebread,项目名称:streetsign,代码行数:19,代码来源:users_and_auth.py

示例4: test_users_none

# 需要导入模块: from streetsign_server.models import User [as 别名]
# 或者: from streetsign_server.models.User import select [as 别名]
 def test_users_none(self):
     self.assertEqual(User.select().count(), 0)
开发者ID:Fivebread,项目名称:streetsign,代码行数:4,代码来源:test_models_user.py


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