Changeset 73


Ignore:
Timestamp:
01/13/06 15:28:26 (14 years ago)
Author:
laszlo
Message:

Change module into material, but templates have not been done yet. refs #167 spent 2h remaining 2h

Location:
trunk
Files:
6 edited
3 moved

Legend:

Unmodified
Added
Removed
  • trunk/LOM.py

    r67 r73  
    4141    top_element = document.documentElement 
    4242     
    43     if object.meta_type=='Module': 
     43    if object.meta_type=='Material': 
    4444        general = addNode(top_element, "general") 
    4545        general_identifier = addNode(general, "identifier") 
     
    7878def constructLOM(folder): 
    7979    id = folder.generateUniqueId() 
    80     folder.invokeFactory(type_name='Module',id=id) 
     80    folder.invokeFactory(type_name='Material',id=id) 
    8181    return getattr(folder,id) 
    8282 
  • trunk/Material.py

    r69 r73  
    11from Products.Archetypes.public import BaseSchema, Schema, MetadataSchema 
    2 from Products.Archetypes.public import StringField, LinesField, TextField 
     2from Products.Archetypes.public import ReferenceField 
    33from Products.Archetypes.public import LinesWidget, TextAreaWidget, IdWidget, StringWidget, SelectionWidget 
    44from Products.Archetypes.public import BaseContent, registerType 
     
    1414 
    1515schema = BaseSchema + LOMSchema + Schema(( 
    16     WYSIWYMField('body', 
    17         required=True, 
    18         primary=False, 
    19         languageIndependent=False, 
    20         widget=WYSIWYMWidget( 
    21             label="Body", 
    22             label_msgid="label_body", 
    23             description="Module body", 
    24             description_msgid="desc_body", 
    25             i18n_domain="toolbox",), 
    26         ), 
     16    ReferenceField('references', 
     17        relationship='Contains', 
     18        allowed_types=('Piece','Material'), 
     19        multiValued=True 
     20    ), 
    2721)) 
    2822 
    29 class Module(BaseContent): 
     23class Material(BaseContent): 
    3024    schema = schema 
    3125    actions = ( 
    3226        {'id':'view', 
    3327         'name':'view', 
    34          'action':'string:${object_url}/module_view', 
     28         'action':'string:${object_url}/material_view', 
    3529         'permission':('View',), 
    3630        }, 
    37     ) 
    38     meta_type = "Module" 
    39     archetype_name = "Module 
     31    )     
     32    meta_type = "Material" 
     33    archetype_name = "Material 
    4034    global_allow = 1 
    4135 
     
    8175        return user.getId() in users 
    8276 
    83 registerType(Module, PROJECTNAME) 
     77registerType(Material, PROJECTNAME) 
  • trunk/Piece.py

    r68 r73  
    77from AccessControl import ClassSecurityInfo, Unauthorized 
    88from config import PROJECTNAME 
     9from WYSIWYM import WYSIWYMField, WYSIWYMWidget 
    910 
    1011ERROR_NOT_BOTH = "You cannot upload a file, if you wrote the content!" 
    1112 
    1213schema = BaseSchema + Schema(( 
    13     TextField('body', 
    14         searchable = True, 
    15         validators = ('IsTidyHtmlWithCleanup',), 
    16         default_output_type = "text/x-html-safe", 
    17         widget=VisualWidget( 
     14    WYSIWYMField('body', 
     15        #searchable = True, 
     16        #validators = ('IsTidyHtmlWithCleanup',), 
     17        #default_output_type = "text/x-html-safe", 
     18        widget=WYSIWYMWidget( 
    1819            label="Piece body", 
    1920            label_msgid="label_piece_body", 
  • trunk/__init__.py

    r68 r73  
    1313 
    1414# Our own content types 
    15 import Piece, Module, SyndicatedFolder, Story, Activity, Tool 
     15import Piece, Material, SyndicatedFolder, Story, Activity, Tool 
    1616 
    1717# Our own portal tools 
  • trunk/skins/toolbox/material_view.pt

    r67 r73  
    3737            Description 
    3838        </p> 
    39  
    40     <p class="stx" 
    41         tal:replace="structure here/getBody"> 
    42             Content 
    43     </p> 
    4439     
    4540        <div metal:use-macro="here/document_relateditems/macros/relatedItems"> 
  • trunk/tests/testLOM.py

    r67 r73  
    1919        LOMID='IDtest' 
    2020        LOMCOV='coverageTest' 
    21         ob=self.construct('Module', 'TestModule' ,self.folder) 
     21        ob=self.construct('Material', 'TestLOMMaterial' ,self.folder) 
    2222        ob.edit( 
    2323            description='Test description', 
     
    3030        xml2 = re.sub(r'<identifier>(.*?)</identifier>', '', xml2)         
    3131        self.failUnless(xml==xml2,"Import and export are out of sync: %s %s" % (xml, xml2)) 
    32         #raise 'FOO', xml     
    3332         
    3433def test_suite(): 
  • trunk/tests/testMaterial.py

    r69 r73  
    1 # 
    2 # Test case for Module content 
    3 # 
    4  
    51import os, sys, re 
    62if __name__ == '__main__': 
     
    117from ToolboxTestCase import ToolboxTestCase 
    128from Products.CMFCore.utils import getToolByName 
    13 from Products.Toolbox.Module import Module 
     9from Products.Toolbox.Material import Material 
    1410from Products.Toolbox.ToolboxMember import getToolboxMember 
    1511 
    16 types = ('Module',) 
     12types = ('Material',) 
    1713 
    18 class TestModule(ToolboxTestCase): 
     14class TestMaterial(ToolboxTestCase): 
    1915 
    2016    def afterSetUp(self): 
     
    2925    def testEditing(self): 
    3026        TITLE='Test' 
    31         LOMID='IDtest' 
    3227        LOMCOV='coverageTest' 
    33         ob=self.construct('Module', 'TestModule' ,self.folder) 
    34         ob.edit(title=TITLE, LOMIdentifier=LOMID, LOMCoverage=LOMCOV) 
    35         self.assertEqual(self.folder.TestModule.Title(), TITLE) 
    36         self.assertEqual(self.folder.TestModule.getLOMCoverage(), LOMCOV) 
     28        ob=self.construct('Material', 'TestMaterial' ,self.folder) 
     29        ob.edit(title=TITLE, LOMCoverage=LOMCOV) 
     30        self.assertEqual(self.folder.TestMaterial.Title(), TITLE) 
     31        self.assertEqual(self.folder.TestMaterial.getLOMCoverage(), LOMCOV) 
    3732        
    38     def testBody(self):     
    39         TITLE='Test' 
    40         LOMCOV='coverageTest' 
    41         BODY='Visible body' 
    42         ob=self.construct('Module', 'TestModule' ,self.folder) 
    43         ob.edit(title=TITLE, LOMCoverage=LOMCOV, body=BODY) 
    44         path=ob.absolute_url_path() 
    45         result=self.publish(path).getBody() 
    46         #raise "FOO",str(result) 
    47         self.failUnless(re.search(BODY, result),"The 'Visible body' is not shown.") 
    48  
    49 class TestModuleUse(ToolboxTestCase): 
     33class TestMaterialUse(ToolboxTestCase): 
    5034 
    5135    def afterSetUp(self): 
    52         self.ID='TestModule' 
    53         self.ob=self.construct('Module',self.ID,self.folder) 
     36        self.ID='TestMaterial' 
     37        self.ob=self.construct('Material',self.ID,self.folder) 
    5438        self.addUser('foobar','foobar') 
    5539 
    5640    def testUseLogic(self): 
    5741        self.login('foobar') 
    58         self.failIf(self.ob.isUsedByUser(),"Module is prematurely used by user") 
     42        self.failIf(self.ob.isUsedByUser(),"Material is prematurely used by user") 
    5943        self.ob.useThis() 
    60         self.failUnless(self.ob.isUsedByUser(),"Module use isn't stored") 
     44        self.failUnless(self.ob.isUsedByUser(),"Material use isn't stored") 
    6145        self.ob.unuseThis() 
    62         self.failIf(self.ob.isUsedByUser(),"Module unuse isn't stored") 
     46        self.failIf(self.ob.isUsedByUser(),"Material unuse isn't stored") 
    6347 
    6448    def testUseLogicMemberData(self): 
     
    6650        member = getToolboxMember('foobar',self.portal) 
    6751        self.failIf(self.ob.getId() in member.getTokens('used_content'), 
    68                     "Module is prematurely used by user in user data") 
     52                    "Material is prematurely used by user in user data") 
    6953        self.ob.useThis() 
    7054        self.failUnless(self.ob.getId() in member.getTokens('used_content'), 
    71                     "Module use isn't stored in user data") 
     55                    "Material use isn't stored in user data") 
    7256        self.ob.unuseThis() 
    7357        self.failIf(self.ob.getId() in member.getTokens('used_content'), 
    74                     "Module unuse isn't stored in user data") 
     58                    "Material unuse isn't stored in user data") 
    7559 
    7660    def testUseLogicUI(self): 
     
    10387    from unittest import TestSuite, makeSuite 
    10488    suite = TestSuite() 
    105     suite.addTest(makeSuite(TestModule)) 
    106     suite.addTest(makeSuite(TestModuleUse)) 
     89    suite.addTest(makeSuite(TestMaterial)) 
     90    suite.addTest(makeSuite(TestMaterialUse)) 
    10791    return suite 
    10892 
  • trunk/tests/testPiece.py

    r68 r73  
    3131    def testEditing(self): 
    3232        TITLE='Test' 
    33         BODY='<p>Test paragraph</p>' 
     33        BODY='Test paragraph' 
    3434        ob=self.construct('Piece', 'TestPiece2' ,self.folder) 
    3535        ob.edit(title=TITLE, body=BODY) 
    3636        self.assertEqual(ob.Title(), TITLE) 
    37         self.assertEqual(ob.getBody(), BODY) 
     37        self.assertEqual(ob.getBody(), '<p>' + BODY + '</p>') 
    3838 
    3939    def testCompatibilityFileAccess(self): 
  • trunk/tests/testWYSIWYM.py

    r66 r73  
    1212from Products.PloneTestCase.setup import portal_owner, default_password 
    1313 
    14 types = ('Module',) 
    1514auth=':'.join((portal_owner, default_password)) 
    1615 
     
    1817 
    1918    def afterSetUp(self): 
    20         self.ID='TestModule' 
     19        self.ID='TestPiece' 
    2120        self.addUser('foobar','foobar') 
    22         self.ob=self.construct('Module',self.ID,self.folder) 
     21        self.ob=self.construct('Piece',self.ID,self.folder) 
    2322 
    2423    #~ def testEditing(self): 
Note: See TracChangeset for help on using the changeset viewer.