コード例 #1
0
ファイル: tests.py プロジェクト: GunioRobot/hubplus
    def test_become_member(self):
        u2 = get_admin_user()

        # now upgrade to a user
        u3 = self.ct.become_member('tom.salfield',
                                   invited_by=self.u,
                                   accepted_by=u2)
        self.assertEquals(u2.__class__, User)

        # the following commented test was to confirm that becoming a member deleted the Contact
        # as I'm not deleting contacts at the moment, this test is redundant
        # self.assertEquals(len(Contact.objects.filter(id=self.ct.id)), 0)

        p = u3.get_profile()
        self.assertEquals(p.first_name, self.ct.first_name)
        self.assertEquals(p.last_name, self.ct.last_name)
        self.assertEquals(p.email_address, self.ct.email_address)
        self.assertEquals(p.location, self.ct.location)
        self.assertEquals(p.get_host_info().find_out, self.ct.find_out)
        self.assertTrue(p.was_invited())
        self.assertTrue(p.was_accepted())
        self.assertEquals(p.invited_by.username, self.u.username)
        self.assertEquals(p.accepted_by.username, u2.username)

        self.assertTrue(u3.is_member_of(get_all_members_group()))
コード例 #2
0
ファイル: models.py プロジェクト: GunioRobot/hubplus
        def post_leave(self, user_or_group):
            """ this method, a break out of other stuff which happens when members leave groups,
            can be called as an independent function from syncer"""

            from apps.plus_permissions.types.Profile import ProfileInterfaces
            from apps.plus_permissions.default_agents import get_all_members_group, get_admin_user
            # remove host erpermissions on profile when join/leave Hub
            admin = get_admin_user()
            admin_group = self.get_admin_group()
            if self.group_type == 'hub':
                for prof in ProfileInterfaces:
                    user_or_group.get_security_context(
                    ).remove_arbitrary_agent(admin_group, 'Profile.%s' % prof,
                                             admin)

            from apps.plus_feed.models import FeedItem
            FeedItem.post_LEAVE(user_or_group, self)

            # stop following any group you leave .. not 100% certain this is what we want but our best guess
            from apps.microblogging.models import Following
            Following.objects.unfollow(user_or_group, self)

            # if I was the homehome for this user, change
            if user_or_group.homehub == self:
                user_or_group.homehub = get_all_members_group()
                user_or_group.save()
コード例 #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"
コード例 #4
0
def give_host_permissions(hub):
    """give hosts all rights to on user profiles of their members
    """
    admin = get_admin_user()
    for member in hub.get_members():
        for prof in ProfileInterfaces:
            member.get_security_context().add_arbitrary_agent(hub.get_admin_group(), 'Profile.%s' % prof, admin)
コード例 #5
0
ファイル: models.py プロジェクト: GunioRobot/hubplus
        def post_leave(self, user_or_group) :
            """ this method, a break out of other stuff which happens when members leave groups,
            can be called as an independent function from syncer"""

            from apps.plus_permissions.types.Profile import ProfileInterfaces
            from apps.plus_permissions.default_agents import get_all_members_group, get_admin_user
            # remove host erpermissions on profile when join/leave Hub
            admin = get_admin_user()
            admin_group = self.get_admin_group()
            if self.group_type == 'hub':
                for prof in ProfileInterfaces:
                    user_or_group.get_security_context().remove_arbitrary_agent(admin_group, 'Profile.%s' % prof, admin)

            from apps.plus_feed.models import FeedItem
            FeedItem.post_LEAVE(user_or_group, self)

            # stop following any group you leave .. not 100% certain this is what we want but our best guess
            from apps.microblogging.models import Following
            Following.objects.unfollow(user_or_group,self)


            # if I was the homehome for this user, change
            if user_or_group.homehub == self :
                user_or_group.homehub = get_all_members_group()
                user_or_group.save()
