Ejemplo n.º 1
0
    def patch_user(user):
        print "%s at %s" % (user.username, user.homeplace)
        
        if user not in site_members and user.username != 'anon':
            site_members_group.users.add(user)
        if user.homeplace:
            user.homehub = user.homeplace.tggroup_set.get(level='member')
        else:
            user.homeplace = root_location
            user.homehub = site_members_group
        
        user.save()
        create_reference(User, user)

        if user.active:
            if user.public_field:
                setup_user_security(user,'public')
            else:
                setup_user_security(user,'members_only')
        else:
            setup_user_security(user,'inactive')
            # inactive users should NOT be public...
            if user.public_field:
                user.public_field = 0
                user.save()

        if not user.hostinfo_set.count():
            hi = user.create_HostInfo(user, user=user)
            hi.save()

        if not user.public_field:
            user.public_field = 0 # its sometimes NULL atm
        user.save()
        profile = user.create_Profile(user, user=user)
        profile.save()
Ejemplo n.º 2
0
def patch_in_profiles():
    """create profiles and setup security hubspace users 
    """

    site_members_group = get_all_members_group()
    site_members = site_members_group.users.all()

    users = User.objects.all()
    for user in users:
        if user not in site_members and user.username != 'anon':
            site_members_group.users.add(user)
        if not user.homeplace :
            user.homeplace = get_or_create_root_location()
            user.save()
            print "%s at %s" % (user.username, user.homeplace)

    users = User.objects.filter(profile__isnull=True)
    no_of_users = users.count()

    for user in users:
        print user.username
        create_reference(User, user)
        setup_user_security(user,'public')
        profile = user.create_Profile(user, user=user)
        profile.save()
        print `profile`

    print "patched %s users to have profiles" % str(no_of_users)
Ejemplo n.º 3
0
def patch_in_groups():
    """Do group security setup for hubspace groups

       XXX patch group names to reflect Location names      
       XXX ensure all directors are in the host group 
       1. setup a security context for each group passing in context_agent, context_admin and creator 
    2. set 'hosts' as a members of the members group, ignore 'directors' groups (they are deprecated - bring on host anarchy

    """
    no_security = [group for group in TgGroup.objects.filter(level='member') if not group.ref.all()]
    admin_user = get_admin_user()
    for group in no_security:
        setup_hubs_security(group, admin_user)
    
    #this should have setup most of the host groups, but if not
    no_security_host = [group for group in TgGroup.objects.filter(level='host') if not group.ref.all()]

    for group in no_security_host:
        create_reference(TgGroup, group)
        group.type = 'administrative'
        setup_group_security(group, group, group, admin_user, 'private')

    #this should have setup most of the host groups, but if not
    no_security_director = [group for group in TgGroup.objects.filter(level='director') if not group.ref.all()]

    for group in no_security_host:
        create_reference(TgGroup, group)
        group.type = 'administrative'
        group.save()
        setup_group_security(group, group, group, admin_user, 'private')

    print "patched hub group's security"
Ejemplo n.º 4
0
def patch_in_groups():
    """Do group security setup for hubspace groups

       XXX patch group names to reflect Location names      
       XXX ensure all directors are in the host group 
       1. setup a security context for each group passing in context_agent, context_admin and creator 
    2. set 'hosts' as a members of the members group, ignore 'directors' groups (they are deprecated - bring on host anarchy

    """
    no_security = [group for group in TgGroup.objects.filter(level='member').exclude(place__name='hubplus') if not group.ref.all()]
    admin_user = get_admin_user()
    for group in no_security:
        setup_hubs_security(group, admin_user)
    
    #this should have setup most of the host groups, but if not
    no_security_host = [group for group in TgGroup.objects.filter(level='host') if not group.ref.all()]

    for group in no_security_host:
        create_reference(TgGroup, group)
        setup_group_security(group, group, group, admin_user)

    print "patched %s hub group's security" % str(len(no_security_host))