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


Python model.Groups类代码示例

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


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

示例1: view

    def view(self, groupname, order_by='username'):
        '''View group'''
        sort_map = { 'username': 'people_1.username',
            'creation': 'person_roles_creation',
            'approval': 'person_roles_approval',
            'role_status': 'person_roles_role_status',
            'role_type': 'person_roles_role_type',
            'sponsor': 'people_2.username',
            }
        username = turbogears.identity.current.user_name
        person = People.by_username(username)
        group = Groups.by_name(groupname)

        if not can_view_group(person, group):
            turbogears.flash(_("You cannot view '%s'") % group.name)
            turbogears.redirect('/group/list')
            return dict()

        # Also return information on who is not sponsored
        unsponsored = PersonRoles.query.join('group').join('member',
            aliased=True).outerjoin('sponsor', aliased=True).filter(
            and_(Groups.name==groupname,
                PersonRoles.role_status=='unapproved')).order_by(sort_map[order_by])
        unsponsored.json_props = {'PersonRoles': ['member']}
        members = PersonRoles.query.join('group').join('member', aliased=True).filter(
            People.username.like('%')
            ).outerjoin('sponsor', aliased=True).filter(
            Groups.name==groupname,
            ).order_by(sort_map[order_by])
        return dict(group=group, sponsor_queue=unsponsored,
            members=list(members))
开发者ID:chepioq,项目名称:fas,代码行数:31,代码来源:group.py

示例2: invite

    def invite(self, groupname, language):
        username = turbogears.identity.current.user_name
        person = People.by_username(username)
        group = Groups.by_name(groupname)
        person = person.filter_private()

        subject = _('Invitation to join the Fedora Team!', language)
        text = _('''
%(fullname)s <%(user)[email protected]%(hostname)s> has invited you to join the Fedora
Project!  We are a community of users and developers who produce a
complete operating system from entirely free and open source software
(FOSS).  %(fullname)s thinks that you have knowledge and skills
that make you a great fit for the Fedora community, and that you might
be interested in contributing.

How could you team up with the Fedora community to use and develop your
skills?  Check out http://fedoraproject.org/join-fedora for some ideas.
Our community is more than just software developers -- we also have a
place for you whether you're an artist, a web site builder, a writer, or
a people person.  You'll grow and learn as you work on a team with other
very smart and talented people.

Fedora and FOSS are changing the world -- come be a part of it!'''
        % {'fullname': person.human_name, 
               'user': person.username,
           'hostname': config.get('email_host')}, language)

        return dict(person=person, group=group, invite_subject=subject,
                    invite_text=text, selected_language=language)
开发者ID:chepioq,项目名称:fas,代码行数:29,代码来源:group.py

示例3: sendinvite

    def sendinvite(self, groupname, target):
        username = turbogears.identity.current.user_name
        person = People.by_username(username)
        group = Groups.by_name(groupname)

        if is_approved(person, group):
            invite_subject = _('Come join The Fedora Project!')
            invite_text = _('''
%(user)s <%(email)s> has invited you to join the Fedora
Project!  We are a community of users and developers who produce a
complete operating system from entirely free and open source software
(FOSS).  %(user)s thinks that you have knowledge and skills
that make you a great fit for the Fedora community, and that you might
be interested in contributing.

How could you team up with the Fedora community to use and develop your
skills?  Check out http://fedoraproject.org/join-fedora for some ideas.
Our community is more than just software developers -- we also have a
place for you whether you're an artist, a web site builder, a writer, or
a people person.  You'll grow and learn as you work on a team with other
very smart and talented people.

Fedora and FOSS are changing the world -- come be a part of it!''') % \
    {'user': person.username, 'email': person.email}

            send_mail(target, invite_subject, invite_text)

            turbogears.flash(_('Message sent to: %s') % target)
            turbogears.redirect('/group/view/%s' % group.name)
        else:
            turbogears.flash(_("You are not in the '%s' group.") % group.name)

        person = person.filter_private()
        return dict(target=target, person=person, group=group)