コード例 #6
0
ファイル: groups.py プロジェクト: GunioRobot/hubplus
def import_group(f_name, group_type, fn_place) :
    groups = pickle.load(open(f_name))
    admin = get_admin_user()
    site = get_site(admin)
    for g in groups:
        #print g.keys()
 
        print g['groupname'], g['body'], g['description'],g['joinpolicy'],g['imagefilename']

        if g['joinpolicy']== 'open' :
            permission_prototype='public'
        else :
            permission_prototype='private'

        description = ""
        if g['description'] :
            description = description + g['description']
        if g['body'] :
            description = description + g['body']
        if description == "" :
            description = 'About this group'

        display_name = g['groupname']
        group_name = psn_group_name(display_name)
        psn_id = g['uid']

        keywords = g['keywords']

        image_file = g['imagefilename'].split('/')[-1]

        print group_name, display_name, psn_id, permission_prototype,image_file
        print description
        print keywords

        groups = TgGroup.objects.filter(psn_id=psn_id)
        if groups : 
            group = groups[0]
        else :
            group = site.create_TgGroup(
                group_name = group_name,
                display_name = display_name,
                group_type = group_type ,
                level = 'member',
                user = admin,
                description = description,
                permission_prototype = permission_prototype,
                )
            group = group.get_inner()

        group.psn_id = psn_id
        group.group_name = group_name

        group.place = fn_place(g)        
        group.save()

        print "XX ", group.display_name, group.group_type
        if group.group_type != 'Hub' :
            add_avatar(group,"group_images",image_file)
        else :
            add_avatar(group,"hub_images",image_file)
コード例 #7
0
ファイル: tests.py プロジェクト: GunioRobot/hubplus
 def test_pp(self):
     god = get_admin_user()
     site = get_site(god)
     u = User(username='******', email_address='*****@*****.**')
     u.save()
     p = u.get_profile()
     self.assertTrue(p.get_ref())
     self.assertEquals(p.get_security_context(),site.get_inner().get_security_context())
コード例 #8
0
ファイル: tests.py プロジェクト: GunioRobot/hubplus
 def test_pp(self):
     god = get_admin_user()
     site = get_site(god)
     u = User(username='******', email_address='*****@*****.**')
     u.save()
     p = u.get_profile()
     self.assertTrue(p.get_ref())
     self.assertEquals(p.get_security_context(),
                       site.get_inner().get_security_context())
コード例 #9
0
ファイル: groups.py プロジェクト: mrchrisadams/hubplus
def import_group(f_name, group_type, fn_place) :
    groups = pickle.load(open(f_name))
    admin = get_admin_user()
    site = get_site(admin)
    for g in groups:
        print g.keys()
    #print g['groupname'], g['body'], g['description'],g['joinpolicy']
        if g['joinpolicy']== 'open' :
            permission_prototype='public'
        else :
            permission_prototype='private'

        description = ""
        if g['description'] :
            description = description + g['description']
        if g['body'] :
            description = description + g['body']
        if description == "" :
            description = 'About this group'

        group_name = make_name(g['groupname'])
        if len(group_name)>30 :
            group_name = group_name[30]
        display_name = g['groupname']
        psn_id = g['uid']

        keywords = g['keywords']

        print group_name, display_name, psn_id, permission_prototype
        print description
        print keywords

        groups = TgGroup.objects.filter(group_name=group_name)
        if groups : 
            group = groups[0]
        else :
            group = site.create_TgGroup(
                group_name = group_name,
                display_name = display_name,
                group_type = group_type ,
                level = 'member',
                user = admin,
                description = description,
                permission_prototype = permission_prototype,
                )
            group = group.get_inner()
        group.psn_id = psn_id
        
        group.place = fn_place(g)
        
        group.save()
コード例 #10
0
ファイル: models.py プロジェクト: GunioRobot/hubplus
        def post_join(self, user_or_group) :
            """ this method, a break out of other stuff which happens when members join groups,
            can be called as an independent funtion from syncer"""

            # add host permissions on profile when join/leave Hub
            from apps.plus_permissions.types.Profile import ProfileInterfaces
            from apps.plus_permissions.default_agents import get_all_members_group, get_admin_user
            admin = get_admin_user()
            admin_group = self.get_admin_group()
            if self.group_type == 'hub':
                for prof in ProfileInterfaces:
                    user_or_group.get_security_context().add_arbitrary_agent(admin_group, 'Profile.%s' % prof, admin)

            # start following any group you join
            from apps.microblogging.models import Following
            Following.objects.follow(user_or_group,self)
