Changeset 6

Show
Ignore:
Timestamp:
08/04/06 05:47:11 (4 years ago)
Author:
matt_dorn@yahoo.com
Message:

0.3.1--document locking solution and other changes

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • Extensions/xl8_translation_workflow.py

    r4 r6  
    9090    stateDef.setPermission('Modify portal content', 
    9191                           0, 
    92                            ['Member', 'Manager', 'Owner']) 
     92                           ['Manager', 'Owner']) 
    9393 
    9494    stateDef = workflow.states['proofread'] 
     
    216216                                actbox_url="""""", 
    217217                                actbox_category="""workflow""", 
    218                                 props={}, 
     218                                props={'guard_roles': 'Owner;Manager'}, 
    219219                                ) 
    220220 
  • Extensions/xl8_translation_workflow_scripts.py

    r4 r6  
    3232from Products.CMFCore.utils import getToolByName 
    3333from Products.LinguaPlone.I18NBaseObject import AlreadyTranslated 
     34from DateTime import DateTime 
    3435##/code-section workflow-script-header 
    3536 
     
    4950    obj=state_change.object 
    5051    langtool=getToolByName(self, 'portal_languages') 
    51     lang=langtool.getPreferredLanguage() 
     52    lang=obj.getOriginalLang() 
     53    # apply original language chosen in the form, otherwise 
     54    # get the language of the current interface 
     55    if not lang: 
     56        lang=langtool.getPreferredLanguage() 
    5257    factory_tool=getToolByName(self, 'portal_factory') 
    5358    new_context=factory_tool.doCreate(obj) 
    5459    new_context.plone_utils.editMetadata(new_context, 
    5560                                     language=lang) 
     61 
    5662    # generate the translation content objects for the requested languages 
    5763    langs=obj.getRequestedLangs() 
     
    7783        putils.changeOwnershipOf(obj, member) 
    7884 
    79  
     85    # update the modification time 
     86    now=DateTime() 
     87    obj.getField('translationModTime').set(obj, now) 
  • content/TranslationDoc.py

    r4 r6  
    4545##code-section module-header #fill in your manual code here 
    4646from Products.CMFCore.utils import getToolByName 
     47from DateTime import DateTime 
    4748##/code-section module-header 
    4849 
     
    7071    ), 
    7172 
    72     #NOTE: ideally, the vocabulary would be dynamically generated and 
    73     #managed with ATVocabularyManager, but I can't get ordering to 
    74     #work correctly. 
    75     StringField( 
    76         name='documentType', 
    77         index="FieldIndex:Schema", 
     73    StringField( 
     74        name='originalLang', 
    7875        widget=SelectionWidget( 
    79             label="Document type", 
    80             label_msgid='PloneXL8_label_documentType', 
    81             i18n_domain='PloneXL8', 
    82         ), 
    83         enforceVocabulary=True, 
    84         searchable=1, 
    85         vocabulary=['Public SF', 'Internal SF', 'Babels'], 
    86         default='Public SF', 
    87         required=True, 
    88         languageIndependent=1 
    89     ), 
    90  
    91     #NOTE: ideally, the vocabulary would be dynamically generated and 
    92     #managed with ATVocabularyManager, but I can't get ordering to 
    93     #work correctly. 
    94     StringField( 
    95         name='urgency', 
    96         index="FieldIndex:schema", 
    97         widget=SelectionWidget( 
    98             label="Urgency", 
    99             label_msgid='PloneXL8_label_urgency', 
    100             i18n_domain='PloneXL8', 
    101         ), 
    102         enforceVocabulary=True, 
    103         searchable=1, 
    104         vocabulary=['Normal', 'Urgent', 'Super Urgent'], 
    105         default='Normal', 
    106         required=True, 
    107         languageIndependent=1 
    108     ), 
    109  
    110     DateTimeField( 
    111         name='dueDate', 
    112         index="DateRangeIndex:schema", 
    113         widget=CalendarWidget( 
    114             label="Translation due date", 
    115             label_msgid='PloneXL8_label_dueDate', 
     76            label="Language of original document", 
     77            label_msgid='PloneXL8_label_originalLang', 
    11678            i18n_domain='PloneXL8', 
    11779        ), 
    11880        languageIndependent=1, 
    119         searchable=1 
    120     ), 
    121  
    122     DateTimeField( 
    123         name='proofDueDate', 
    124         index="DateRangeIndex:schema", 
    125         widget=CalendarWidget( 
    126             label="Translation proofreading due date", 
    127             label_msgid='PloneXL8_label_proofDueDate', 
    128             i18n_domain='PloneXL8', 
    129         ), 
    130         languageIndependent=1, 
    131         searchable=1 
    132     ), 
    133  
    134     StringField( 
    135         name='isSource', 
    136         index="FieldIndex:schema", 
    137         widget=StringWidget( 
    138             label="Original document?", 
    139             visible=0, 
    140             label_msgid='PloneXL8_label_isSource', 
    141             i18n_domain='PloneXL8', 
    142         ), 
    143         enforceVocabulary=1, 
    144         searchable=1, 
    145         vocabulary=['Yes', 'No'], 
    146         default="Yes", 
    147         required=1, 
    148         accessor="isDocSource" 
    149     ), 
    150  
    151     #Make this default ATCT field disappear. There must be a better 
    152     #way to do this. Do NOT change the 'Visible' field. 
    153     StringField( 
    154         name='relatedItems', 
    155         default=['dummy',], 
    156         widget=StringWidget( 
    157             visible=0, 
    158             label='Relateditems', 
    159             label_msgid='PloneXL8_label_relatedItems', 
    160             i18n_domain='PloneXL8', 
    161         ), 
    162         languageIndependent=1 
    163     ), 
    164  
    165     #Make this default ATCT field disappear. There must be a better 
    166     #way to do this. Do NOT change the 'visible' field. 
    167     StringField( 
    168         name='allowDiscussion', 
    169         default=['dummy',], 
    170         widget=StringWidget( 
    171             visible=0, 
    172             label='Allowdiscussion', 
    173             label_msgid='PloneXL8_label_allowDiscussion', 
    174             i18n_domain='PloneXL8', 
    175         ), 
    176         languageIndependent=1 
    177     ), 
    178  
    179     StringField( 
    180         name='sourceLanguage', 
    181         index="FieldIndex:Schema", 
    182         widget=StringWidget( 
    183             label="Source language (if translation)", 
    184             label_msgid='PloneXL8_label_sourceLanguage', 
    185             i18n_domain='PloneXL8', 
    186         ), 
    187         mode="r", 
    188         searchable=1, 
    189         accessor="getSourceLanguage" 
     81        vocabulary="getAllLanguages" 
    19082    ), 
    19183 
     
    20395        multiValued=1, 
    20496        vocabulary="getLanguageList" 
     97    ), 
     98 
     99    #NOTE: ideally, the vocabulary would be dynamically generated and 
     100    #managed with ATVocabularyManager, but I can't get ordering to 
     101    #work correctly. 
     102    StringField( 
     103        name='documentType', 
     104        index="FieldIndex:Schema", 
     105        widget=SelectionWidget( 
     106            label="Document type", 
     107            label_msgid='PloneXL8_label_documentType', 
     108            i18n_domain='PloneXL8', 
     109        ), 
     110        enforceVocabulary=True, 
     111        searchable=1, 
     112        vocabulary=['Public SF', 'Internal SF', 'Babels'], 
     113        default='Public SF', 
     114        required=True, 
     115        languageIndependent=1 
     116    ), 
     117 
     118    #NOTE: ideally, the vocabulary would be dynamically generated and 
     119    #managed with ATVocabularyManager, but I can't get ordering to 
     120    #work correctly. 
     121    StringField( 
     122        name='urgency', 
     123        index="FieldIndex:schema", 
     124        widget=SelectionWidget( 
     125            label="Urgency", 
     126            label_msgid='PloneXL8_label_urgency', 
     127            i18n_domain='PloneXL8', 
     128        ), 
     129        enforceVocabulary=True, 
     130        searchable=1, 
     131        vocabulary=['Normal', 'Urgent', 'Super Urgent'], 
     132        default='Normal', 
     133        required=True, 
     134        languageIndependent=1 
     135    ), 
     136 
     137    DateTimeField( 
     138        name='dueDate', 
     139        index="DateRangeIndex:schema", 
     140        widget=CalendarWidget( 
     141            label="Translation due date", 
     142            label_msgid='PloneXL8_label_dueDate', 
     143            i18n_domain='PloneXL8', 
     144        ), 
     145        languageIndependent=1, 
     146        searchable=1 
     147    ), 
     148 
     149    DateTimeField( 
     150        name='proofDueDate', 
     151        index="DateRangeIndex:schema", 
     152        widget=CalendarWidget( 
     153            label="Translation proofreading due date", 
     154            label_msgid='PloneXL8_label_proofDueDate', 
     155            i18n_domain='PloneXL8', 
     156        ), 
     157        languageIndependent=1, 
     158        searchable=1 
     159    ), 
     160 
     161    StringField( 
     162        name='isSource', 
     163        index="FieldIndex:schema", 
     164        widget=StringWidget( 
     165            label="Original document?", 
     166            visible=0, 
     167            label_msgid='PloneXL8_label_isSource', 
     168            i18n_domain='PloneXL8', 
     169        ), 
     170        enforceVocabulary=1, 
     171        searchable=1, 
     172        vocabulary=['Yes', 'No'], 
     173        default="Yes", 
     174        required=1, 
     175        accessor="isDocSource" 
     176    ), 
     177 
     178    #Make this default ATCT field disappear. There must be a better 
     179    #way to do this. Do NOT change the 'Visible' field. 
     180    StringField( 
     181        name='relatedItems', 
     182        default=['dummy',], 
     183        widget=StringWidget( 
     184            visible=0, 
     185            label='Relateditems', 
     186            label_msgid='PloneXL8_label_relatedItems', 
     187            i18n_domain='PloneXL8', 
     188        ), 
     189        languageIndependent=1 
     190    ), 
     191 
     192    #Make this default ATCT field disappear. There must be a better 
     193    #way to do this. Do NOT change the 'visible' field. 
     194    StringField( 
     195        name='allowDiscussion', 
     196        default=['dummy',], 
     197        widget=StringWidget( 
     198            visible=0, 
     199            label='Allowdiscussion', 
     200            label_msgid='PloneXL8_label_allowDiscussion', 
     201            i18n_domain='PloneXL8', 
     202        ), 
     203        languageIndependent=1 
     204    ), 
     205 
     206    StringField( 
     207        name='sourceLanguage', 
     208        index="FieldIndex:Schema", 
     209        widget=StringWidget( 
     210            label="Source language (if translation)", 
     211            label_msgid='PloneXL8_label_sourceLanguage', 
     212            i18n_domain='PloneXL8', 
     213        ), 
     214        mode="r", 
     215        searchable=1, 
     216        accessor="getSourceLanguage" 
     217    ), 
     218 
     219    DateTimeField( 
     220        name='translationModTime', 
     221        index="FieldIndex:Schema", 
     222        widget=CalendarWidget( 
     223            visible=0, 
     224            label='Translationmodtime', 
     225            label_msgid='PloneXL8_label_translationModTime', 
     226            i18n_domain='PloneXL8', 
     227        ), 
     228        searchable=1, 
     229        mutator="setModDateTime" 
    205230    ), 
    206231 
     
    339364        return langs 
    340365     
     366    security.declarePublic('setModDateTime') 
     367    def setModDateTime(self, value): 
     368        """ 
     369 
     370        """ 
     371        now=DateTime() 
     372        self.getField('translationModTime').set(self, now) 
     373 
     374    security.declarePublic('getAllLanguages') 
     375    def getAllLanguages(self): 
     376        """ 
     377         
     378        """ 
     379        has_lang=self.getCanonicalLanguage() 
     380        if has_lang: 
     381            return [(has_lang, has_lang)] 
     382        else: 
     383            allLanguages = self.portal_languages.listSupportedLanguages() 
     384            allLanguages.sort(lcmp) 
     385            langs=[('', '--')] 
     386            for lang in allLanguages: 
     387                langs.append((lang[0], lang[0] + " (" + lang[1] + ")")) 
     388            return langs 
     389 
    341390    # Manually created methods 
    342391 
     
    358407        workflow = portal.portal_workflow 
    359408        already_translated = self.getTranslationLanguages() 
    360         if workflow.getInfoFor(self, "review_state", "") == "source": 
     409        if (workflow.getInfoFor(self, "review_state", "") and self.REQUEST.form.has_key("requestedLangs"))== "source": 
    361410            # generate the translation content objects for the requested languages 
    362411            # ONLY if the document is already in "source" state and the user wants 
     
    373422                    self.addTranslation(lang) 
    374423         
     424        # update translation modification time (duplicated mutator code here) 
     425        now=DateTime() 
     426        self.getField('translationModTime').set(self, now) 
     427 
    375428    security.declarePublic('getDocTypes') 
    376429    def getDocTypes(self): 
  • content/__init__.py

    r4 r6  
    3636import TranslationCenter 
    3737import TranslationDoc 
     38import value 
    3839 
    3940##code-section init-module-footer #fill in your manual code here 
  • skins/PloneXL8/fieldsNotToShowInTranslationForm.py

    r1 r6  
    99## 
    1010 
    11 return ('id', 'relatedItems', 'allowDiscussion', 'isSource', 'sourceLanguage'
     11return ('id', 'relatedItems', 'allowDiscussion', 'isSource', 'sourceLanguage', 'requestedLangs', 'originalLang', 'translationModTime'
  • skins/PloneXL8/test2.py

    r1 r6  
    1212urltool = getToolByName(context, 'portal_url') 
    1313portal = urltool.getPortalObject() 
    14 folder = getattr(portal, 'qwe') 
    1514 
    16 ##do= dtc.invokeFactory('Document', id='blah14', title="blow me") 
    17 ##doc = getattr(dtc, 'blah14') 
    18 ##doc.edit(title = 'Foo', description='This is a test') 
    19 ##doc.setTitle('Foo2') 
    20 ##doc.setDescription("fuck off") 
    21 ##doc.editMetadata(title='Appointment') 
    22 ##doc.editMetadata(description="boo!") 
    23 ##doc.editMetadata(language='en') 
    24 ##refreshCatalog(self, clear=0) 
    25  
    26 #max=100 
    27 #i=0 
    28 #while i < max: 
    29     #name="doc" + str(i) 
    30     #tit="Document #" + str(i) 
    31     #do=folder.invokeFactory("Document", id=name, title=tit) 
    32     ##doc = getattr(dtc, name) 
    33     ##doc.editMetadata(language='en') 
    34     #print name 
    35     #i=i+1 
    36  
    37 urltool = getToolByName(context, 'portal_url') 
    38 portal = urltool.getPortalObject() 
    39  
    40 wf=getToolByName(context, 'portal_workflow') 
    41 x=wf.getInfoFor(folder, 'review_state', '') 
    42 print x 
    43 
    44 #roles=wf.listWFStatesByTitle(True) 
    45 #chain=wf.getChainForPortalType("TranslationDoc") 
    46 #chainobj= 
    47 #for x in chainobj: 
    48 #    print x 
    49 #for role in roles: 
    50 #    x=wf.getTitleForStateOnType(role[1], "TranslationDoc") 
    51 #    print x 
    52     
    53  
     15now = DateTime() 
     16other =context.getTranslationModTime() 
     17print now 
     18print other 
     19print now - other 
     20print context.isCanonical() 
     21print context.portal_workflow.getInfoFor(context, "review_state", "") 
    5422print "done" 
    5523return printed 
  • tests/testTranslationDoc.py

    r4 r6  
    119119        # only returns [('en', 'English (en)')] 
    120120        # I.E., not really worth testing.... 
     121        pass 
     122 
     123    # from class TranslationDoc: 
     124    def test_setModDateTime(self): 
     125        pass 
     126 
     127    # from class TranslationDoc: 
     128    def test_getAllLanguages(self): 
    121129        pass 
    122130 
  • version.txt

    r4 r6  
    1 0.3 
     10.3.1