开发者ID:ccoss,项目名称:fas,代码行数:34,代码来源:group.py

示例4: invite

    def invite(self, groupname):
        username = turbogears.identity.current.user_name
        person = People.by_username(username)
        group = Groups.by_name(groupname)

        person = person.filter_private()
        return dict(person=person, group=group)
开发者ID:ccoss,项目名称:fas,代码行数:7,代码来源:group.py

示例5: members

    def members(self, groupname, search=u'a*', role_type=None,
                order_by='username'):
        '''View group'''
        sort_map = { 'username': 'people_1.username',
            'creation': 'person_roles_creation',
            'approval': 'person_roles_approval',
            'role_status': 'person_roles_role_status',
            'role_type': 'person_roles_role_type',
            'sponsor': 'people_2.username',
            }
        if not isinstance(search, unicode) and isinstance(search, basestring):
            search = unicode(search, 'utf-8', 'replace')

        re_search = search.translate({ord(u'*'): ur'%'}).lower()

        username = turbogears.identity.current.user_name
        person = People.by_username(username)
        group = Groups.by_name(groupname)

        if not can_view_group(person, group):
            turbogears.flash(_("You cannot view '%s'") % group.name)
            turbogears.redirect('/group/list')
            return dict()

        # return all members of this group that fit the search criteria
        members = PersonRoles.query.join('group').join('member', aliased=True).filter(
            People.username.like(re_search)
            ).outerjoin('sponsor', aliased=True).filter(
            Groups.name==groupname,
            ).order_by(sort_map[order_by])
        if role_type:
            members = members.filter(PersonRoles.role_type==role_type)
        group.json_props = {'PersonRoles': ['member']}
        return dict(group=group, members=members, search=search)
开发者ID:chepioq,项目名称:fas,代码行数:34,代码来源:group.py

示例6: save

    def save(self, groupname, display_name, owner, group_type,
             needs_sponsor=0, user_can_remove=1, prerequisite='',
             url='', mailing_list='', mailing_list_url='', invite_only=0,
             irc_channel='', irc_network='', joinmsg='', apply_rules="None"):
        '''Edit a group'''
        username = turbogears.identity.current.user_name
        person = People.by_username(username)
        group = Groups.by_name(groupname)

        changed = []
        #TODO: check any mandatory fields
        if not group_type:
            turbogears.flash(_("Group type cannot by empty!"))
            turbogears.redirect('/group/edit/%s' % group.name)

        if not can_edit_group(person, group):
            turbogears.flash(_("You cannot edit '%s'.") % group.name)
            turbogears.redirect('/group/view/%s' % group.name)
        else:
            owner = People.by_username(owner)

            if prerequisite:
                prerequisite = Groups.by_name(prerequisite)

            try:
                for field, _validator in GroupSave().fields.items():
                    if field in ['groupname']:
                        continue

                    if getattr(group, field) != locals()[field]:
                        setattr(group, field, locals()[field])
                        changed.append(field)

                session.flush()
            except:
                turbogears.flash(_('The group details could not be saved.'))
            else:
                Log(author_id=person.id, description='%s edited group %s' %
                    (person.username, group.name))
                fas.fedmsgshim.send_message(topic="group.update", msg={
                    'agent': person.username,
                    'group': group.name,
                    'fields': changed,
                })
                turbogears.flash(_('The group details have been saved.'))
                turbogears.redirect('/group/view/%s' % group.name)
            return dict(group=group)
开发者ID:fedora-infra,项目名称:fas,代码行数:47,代码来源:group.py

示例7: group_by_name

 def group_by_name(self, groupname):
     try:
         group = Groups.by_name(groupname)
         group.json_props = {
                 'Groups': ('approved_roles', 'unapproved_roles')}
         return dict(success=True, group=group)
     except InvalidRequestError:
         return dict(success=False)
开发者ID:0-T-0,项目名称:fas,代码行数:8,代码来源:json_request.py