コード例 #11
0
ファイル: models.py プロジェクト: GunioRobot/hubplus
        def post_join(self, user_or_group):
            """ this method, a break out of other stuff which happens when members join groups,
            can be called as an independent funtion from syncer"""

            # add host permissions on profile when join/leave Hub
            from apps.plus_permissions.types.Profile import ProfileInterfaces
            from apps.plus_permissions.default_agents import get_all_members_group, get_admin_user
            admin = get_admin_user()
            admin_group = self.get_admin_group()
            if self.group_type == 'hub':
                for prof in ProfileInterfaces:
                    user_or_group.get_security_context().add_arbitrary_agent(
                        admin_group, 'Profile.%s' % prof, admin)

            # start following any group you join
            from apps.microblogging.models import Following
            Following.objects.follow(user_or_group, self)
コード例 #12
0
ファイル: views.py プロジェクト: mrchrisadams/hubplus
def patch_in_groups(request):
    """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()] #e.g. hubspace superuser and hubspace api
    for group in no_security_host:
        create_reference(TgGroup, group)
        setup_group_security(group, group, group, admin_user)

    return HttpResponse("patched %s hub group's security" % str(len(no_security_host)))
コード例 #13
0
ファイル: views.py プロジェクト: GunioRobot/hubplus
def patch_in_groups(request):
    """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()] #e.g. hubspace superuser and hubspace api
    for group in no_security_host:
        create_reference(TgGroup, group)
        setup_group_security(group, group, group, admin_user)

    return HttpResponse("patched %s hub group's security" % str(len(no_security_host)))
コード例 #14
0
def individual_changes():
    # make admin user active
    admin = get_admin_user()
    admin.active = True
    admin.save()
    all_members_group = get_all_members_group()
    all_members_group.group_name = settings.VIRTUAL_HUB_NAME
    all_members_group.display_name = settings.VIRTUAL_HUB_DISPLAY_NAME
    all_members_group.group_type = "hub"
    all_members_group.save()
    all_members_hosts = all_members_group.get_admin_group()
    all_members_hosts.group_name = "hubplus_hosts"
    all_members_hosts.display_name = "Hub+ Hosts" 
    all_members_hosts.group_type = 'administrative'
    all_members_hosts.save()

    for gr in TgGroup.objects.filter(level='host'):
        all_members_hosts.add_member(gr)
        gr.save()
コード例 #15
0
ファイル: tests.py プロジェクト: GunioRobot/hubplus
    def test_become_member(self):
        u2 = get_admin_user()

        # now upgrade to a user
        u3 = self.ct.become_member('tom.salfield',  invited_by=self.u, accepted_by=u2)
        self.assertEquals(u2.__class__, User)

        # the following commented test was to confirm that becoming a member deleted the Contact
        # as I'm not deleting contacts at the moment, this test is redundant
        # self.assertEquals(len(Contact.objects.filter(id=self.ct.id)), 0)
        
        p = u3.get_profile() 
        self.assertEquals(p.first_name, self.ct.first_name)
        self.assertEquals(p.last_name, self.ct.last_name)
        self.assertEquals(p.email_address, self.ct.email_address)
        self.assertEquals(p.location, self.ct.location)
        self.assertEquals(p.get_host_info().find_out, self.ct.find_out)
        self.assertTrue(p.was_invited())
        self.assertTrue(p.was_accepted())
        self.assertEquals(p.invited_by.username, self.u.username)
        self.assertEquals(p.accepted_by.username, u2.username)

        self.assertTrue(u3.is_member_of(get_all_members_group()))
コード例 #16
0
def patch():
    for ref in GenericReference.objects.filter(creator=None):
        ref.creator = get_admin_user()
        ref.save()
コード例 #17
0
load_all()

docs = maps['Document']
print docs[0].keys()

