Exemple #1
0
    def apply(self, groupname, targetname=None):
        '''Apply to a group'''
        username = turbogears.identity.current.user_name
        person = People.by_username(username)
        if not targetname:
            target = person
        else:
            target = People.by_username(targetname)
        group = Groups.by_name(groupname)

        if not can_apply_group(person, group, target):
            turbogears.flash(_('%(user)s can not apply to %(group)s.') % \
                {'user': target.username, 'group': group.name })
            turbogears.redirect('/group/view/%s' % group.name)
            return dict()
        else:
            try:
                target.apply(group, person)
            except fas.ApplyError, e:
                turbogears.flash(_('%(user)s could not apply to %(group)s: %(error)s') % \
                    {'user': target.username, 'group': group.name, 'error': e})
                turbogears.redirect('/group/view/%s' % group.name)
            else:
Exemple #2
0
    def application_screen(self, groupname, targetname=None):
        username = turbogears.identity.current.user_name
        person = People.by_username(username)
        if not targetname:
            targetname = username
            target = person
        else:
            target = People.by_username(targetname)
        group = Groups.by_name(groupname)

        if username != targetname or group.apply_rules is None or len(group.apply_rules) < 1:
            turbogears.redirect('/group/apply/%s/%s' % (group.name, target.username))

        if group in target.memberships:
            turbogears.flash('You are already a member of %s!' % group.name)
            turbogears.redirect('/group/view/%s' % group.name)

        if not can_apply_group(person, group, target):
            turbogears.flash(_('%(user)s can not apply to %(group)s.') % \
                {'user': target.username, 'group': group.name })
            turbogears.redirect('/group/view/%s' % group.name)
            return dict()
        else:
            return dict(group=group)