示例8: save

    def save(self, groupname, display_name, owner, group_type, 
             needs_sponsor=0, user_can_remove=1, prerequisite='', 
             url='', mailing_list='', mailing_list_url='', invite_only=0,
             irc_channel='', irc_network='', joinmsg='', apply_rules="None"):
        '''Edit a group'''
        username = turbogears.identity.current.user_name
        person = People.by_username(username)
        group = Groups.by_name(groupname)

        if not can_edit_group(person, group):
            turbogears.flash(_("You cannot edit '%s'.") % group.name)
            turbogears.redirect('/group/view/%s' % group.name)
        else:
            try:
                owner = People.by_username(owner)
                group.display_name = display_name
                group.owner = owner
                group.group_type = group_type
                group.needs_sponsor = bool(needs_sponsor)
                group.user_can_remove = bool(user_can_remove)
                if prerequisite:
                    prerequisite = Groups.by_name(prerequisite)
                    group.prerequisite = prerequisite
                else:
                    group.prerequisite = None
                group.url = url
                group.mailing_list = mailing_list
                group.mailing_list_url = mailing_list_url
                if invite_only: 
                    group.invite_only = True
                else:
                    group.invite_only = False
                group.irc_channel = irc_channel
                group.irc_network = irc_network
                group.joinmsg = joinmsg
                group.apply_rules = apply_rules
                # Log here
                session.flush()
            except:
                turbogears.flash(_('The group details could not be saved.'))
            else:
                Log(author_id=person.id, description='%s edited group %s' %
                    (person.username, group.name))
                turbogears.flash(_('The group details have been saved.'))
                turbogears.redirect('/group/view/%s' % group.name)
            return dict(group=group)
开发者ID:Affix,项目名称:fas,代码行数:46,代码来源:group.py

示例9: validate_python

 def validate_python(self, value, state):
     # pylint: disable-msg=C0111
     try:
         # Just make sure the group already exists
         # pylint: disable-msg=W0612
         group = Groups.by_name(value)
     except InvalidRequestError:
         raise validators.Invalid(self.message('no_group', state, group=value),
                 value, state)
开发者ID:fedora-infra,项目名称:fas,代码行数:9,代码来源:validators.py

示例10: edit

    def edit(self, groupname):
        '''Display edit group form'''
        username = turbogears.identity.current.user_name
        person = People.by_username(username)
        group = Groups.by_name(groupname)

        if not can_admin_group(person, group):
            turbogears.flash(_("You cannot edit '%s'.") % group.name)
            turbogears.redirect('/group/view/%s' % group.name)
        return dict(group=group)
开发者ID:chepioq,项目名称:fas,代码行数:10,代码来源:group.py

示例11: view

    def view(self, groupname, order_by='username'):
        '''View group'''
        sort_map = { 'username': 'people_1.username',
            'creation': 'person_roles_creation',
            'approval': 'person_roles_approval',
            'role_status': 'person_roles_role_status',
            'role_type': 'person_roles_role_type',
            'sponsor': 'people_2.username',
            }
        username = turbogears.identity.current.user_name
        person = People.by_username(username)
        group = Groups.by_name(groupname)

        if not can_view_group(person, group):
            turbogears.flash(_("You cannot view '%s'") % group.name)
            turbogears.redirect('/group/list')
            return dict()

        # Also return information on who is not sponsored
        unsponsored = PersonRoles.query.join('group').join('member',
            aliased=True).outerjoin('sponsor', aliased=True).filter(
            and_(Groups.name==groupname,
                PersonRoles.role_status=='unapproved')).options(
                    eagerload('member')).order_by(sort_map[order_by])

        # Filter out privacy sensitive information
        unsponsored = list(unsponsored)
        for person in unsponsored:
            person.member.filter_private()


        # This is a really, really slow query in some cases, and we only
        # render it in this view if there are < 10 members. This is a rare case
        # where it makes sense to perform a count query first.
        # However, for consistency, we should probably count in the template.
        # So instead of sending list(members) back to the template, let's
        # send the members query object, then in the template, we can check
        # if we need to convert it to a list or not.
        members = PersonRoles.query.join('group').join('member', aliased=True).filter(
            People.username.like('%')
            ).outerjoin('sponsor', aliased=True).filter(
            Groups.name==groupname,
            ).order_by(sort_map[order_by])
        # At the present time members is only PersonRoles info
        # so we don't have to filter that.
        return dict(group=group, sponsor_queue=unsponsored, members=members)