log= []
related_dict = {}
for doc in docs :
    path, tags = [],[]
    try :
        container = get_top_container(doc['uid'],path,tags)
        print
        print doc['title'].encode('utf-8'), container.get_display_name()
        creator_id = doc['creatoruid']
        if creator_id == -1 or creator_id == '-1' :
            user = get_admin_user()
        else :
            #print creator_id,e_type(creator_id)

            try :
                user = get_user_for(creator_id)
            except Exception, e:
                print e
                user = get_admin_user()

        #print doc['creators'],creator_id,user
        #print doc['body'].encode('utf-8')
        keywords = doc['keywords']
        if keywords  :
            print "found keywords"
            ipdb.set_trace()
コード例 #18
0
def create_messages(sender, instance, **kwargs):

    if instance is None:
        return
    application = instance
    if application.status == PENDING:
        approvers = instance.get_approvers()
        for approver in approvers:
            if isinstance(application.applicant, User):
                sender = application.applicant
            else:
                sender = get_admin_user()

            review_url = 'http://' + settings.DOMAIN_NAME + reverse(
                'plus_groups:list_open_applications',
                args=[application.group.id])

            if application.group.id == get_all_members_group().id:
                group_name = settings.SITE_NAME.encode('utf-8')
            else:
                group_name = application.group.get_display_name()

            find_out = ""
            country = ""
            if isinstance(application.applicant, Contact):
                find_out = application.applicant.find_out
                from apps.plus_lib.countryfield import country_name
                country = country_name(application.applicant.country)

            context = Context({
                'first_name': application.applicant.first_name,
                'last_name': application.applicant.last_name,
                'email_address': application.applicant.email_address,
                'organisation': application.applicant.organisation,
                'group_name': group_name,
                'request': application.request,
                'review_url': review_url,
                'find_out': find_out,
                'country': country
            })

            msg = Template(settings.APPLICATION_MESSAGE).render(context)
            approver.message(
                sender=sender,
                subject="Application to %s from %s" %
                (group_name, application.applicant.get_display_name()),
                body=msg)

    #if the application has a user then we want to message them
    if not application.is_site_application():
        if application.status == ACCEPTED:
            group = application.group
            accepted_by = application.accepted_by
            applicant = application.applicant
            data = {
                'group_name': group.get_display_name(),
                'accepted_by': accepted_by.get_display_name(),
                'applicant': applicant.get_display_name(),
                'group_url': reverse('plus_groups:group', args=[group.id])
            }

            msg = settings.ACCEPTED_TO_GROUP % data

            applicant.message(
                sender=accepted_by,
                subject="Your application to %(group_name)s was accepted" %
                data,
                body=msg)

        elif application.status == REJECTED:
            group = application.group
            rejected_by = application.rejected_by
            applicant = application.applicant
            data = {
                'group_name': group.get_display_name(),
                'rejected_by': rejected_by.get_display_name(),
                'applicant': applicant.get_display_name(),
                'group_url': reverse('plus_groups:group', args=[group.id])
            }

            context = Context(data)
            msg = Template(
                settings.APPLICATION_REJECT_TEMPLATE).render(context)

            applicant.message(
                sender=rejected_by,
                subject="Your application to %(group_name)s was declined" %
                data,
                body=msg)
コード例 #19
0
ファイル: tests.py プロジェクト: GunioRobot/hubplus
    def test_invite(self):
        site = get_site(get_admin_user())
        all_members = get_all_members_group()

        u = create_user('fred','*****@*****.**')
