コード例 #1
0
ファイル: group.py プロジェクト: ujjwalwahi/fas
    def list(self, search='*', with_members=True):
        username = turbogears.identity.current.user_name
        person = People.by_username(username)

        memberships = {}
        groups = []
        re_search = re.sub(r'\*', r'%', search).lower()
        results = Groups.query.filter(Groups.name.like(re_search)).order_by('name').all()
        if self.jsonRequest():
            if with_members:
                membersql = sqlalchemy.select([PersonRoles.person_id, PersonRoles.group_id, PersonRoles.role_type], PersonRoles.role_status=='approved').order_by(PersonRoles.group_id)
                members = membersql.execute()
                for member in members:
                    try:
                        memberships[member[1]].append({'person_id': member[0], 'role_type': member[2]})
                    except KeyError:
                        memberships[member[1]]=[{'person_id': member[0], 'role_type': member[2]}]
            else:
                memberships = []

                if len(results) == 1 and results[0].name == search 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 matching '%s'") % search)
        return dict(groups=groups, search=search, memberships=memberships)
コード例 #2
0
ファイル: group.py プロジェクト: fedora-infra/fas
    def list(self, search='*', with_members=True):
        username = turbogears.identity.current.user_name
        person = People.by_username(username)

        memberships = {}
        groups = []
        re_search = re.sub(r'\*', r'%', search).lower()
        results = Groups.query.filter(Groups.name.like(re_search)).order_by('name').all()
        if self.jsonRequest():
            if with_members:
                membersql = sqlalchemy.select([PersonRoles.person_id, PersonRoles.group_id, PersonRoles.role_type], PersonRoles.role_status=='approved').order_by(PersonRoles.group_id)
                members = membersql.execute()
                for member in members:
                    try:
                        memberships[member[1]].append({'person_id': member[0], 'role_type': member[2]})
                    except KeyError:
                        memberships[member[1]]=[{'person_id': member[0], 'role_type': member[2]}]
            else:
                memberships = []

                if len(results) == 1 and results[0].name == search 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 matching '%s'") % search)
        return dict(groups=groups, search=search, memberships=memberships)
コード例 #3
0
ファイル: group.py プロジェクト: chepioq/fas
    def members(self, groupname, search=u'a*', role_type=None,
                order_by='username'):
        '''View group'''
        sort_map = { '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)
コード例 #4
0
ファイル: group.py プロジェクト: chepioq/fas
    def view(self, groupname, order_by='username'):
        '''View group'''
        sort_map = { '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))
コード例 #5
0
ファイル: group.py プロジェクト: ujjwalwahi/fas
    def members(self, groupname, search=u'a*', role_type=None,
                order_by='username'):
        '''View group'''
        sort_map = { '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)
コード例 #6
0
    def view(self, groupname, order_by='username'):
        '''View group'''
        sort_map = {
            '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']}
        return dict(group=group, sponsor_queue=unsponsored)
コード例 #7
0
ファイル: __init__.py プロジェクト: 0-T-0/fas
    def view(self, show):
        '''View Show'''
        username = turbogears.identity.current.user_name
        person = People.by_username(username)
        show = Show.by_name(show)

        if not can_view_group(person, show.group):
            turbogears.flash(_("You cannot view '%s'") % show.name)
            turbogears.redirect('/show/list')
            return dict()
        return dict(show=show)
コード例 #8
0
ファイル: __init__.py プロジェクト: ccoss/fas
    def view(self, show):
        '''View Show'''
        username = turbogears.identity.current.user_name
        person = People.by_username(username)
        show = Show.by_name(show)

        if not can_view_group(person, show.group):
            turbogears.flash(_("You cannot view '%s'") % show.name)
            turbogears.redirect('/show/list')
            return dict()
        return dict(show=show)
コード例 #9
0
ファイル: group.py プロジェクト: fedora-infra/fas
    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)
コード例 #10
0
ファイル: group.py プロジェクト: ujjwalwahi/fas
    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)
コード例 #11
0
ファイル: __init__.py プロジェクト: 0-T-0/fas
    def list(self, search='*'):
        username = turbogears.identity.current.user_name
        person = People.by_username(username)

        re_search = re.sub(r'\*', r'%', search).lower()
        results = Show.query.filter(Show.name.like(re_search)).order_by('name').all()
        shows = list()
        for show in results:
            if can_view_group(person, show.group):
                shows.append(show)
        if not len(shows):
            turbogears.flash(_("No Shows found matching '%s'") % search)
        return dict(shows=shows, search=search)
コード例 #12
0
ファイル: __init__.py プロジェクト: ccoss/fas
    def list(self, search='*'):
        username = turbogears.identity.current.user_name
        person = People.by_username(username)

        re_search = re.sub(r'\*', r'%', search).lower()
        results = Show.query.filter(
            Show.name.like(re_search)).order_by('name').all()
        shows = list()
        for show in results:
            if can_view_group(person, show.group):
                shows.append(show)
        if not len(shows):
            turbogears.flash(_("No Shows found matching '%s'") % search)
        return dict(shows=shows, search=search)
コード例 #13
0
ファイル: group.py プロジェクト: fedora-infra/fas
    def view(self, groupname, order_by='username'):
        '''View group'''
        sort_map = { '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)
コード例 #14
0
ファイル: group.py プロジェクト: ujjwalwahi/fas
    def view(self, groupname, order_by='username'):
        '''View group'''
        sort_map = { '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)