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


Python Group.lookup_by_attribute方法代码示例

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


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

示例1: group_edit_view

# 需要导入模块: from models import Group [as 别名]
# 或者: from models.Group import lookup_by_attribute [as 别名]
def group_edit_view(request):
    """returns current group information for editing and then collects
    all information that has been added by the user whether new or existing
    and edits the existing entries.
    """
    username = request.authenticated_userid
    group = Group.lookup_by_attribute(name=request.matchdict['group_name'])[0]
    criteria = Criteria.lookup_by_attribute(group=group)[0]
    if request.method == 'POST':
        criteria = Criteria.edit(location=request.params.getall('location'),
                                 taste=request.params.getall('taste'),
                                 diet=request.params.getall('diet'),
                                 cost=request.params.getall('cost'),
                                 age=request.params.getall('age'),
                                 id=criteria.id)
        group = Group.edit(name=request.params.get('name'),
                           description=request.params.get('description'),
                           id=group.id)
        return HTTPFound(request.route_url('group_detail',
                                           group_name=group.name))

    profile = {}
    profile['criteria'] = criteria
    profile['group'] = group
    profile['username'] = username

    return profile
开发者ID:kaka0525,项目名称:taste-buddies,代码行数:29,代码来源:views.py

示例2: group_detail_view

# 需要导入模块: from models import Group [as 别名]
# 或者: from models.Group import lookup_by_attribute [as 别名]
def group_detail_view(request):
    """returns current group information.  If recievng input form a form
    will add that user as a group member if they aren't already.  Will look
    to see whether a new discussion is being created and if so, add it
    to the group forum.  If a new post on an existing discussion is created
    that post will be added to the appropriate discussion.  Discussions
    are returned in reverse order.
    """
    username = request.authenticated_userid
    group = Group.lookup_by_attribute(name=request.matchdict['group_name'])[0]
    criteria = Criteria.lookup_by_attribute(group=group)[0]
    if request.method == 'POST':
        user = User.lookup_by_attribute(username=username)[0]
        user.groups.append(group)
        time = datetime.datetime.utcnow()
        if request.params.get('title'):
            title = request.params.get('title')
            group.forum[title] = [(request.params.get('post'), username, time)]
            group.edit(id=group.id, forum=group.forum)
        else:
            title = request.params.items()[0][0]
            post = request.params.items()[0][1]
            group.forum[title].append((post, username, time))
            group.edit(id=group.id, forum=group.forum)
        return HTTPFound(request.route_url(
                         'group_detail',
                         group_name=request.matchdict['group_name'],
                         ))
    profile = {}
    forum = OrderedDict()
    for _ in range(len(group.forum)):
        to_add = group.forum.popitem()
        forum[to_add[0]] = to_add[1]
    profile['forum'] = forum
    profile['criteria'] = criteria
    profile['group'] = group
    profile['username'] = username
    return profile
开发者ID:kaka0525,项目名称:taste-buddies,代码行数:40,代码来源:views.py


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