コード例 #20
0
ファイル: models.py プロジェクト: GunioRobot/hubplus
def create_messages(sender, instance, **kwargs):

    if instance is None:
        return
    application = instance
    if application.status == PENDING:
        approvers = instance.get_approvers()
        for approver in approvers:
            if isinstance(application.applicant, User):
                sender = application.applicant
            else:
                sender = get_admin_user()

            review_url = 'http://' + settings.DOMAIN_NAME + reverse('plus_groups:list_open_applications', args=[application.group.id])

            if application.group.id == get_all_members_group().id:
                group_name = settings.SITE_NAME.encode('utf-8')
            else:    
                group_name = application.group.get_display_name()

            find_out = ""
            country = ""
            if isinstance(application.applicant, Contact):
                find_out = application.applicant.find_out
                from apps.plus_lib.countryfield import country_name
                country = country_name(application.applicant.country)

            context = Context({'first_name':application.applicant.first_name,
                               'last_name':application.applicant.last_name,
                               'email_address':application.applicant.email_address,
                               'organisation':application.applicant.organisation,
                               'group_name':group_name,
                               'request':application.request,
                               'review_url':review_url,
                               'find_out':find_out,
                               'country':country})

            msg = Template(settings.APPLICATION_MESSAGE).render(context)
            approver.message(sender=sender, 
                         subject="Application to %s from %s" %(group_name, application.applicant.get_display_name()), 
                         body=msg)

    #if the application has a user then we want to message them
    if not application.is_site_application():
        if application.status == ACCEPTED:
            group = application.group
            accepted_by = application.accepted_by
            applicant = application.applicant
            data = {'group_name':group.get_display_name(),
                    'accepted_by': accepted_by.get_display_name(),
                    'applicant':applicant.get_display_name(),
                    'group_url':reverse('plus_groups:group', args=[group.id])}

            msg = settings.ACCEPTED_TO_GROUP % data
            
            applicant.message(sender=accepted_by,
                         subject="Your application to %(group_name)s was accepted" % data,
                         body=msg)

        elif application.status == REJECTED:
            group = application.group
            rejected_by = application.rejected_by
            applicant = application.applicant
            data = {'group_name':group.get_display_name(),
                    'rejected_by': rejected_by.get_display_name(),
                    'applicant':applicant.get_display_name(),
                    'group_url':reverse('plus_groups:group', args=[group.id])}

            context = Context(data)
            msg = Template(settings.APPLICATION_REJECT_TEMPLATE).render(context)

            applicant.message(sender=rejected_by,
                         subject="Your application to %(group_name)s was declined" % data,
                         body=msg)
コード例 #21
0
ファイル: tests.py プロジェクト: GunioRobot/hubplus
    def test_invite(self):
        site = get_site(get_admin_user())
        all_members = get_all_members_group()

        u = create_user('fred', '*****@*****.**')
コード例 #22
0
ファイル: tests.py プロジェクト: GunioRobot/hubplus
    def test_application(self) :

        god = get_admin_user() # now a standard user, and member of the site_members_group's admin
        site = get_site(god)

        contact = site.create_Contact(god, first_name='kate', last_name='smith', email_address='*****@*****.**')
        contact.save()

        self.assertTrue(contact.get_inner().get_creator())

        group = site.create_TgGroup(god, group_name='sexy_salad', display_name='Sexy Salad', level='member')
        

        self.assertTrue(group.get_inner().get_creator()) # group should have a creator
        self.assertEquals(group.get_inner().get_creator().id,god.id)
        
        application = site.create_Application(god, applicant=contact, request='I want to join in')
        
        # the following should be true because application was created by god
        # so god is its "creator" and default for Application.Editor is "creator"

        self.assertTrue(has_access(god, application, 'Application.Editor'))
        application.group = group.get_inner()
        application.save()

        self.assertTrue(has_access(group,application,'Application.Viewer'))

        self.assertEquals(application.date.date(),datetime.datetime.today().date())


        self.assertTrue(application.applicant.s_eq(contact))
        self.assertEquals(application.request, 'I want to join in')
        self.assertTrue(application.group.s_eq(group))
        self.assertEquals(application.status, PENDING)
        self.assertEquals(application.admin_comment,'')
        self.assertEquals(application.accepted_by,None)


        # adding a couple more 

        ap2 = site.create_Application(god, applicant=contact,request='ap2',group=get_anonymous_group())
        ap3 = site.create_Application(god, applicant=contact,request='ap3',group=get_all_members_group())
        
        self.assertEquals(self.count(Application.objects.filter()),3)
        self.assertEquals(self.count(Application.objects.filter(request='ap2')),1)

        mable = User(username='******',email_address='*****@*****.**')
        mable.save()
        self.assertEquals(Application.objects.plus_count(mable),0)

        # now there's a security tag which links "group" as context to the interface "ApplicationViewer"
        site.get_inner().get_security_context().add_arbitrary_agent(group, 'Application.Viewer', god)
        
        self.assertTrue(has_access(group, ap2, 'Application.Viewer'))

        self.assertFalse(has_access(mable, ap2, 'Application.Viewer'))

        self.assertEquals(Application.objects.plus_count(group),3)
            
        s_application = Application.objects.plus_get(mable, id=application.id)
        
        def f(application,sponsor) :
            application.accept(sponsor)
        
        self.assertRaises(PlusPermissionsNoAccessException,f,s_application,mable)
            
        self.assertEquals(s_application.get_inner().status,PENDING)

        application = Application.objects.get(id=application.id)

        application.accept(mable, 'site_root', admin_comment='great choice')

        self.assertEquals(application.status,WAITING_USER_SIGNUP)
        self.assertEquals(application.admin_comment,'great choice')
        self.assertEquals(application.accepted_by, mable)