开发者ID:fedora-infra,项目名称:fas,代码行数:46,代码来源:group.py

示例12: downgrade

    def downgrade(self, groupname, targetname):
        '''Upgrade user in group'''
        username = turbogears.identity.current.user_name
        person = People.by_username(username)
        target = People.by_username(targetname)
        group = Groups.by_name(groupname)

        if not can_downgrade_user(person, group):
            turbogears.flash(_("You cannot downgrade '%s'") % target.username)
            turbogears.redirect(cherrypy.request.headerMap.get("Referer", "/"))
            return dict()
        else:
            try:
                target.downgrade(group, person)
            except fas.DowngradeError, e:
                turbogears.flash(_('%(name)s could not be downgraded in %(group)s: %(error)s') % \
                    {'name': target.username, 'group': group.name, 'error': e})
                turbogears.redirect(cherrypy.request.headerMap.get("Referer", "/"))
            else:
开发者ID:chepioq,项目名称:fas,代码行数:19,代码来源:group.py

示例13: sponsor

    def sponsor(self, groupname, targetname):
        '''Sponsor user'''
        username = turbogears.identity.current.user_name
        person = People.by_username(username)
        target = People.by_username(targetname)
        group = Groups.by_name(groupname)

        if not can_sponsor_user(person, group):
            turbogears.flash(_("You cannot sponsor '%s'") % target.username)
            turbogears.redirect('/group/view/%s' % group.name)
            return dict()
        else:
            try:
                target.sponsor(group, person)
            except fas.SponsorError, e:
                turbogears.flash(_("%(user)s could not be sponsored in %(group)s: %(error)s") % \
                    {'user': target.username, 'group': group.name, 'error': e})
                turbogears.redirect('/group/view/%s' % group.name)
            else:
开发者ID:chepioq,项目名称:fas,代码行数:19,代码来源:group.py

示例14: type_list

    def type_list(self, grptype='pkgdb'):
        """ Return the list of all group of the given type.
        """
        username = turbogears.identity.current.user_name
        person = People.by_username(username)
        groups = []
        results = Groups.by_type(grptype)
        if self.jsonRequest():
            if len(results) == 1 \
                    and results[0].name == grptype \
                    and can_view_group(person, results[0]):
                turbogears.redirect('/group/view/%s' % (results[0].name))
                return dict()

        for group in results:
            if can_view_group(person, group):
                groups.append(group)
        if not len(groups):
            turbogears.flash(_("No Groups found of type '%s'") % grptype)
        return dict(groups=groups, search=grptype)
开发者ID:fedora-infra,项目名称:fas,代码行数:20,代码来源:group.py

示例15: remove

    def remove(self, groupname, targetname):
        '''Remove user from group'''
        # TODO: Add confirmation?
        username = turbogears.identity.current.user_name
        person = People.by_username(username)
        target = People.by_username(targetname)
        group = Groups.by_name(groupname)

        if not can_remove_user(person, group, target):
            turbogears.flash(_("You cannot remove '%(user)s' from '%(group)s'.") % \
                {'user': target.username, 'group': group.name})
            turbogears.redirect(cherrypy.request.headerMap.get("Referer", "/"))
            return dict()
        else:
            try:
                target.remove(group, target)
            except fas.RemoveError, e:
                turbogears.flash(_("%(user)s could not be removed from %(group)s: %(error)s") % \
                    {'user': target.username, 'group': group.name, 'error': e})
                turbogears.redirect(cherrypy.request.headerMap.get("Referer", "/"))
            else:
开发者ID:chepioq,项目名称:fas,代码行数:21,代码来源:group.py


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