Changeset 1930


Ignore:
Timestamp:
08/13/07 17:14:15 (12 years ago)
Author:
jukka
Message:

Fixed tests and other stuff, fixed #1376, closed #1420.

Location:
trunk
Files:
3 deleted
12 edited

Legend:

Unmodified
Added
Removed
  • trunk/GroupBlog.py

    r1922 r1930  
    4545schema = BaseFolderSchema + description + tags + coverImage + deletionReason + score + subject_area_schema + latest_edit_schema + Schema(( 
    4646    StringField('title', 
    47         default_method='prefill_title', 
     47        required=True, 
    4848        searchable = True, 
    4949    ), 
    5050    StringField('description', 
    51         default_method='prefill_description', 
    5251        schemata='default', 
    5352        widget=TextAreaWidget( 
     
    105104    meta_type = "GroupBlog" 
    106105    archetype_name = "GroupBlog"   
    107     typeDescription="Shared blog for a group" 
    108     typeDescMsgId='description_groupblog' 
    109106    global_allow = 1 
    110107 
     
    287284            return False 
    288285        self.setGroupMembers(users+[mid]) 
     286        self.reindexObject() 
    289287        return True 
    290288             
     
    311309         
    312310             
    313     def join_group(self): 
     311    def join_group(self, redirect=True): 
    314312        """ The logged in user joins the current group """ 
    315         REQUEST=self.REQUEST 
    316313        mtool = getToolByName(self, 'portal_membership') 
    317314        putils= getToolByName(self, 'plone_utils') 
     
    323320            msg= _(u"You are already member in this group.") 
    324321        putils.addPortalMessage(msg) 
    325         return REQUEST.RESPONSE.redirect(self.absolute_url()) 
     322        if redirect: 
     323            return self.REQUEST.RESPONSE.redirect(self.absolute_url()) 
    326324     
    327325    def leave_group(self): 
  • trunk/LargeSectionFolder.py

    r1921 r1930  
    874874        mtool = getToolByName(self, "portal_membership") 
    875875        memberfolder=mtool.getHomeFolder() 
     876        if not memberfolder: 
     877            return [] 
    876878        glist=memberfolder.getGroups(objects=True) 
    877879        recents=[] 
  • trunk/MemberFolder.py

    r1919 r1930  
    513513        objlist=pc({'getGroupMembers':self.getMemberId(), 'portal_type':'GroupBlog'}) 
    514514        if objects: 
    515             return [o.getObject() for o in objlist] 
     515            return [o.getObject() for o in objlist]  
    516516        else: 
    517517            return objlist 
  • trunk/Resources.py

    r1922 r1930  
    328328        """ Return object with this UID or None """ 
    329329        uc=getToolByName(self, 'uid_catalog') 
     330        if not UID: 
     331            return None 
    330332        objlist=uc({'UID':UID}) 
    331333        if objlist: 
     
    341343        mtool = getToolByName(self, 'portal_membership') 
    342344        memberfolder=mtool.getHomeFolder() 
    343         groups=memberfolder.getGroups() 
     345        if memberfolder: 
     346            groups=memberfolder.getGroups() 
     347        else: 
     348            groups=[] 
    344349 
    345350        if allow_none: 
     
    918923    def canIEdit(self): 
    919924        mtool = getToolByName(self, 'portal_membership') 
    920         lmtool = getToolByName(self, 'lemill_usertool') 
    921925        group = self.getGroupEditing() 
    922926        if not group: 
     
    925929        if not member: 
    926930            return False # This shouldn't happen at all 
    927  
    928         membersgroups=member.getGroups() 
    929         if not membersgroups: 
    930             return False 
    931         return group.id in [m.id for m in membersgroups] 
     931        return group.isMember(member.id) 
    932932 
    933933         
     
    938938        create_new = self.REQUEST.get('new_group_name', '') 
    939939        blog=None 
     940        if hasattr(value, 'portal_type'): 
     941            if value.portal_type=='GroupBlog': 
     942                blog=value 
    940943        if create_new and value=='__new_group': 
    941944            # create a new group here 
     
    946949            blog.join_group() 
    947950            blog.edit(title=create_new, description="") 
    948             value = blog.UID() 
    949951            discussion=self.getDiscussion(do_create=False) 
    950952            if discussion: 
    951953                self.moveDiscussion(discussion, blog)                 
    952954 
    953         if value == '__new_group': 
     955        if value == '__new_group' and not blog: 
    954956            return 
    955957        f = self.getField('groupEditing') 
    956958        old_value = f.get(self) 
    957959        destination=None 
    958         if value: 
     960        if value and not blog: 
    959961            destination = self.getObjectByUID(value) 
    960         else: 
    961             destination=self.community.unassigned_discussions 
     962        elif blog: 
     963            destination = blog 
     964            value=blog.UID() 
    962965 
    963966        if value!=old_value: 
    964             f.set(self, value) 
     967            if destination: 
     968                f.set(self, value) 
     969            else: 
     970                f.set(self, None) 
    965971            discussion=self.getDiscussion(do_create=False) 
    966             if discussion and destination: 
     972            if discussion: 
     973                if not destination: 
     974                    destination=self.community.unassigned_discussions 
    967975                self.moveDiscussion(discussion, destination) 
     976 
     977    def joinGroupEditing(self): 
     978        """ join to a group working on this material """ 
     979        group=self.getGroupEditing() 
     980        if group: 
     981            group.join_group() 
     982        return self.REQUEST.RESPONSE.redirect('%s/edit' % self.absolute_url()) 
    968983 
    969984    ######################### 
  • trunk/skins/lemill/group_invite.cpt

    r1921 r1930  
    3737                          inviter mtool/getHomeFolder;                           
    3838                          groupslist inviter/getGroups; 
    39                           inviteds_grouplist invited/getGroups; 
     39                          inviteds_groupids python:[o.id for o in invited.getGroups()]; 
    4040                          "> 
    4141 
     
    4545        <p i18n:translate="invite_group_message">You can invite <span i18n:name="firstname_lastname" tal:replace="invited/NiceName">Firstname Lastname</span> to join your groups. This invitation will be sent by e-mail.</p> 
    4646         
    47         <span tal:repeat="gr groupslist" tal:omit-tag=""> 
     47        <span tal:repeat="group groupslist" tal:omit-tag=""> 
    4848         
    49         <div tal:define="group python:context.getGroupById(gr)"> 
     49        <div> 
    5050        <input type="checkbox" name="groupname" id="groupname" value="True" tal:attributes=" 
    51         disabled python:gr in inviteds_grouplist; 
    52         name gr; 
    53         id gr; 
     51        disabled python:group.id in inviteds_groupids; 
     52        name group/id; 
     53        id group/id; 
    5454        tabindex tabindex/next" /> 
    55         <span tal:replace="group/NiceName">Groups name</span>  
    56         <span tal:condition="python:gr in inviteds_grouplist" i18n:translate="already_member">(already a member)</span> 
     55        <span tal:replace="group/Title">Groups name</span>  
     56        <span tal:condition="python:group.id in inviteds_groupids" i18n:translate="already_member">(already a member)</span> 
    5757        </div>         
    5858                 
  • trunk/skins/lemill/join_a_group.cpt.metadata

    r727 r1930  
    11[default] 
    2 title = Collection Add 
     2title = Join Group 
    33 
    44[actions] 
    5 action.success = traverse_to:string:script_join_a_group 
    6 action.success..join = traverse_to:string:script_join_a_group 
     5action.success = traverse_to:string:joinGroupEditing 
     6action.success..join = traverse_to:string:joinGroupEditing 
    77action.success..Cancel = redirect_to:string:view 
    8 action.success..SelectGroup = traverse_to:string:script_join_a_group 
     8action.success..SelectGroup = traverse_to:string:joinGroupEditing 
  • trunk/skins/lemill/manage_translations.pt

    r1926 r1930  
    1313     tal:define="translations python:here.getTranslationsOfOriginal(include_self=False); 
    1414                 mother here/getOriginal; 
    15                  obj_translations here/getTranslations; 
    16                 "> 
     15                 obj_translations here/getTranslations;"> 
    1716 
    1817      <div id="content" class="documentEditable"> 
     
    4443                  name="form.button.set_mother" 
    4544                  value="Change source of translation" 
    46                    
    4745                  tal:attributes="tabindex tabindex/next" 
    4846                  /> 
  • trunk/tests/LeMillTestCase.py

    r1632 r1930  
    7575 
    7676    def newGroup(self, id): 
    77         gtool = getToolByName(self.portal, 'portal_groups') 
    78         gtool.addGroup(id,(),()) 
    79         blog=gtool.getGroupareaFolder(id) 
    80         blog.setProperties(title=id) 
    81         return gtool.getGroupById(id) 
    82  
    83     def getGroupBlog(self, id):     
    84         gtool = getToolByName(self.portal, 'portal_groups') 
    85         return gtool.getGroupareaFolder(id) 
     77        community=self.portal.community 
     78        group=self.construct('GroupBlog', id, folder=community) 
     79        group.edit(title=id) 
     80        return group 
    8681 
    8782    def editObject(self,ob,params,basic): 
  • trunk/tests/framework.py

    r236 r1930  
    123123print 'INSTANCE_HOME: %s' % os.environ.get('INSTANCE_HOME', 'Not set') 
    124124sys.stdout.flush() 
    125  
  • trunk/tests/testGroups.py

    r1785 r1930  
    4040    def testGroupView(self): 
    4141        self.loginAsPortalOwner() 
    42         grouptool=getToolByName(self.portal, "portal_groups") 
    4342        group1 = self.newGroup('testgroup1') 
    44         workspace1 = self.getGroupBlog('testgroup1') 
    45         result=self.publish(workspace1.absolute_url_path()+'/view', basic=auth).getBody() 
     43        result=self.publish(group1.absolute_url_path()+'/view', basic=auth).getBody() 
    4644        self.failUnless(result.find('portlet-groupblog-actions') != -1, "Portlet not shown") 
    4745 
    4846    def testGroupEdit(self): 
    4947        self.loginAsPortalOwner() #GRUF's settings are a bit restrictive 
    50         self.grouptool=getToolByName(self.portal, "portal_groups") 
    5148        self.group1 = self.newGroup('testgroup1') 
    52         self.workspace1 = self.getGroupBlog('testgroup1') 
    5349        self.TOKENS1 = 'unit testing is foobar' 
    5450        self.TOKENS2 = ['word','another'] 
    55         self.workspace1.setProperties(description=self.TOKENS1, tags=self.TOKENS2) 
     51        self.group1.edit(description=self.TOKENS1, tags=self.TOKENS2) 
    5652        result=self.publish(self.portal.absolute_url_path()+'/community/testgroup1/base_edit', basic=auth) 
    57         #result=self.publish(self.grouptool.getGroupareaURL('testgroup1')+'/group_edit', basic=auth) 
    58         # why that^^ works but that^ doesn't?  
    5953        for prop in ['title','description','tags']: 
    6054            self.failUnless(result.getBody().find(prop) != -1, "edit form broken, missing property:"+prop+result.getBody()) 
    6155 
    6256    # joining, leaving and such are not tested, because they're just calls to GroupUserFolder's methods in form handler scripts. 
     57 
     58    def testJoiningAndLeavingGroup(self): 
     59        self.addUser('commoner','passwd1') 
     60        self.group1=self.newGroup('testgroup1') 
     61        self.login('commoner') 
     62        auth='commoner:passwd1' 
     63        self.group1.join_group() 
     64        result=self.publish(self.portal.absolute_url_path()+'/community/testgroup1', basic=auth) 
     65        self.failUnless('commoner' in self.group1.getGroupMembers(), "Joined member not visible in group members: %s" % self.group1.getGroupMembers()) 
     66        self.failUnless(result.getBody().find('Leave group') != -1, "If we're joined there should be leave group on page somewhere: "+result.getBody()) 
     67        self.group1.leave_group() 
     68        result=self.publish(self.portal.absolute_url_path()+'/community/testgroup1', basic=auth) 
     69        self.failIf('commoner' in self.group1.getGroupMembers(), "Joined member still visible in group members, after leaving.") 
     70        self.failIf(result.getBody().find('Leave group') != -1, "We should have left already: "+result.getBody()) 
     71 
    6372     
    6473    def testGroupList(self): 
    65         self.loginAsPortalOwner() #GRUF's settings are a bit restrictive 
    66         self.grouptool=getToolByName(self.portal, "portal_groups") 
    6774        self.group1 = self.newGroup('testgroup1') 
    6875        self.TOKENS1 = 'titlefoobar' 
    69         self.workspace1 = self.getGroupBlog('testgroup1') # In LeMill modifying groups is always done by modifying groups workspace. 
    70         self.workspace1.setProperties(title=self.TOKENS1) # This should affect the group too. 
     76        self.group1.edit(title=self.TOKENS1) 
    7177        result=self.publish(self.portal.absolute_url_path()+'/community/groups', basic=auth) 
    7278        self.failUnless(result.getBody().find(self.TOKENS1) != -1, "can't find created group when browsing group names"+result.getBody()) 
     
    8187        self.group1 = self.newGroup('testgroup1') 
    8288        self.group2 = self.newGroup('testgroup2') 
    83         self.workspace1 = self.getGroupBlog('testgroup1') 
    84         self.workspace2 = self.getGroupBlog('testgroup2') 
    85         self.workspace1.join_group() 
    86         self.workspace2.join_group() 
     89        self.group1.join_group() 
     90        self.group2.join_group() 
    8791        # 1) there shouldn't be invite -link visible in your own profile page 
    8892        result=self.publish(self.portal.community.inviter.absolute_url_path(), basic=iauth) 
     
    98102        # 4) if our invitee is already a member, there should be a notion of that 
    99103        self.login('invited') 
    100         self.workspace1.join_group() 
     104        self.group1.join_group() 
    101105        result=self.publish(self.portal.community.invited.absolute_url_path()+'/group_invite', basic=iauth) # this is still ran as portal_owner 
    102106        self.failUnless(result.getBody().find('already a member') != -1, "member is already in group, but it doesn't get noticed"+result.getBody())               
     
    107111        TITLE='TheseThingsTakeTime' 
    108112        VALUE='Most inept that ever stepped' 
    109         self.grouptool=getToolByName(self.portal, "portal_groups") 
    110113        self.group = self.newGroup('testgroup') 
    111         self.workspace = self.getGroupBlog('testgroup') 
    112114        ob = self.construct('BlogPost','TestPost',self.portal.community.testgroup) 
    113115        ob.processForm(values={'title':TITLE,'bodyText':VALUE}) 
     
    127129        self.addUser('foobar','foobar', ('Member',)) 
    128130        self.login('foobar') 
    129         self.grouptool=getToolByName(self.portal, "portal_groups") 
    130131        self.group = self.newGroup('testgroup') 
    131         self.workspace = self.getGroupBlog('testgroup') 
    132132 
    133133        cases = [('test1','First post', 'Most inept that ever stepped'), 
     
    140140        result=self.publish(self.portal.absolute_url_path()+'/community', basic='foobar:foobar') 
    141141        TITLE=cases[0][1] 
    142         GTITLE=self.getGroupBlog('testgroup').title_or_id() 
     142        GTITLE=self.group.title_or_id() 
    143143        self.failIf(result.getBody().find(TITLE) != -1, "Found post titled %s from community front page when member is not member of group." % TITLE) 
    144144        self.failIf(result.getBody().find(GTITLE) != -1, "Found group title %s from community front page when member is not member of group." % GTITLE) 
    145145 
    146         self.workspace.join_group() 
     146        self.group.join_group() 
    147147        result=self.publish(self.portal.absolute_url_path()+'/community', basic='foobar:foobar') 
    148148 
     
    159159        ob = self.construct('PresentationMaterial', 'testMaterial', self.portal.content) 
    160160        self.group = self.newGroup('testgroup') 
    161         self.workspace = self.getGroupBlog('testgroup') 
    162         self.workspace.join_group()        
    163         ob.edit(groups='no_group') 
    164         self.failUnless(ob.getGroupsShared()=='no_group', 'Material isn\'t shared with a group') 
    165         self.failIf(str(ob.getGroupsEditing())=='no_group', '"no_group" as group name should mean that no local role gets assigned. Now the local role is assigned to some group named no_group') 
    166         ob.edit(groups='testgroup') 
    167         self.failUnless(ob.getGroupsShared()=='testgroup', 'Material isn\'t shared with a group') 
    168         self.failUnless(str(ob.getGroupsEditing())=='testgroup', 'Material isn\'t shared with a group. Local roles haven\'t been set!') 
     161        self.group.join_group()        
     162        ob.edit(groupEditing=None) 
     163        self.failUnless(ob.getGroupEditing()==None, 'Material shouldn\'t be shared with a group') 
     164        ob.setGroupEditing(self.group) 
     165 
     166        self.failUnless(ob.getRawGroupEditing()==self.group.UID(), 'Material isn\'t shared with a group') 
     167 
    169168 
    170169        self.addUser('foobar','foobar', ('Member',)) 
     
    175174        joining = self.publish(self.portal.absolute_url_path()+'/community/testgroup/join_group', basic='foobar:foobar').getBody() 
    176175        result = self.publish(ob.absolute_url_path()+'/edit', basic=bauth).getBody() 
    177         self.failIf(result.find('Unauthorized') != -1, 'Joined a group but cannot edit material.') 
     176        self.failUnless(result.find('Slides and captions') != -1, 'Joined a group but cannot edit material.') 
    178177         
    179     def testBanning(self): 
    180         """ test banning and unbanning """ 
    181         self.loginAsPortalOwner() 
     178     
     179    def testMemberLinks(self): 
     180        # Anonymous links 
    182181        self.group = self.newGroup('testgroup') 
    183         self.workspace = self.getGroupBlog('testgroup') 
    184         self.workspace.join_group()        
    185         self.workspace.setBanned('foobar') 
    186182        self.addUser('foobar','foobar', ('Member',)) 
    187183        self.login('foobar') 
    188         bauth = ':'.join(('foobar', 'foobar')) 
    189         result = self.publish(self.workspace.absolute_url_path()+'/join_group', basic=bauth).getBody() 
    190         self.failUnless(result.endswith('community'), 'User should be banned and unable to join. %s' % result) 
    191         self.loginAsPortalOwner() 
    192         self.workspace.setBanned('') 
    193         self.login('foobar') 
    194         result = self.publish(self.workspace.absolute_url_path()+'/join_group', basic=bauth).getBody() 
    195         self.failUnless(result.endswith('testgroup'), 'User should be able to join. %s' % result) 
    196      
    197     def testModerating(self): 
    198         """ test moderation """ 
    199         self.loginAsPortalOwner() 
    200         self.group = self.newGroup('testgroup') 
    201         self.workspace = self.getGroupBlog('testgroup') 
    202         self.workspace.join_group() 
    203         self.addUser('foobar','foobar', ('Member',)) 
    204         self.login('foobar') 
    205         self.workspace.join_group() 
    206         self.loginAsPortalOwner() 
    207         self.workspace.setModerators(('foobar',)) 
    208         bauth = ':'.join(('foobar', 'foobar')) 
    209         cases = [('test1','Firstpost', 'Most inept that ever stepped', 'blog post')] 
    210         for (ID, TITLE, BODY, CATEGORY) in cases: 
    211             ob = self.construct('BlogPost',ID,self.portal.community.testgroup) 
    212             ob.processForm(values={'title':TITLE,'bodyText':BODY, 'category':CATEGORY}) 
    213             ob.at_post_edit_script() 
    214  
    215         self.login('foobar') 
    216         self.failUnless('Reviewer' in self.workspace.getRoles(), 'Member did not get moderator rights %s ' % self.workspace.getRoles()) 
    217         result= self.publish(self.portal.absolute_url_path()+'/community/testgroup/firstpost', basic=bauth).getBody() 
    218         self.failUnless(result.find('firstpost/delete_post') != -1, "Moderator can't see delete post link %s" % result) 
    219         try: 
    220             self.workspace.firstpost.delete_post() 
    221         except: 
    222             self.fail("Moderator couldn't delete post.") 
    223      
    224  
    225     def testMemberLinks(self): 
    226         # Anonymous links 
    227         self.grouptool=getToolByName(self.portal, "portal_groups") 
    228         self.group = self.newGroup('testgroup') 
    229         self.workspace = self.getGroupBlog('testgroup') 
    230         self.addUser('foobar','foobar', ('Member',)) 
    231         self.login('foobar') 
    232         self.workspace.join_group() 
     184        self.group.join_group() 
    233185        result=self.publish(self.portal.absolute_url_path()+'/community/testgroup') 
    234186        self.failUnless(result.getBody().find('community/foobar') != -1, "When viewing group page anonymously, members are not visible") 
  • trunk/tests/testPiece.py

    r1624 r1930  
    5656        self.failUnlessEqual(ob.source.data, file_text, "Source upload error") 
    5757 
    58     def testWCAGLogo(self): 
    59         ob = self.construct('Piece', 'TestPiece4' ,self.folder) 
    60         #path='/'.join((self.folder.absolute_url_path(),'TestPiece4')) 
    61         path = ob.absolute_url_path()+'/view' 
    62         result = self.publish(path).getBody() 
    63         self.failUnless(result.find("Explanation of Level Double-A Conformance") != -1, "WCAG log not found? It may be possible that user doesn't have access to view object.") 
    64  
    6558def test_suite(): 
    6659    from unittest import TestSuite, makeSuite 
  • trunk/tests/testUsers.py

    r1878 r1930  
    4444        auth="test1:passwd1" 
    4545        self.login('test1') 
    46         result=self.publish(self.portal.absolute_url_path()+'/test1/personalize_form', basic=auth) 
     46        result=self.publish(self.portal.absolute_url_path()+'/community/test1/personalize_form', basic=auth) 
    4747        body=result.getBody() 
    4848        for prop in MEMBER_PROPERTIES: 
Note: See TracChangeset for help on using the changeset viewer.