コード例 #23
0
ファイル: tests.py プロジェクト: GunioRobot/hubplus
    def test_application(self):

        god = get_admin_user(
        )  # now a standard user, and member of the site_members_group's admin
        site = get_site(god)

        contact = site.create_Contact(god,
                                      first_name='kate',
                                      last_name='smith',
                                      email_address='*****@*****.**')
        contact.save()

        self.assertTrue(contact.get_inner().get_creator())

        group = site.create_TgGroup(god,
                                    group_name='sexy_salad',
                                    display_name='Sexy Salad',
                                    level='member')

        self.assertTrue(
            group.get_inner().get_creator())  # group should have a creator
        self.assertEquals(group.get_inner().get_creator().id, god.id)

        application = site.create_Application(god,
                                              applicant=contact,
                                              request='I want to join in')

        # the following should be true because application was created by god
        # so god is its "creator" and default for Application.Editor is "creator"

        self.assertTrue(has_access(god, application, 'Application.Editor'))
        application.group = group.get_inner()
        application.save()

        self.assertTrue(has_access(group, application, 'Application.Viewer'))

        self.assertEquals(application.date.date(),
                          datetime.datetime.today().date())

        self.assertTrue(application.applicant.s_eq(contact))
        self.assertEquals(application.request, 'I want to join in')
        self.assertTrue(application.group.s_eq(group))
        self.assertEquals(application.status, PENDING)
        self.assertEquals(application.admin_comment, '')
        self.assertEquals(application.accepted_by, None)

        # adding a couple more

        ap2 = site.create_Application(god,
                                      applicant=contact,
                                      request='ap2',
                                      group=get_anonymous_group())
        ap3 = site.create_Application(god,
                                      applicant=contact,
                                      request='ap3',
                                      group=get_all_members_group())

        self.assertEquals(self.count(Application.objects.filter()), 3)
        self.assertEquals(
            self.count(Application.objects.filter(request='ap2')), 1)

        mable = User(username='******', email_address='*****@*****.**')
        mable.save()
        self.assertEquals(Application.objects.plus_count(mable), 0)

        # now there's a security tag which links "group" as context to the interface "ApplicationViewer"
        site.get_inner().get_security_context().add_arbitrary_agent(
            group, 'Application.Viewer', god)

        self.assertTrue(has_access(group, ap2, 'Application.Viewer'))

        self.assertFalse(has_access(mable, ap2, 'Application.Viewer'))

        self.assertEquals(Application.objects.plus_count(group), 3)

        s_application = Application.objects.plus_get(mable, id=application.id)

        def f(application, sponsor):
            application.accept(sponsor)

        self.assertRaises(PlusPermissionsNoAccessException, f, s_application,
                          mable)

        self.assertEquals(s_application.get_inner().status, PENDING)

        application = Application.objects.get(id=application.id)

        application.accept(mable, 'site_root', admin_comment='great choice')

        self.assertEquals(application.status, WAITING_USER_SIGNUP)
        self.assertEquals(application.admin_comment, 'great choice')
        self.assertEquals(application.accepted_by, mable)
コード例 #24
0
def patch():
    for ref in GenericReference.objects.filter(creator=None):
        ref.creator = get_admin_user()
        ref.save()