Changeset 2889

Show
Ignore:
Timestamp:
09/30/09 16:20:20 (2 years ago)
Author:
jukka
Message:

Fixed #1887

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/LearningResource.py

    r2887 r2889  
    328328        return REQUEST.RESPONSE.redirect('%s/manage_translations' % self.absolute_url()) 
    329329 
    330     security.declareProtected(MANAGE_PORTAL, 'manage_form_setTranslations') 
    331     def manage_form_setTranslations(self, REQUEST): 
     330    security.declareProtected(MANAGE_PORTAL, 'manage_form_removeTranslations') 
     331    def manage_form_removeTranslations(self, REQUEST): 
    332332        """ Allows managers to reorganize which is translated by whom """ 
    333333        lt = getToolByName(self, "lemill_tool") 
    334         oldlist=self.getTranslations() 
    335         folder = self.getSectionFolder() 
    336          
    337         for n in range(len(oldlist)): 
    338             new_id = REQUEST.get('obj_translation%s' % n) 
    339             old_id = REQUEST.get('obj_translation_old%s' % n) 
    340             if new_id != old_id: 
    341                 new=getattr(folder, new_id, None) 
    342                 old=getattr(folder, old_id, None) 
    343                 if new: 
    344                     if new.portal_type == self.portal_type: 
    345                         self.addToTranslations(new.UID()) 
    346                         new.setTranslation_of(self.UID()) 
    347                     else: 
    348                         lt.addPortalMessage("text_message_type_mismatch_cant_translate", default="Type mismatch, cannot be translation of that kind of object.") 
    349                 elif new_id: 
    350                     lt.addPortalMessage("Object not found.")         
    351                 if new and old: 
    352                     self.removeFromTranslations(old.UID()) 
    353                     old.setTranslation_of('') 
    354  
     334        oldlist=self.getTranslations()         
     335        for n, obj in enumerate(oldlist): 
     336            checked = REQUEST.get('obj_translation%s' % n) 
     337            if checked: 
     338                self.removeFromTranslations(obj.UID()) 
     339                obj.setTranslation_of('') 
    355340        return REQUEST.RESPONSE.redirect('%s/manage_translations' % self.absolute_url()) 
    356341 
  • trunk/skins/lemill/manage_translations.pt

    r1995 r2889  
    5555 
    5656        <tal:cond condition="obj_translations"> 
    57      <form name="assign_translations" 
     57     <form name="remove_translations" 
    5858           method="post" 
    5959           class="enableUnloadProtection" 
    60            tal:attributes="action string:${here/absolute_url}/manage_form_setTranslations" 
    61            action="manage_form_setTranslations"> 
     60           tal:attributes="action string:${here/absolute_url}/manage_form_removeTranslations" 
     61           action="manage_form_removeTranslations"> 
    6262 
    6363 
    6464        <ul tal:repeat="trans obj_translations"> 
    6565        <li  tal:define="index repeat/trans/index" > 
    66         <input type="text" tal:attributes="value trans/id; name python:'obj_translation%s' % index" />  
     66        <input type="checkbox" tal:attributes="value trans/id; name python:'obj_translation%s' % index" /> <span tal:replace="trans/id" /> 
    6767        <a href="" tal:content="trans/title" tal:attributes="href string:${trans/absolute_url}/manage_translations" />         
    6868        <input type="hidden" tal:attributes="value trans/id; name python:'obj_translation_old%s' % index" />  
     
    7676           <input class="context" 
    7777                  type="submit" 
    78                   name="form.button.assign_translations" 
    79                   value="Change translations"  
     78                  name="form.button.remove_translations" 
     79                  value="Remove translations"  
    8080                  tal:attributes="tabindex tabindex/next" 
    8181                  /> 
    8282      </div> 
    8383 
    84         <p>You can remove translations by setting the field blank or change translation by writing other objects id in place.</p> 
     84        <p>Select translations you wish to disconnect from this resource or write an id of a new translation to add. </p> 
    8585        <p tal:condition="mother"><b>This is a translation of resource <span tal:replace="mother/id" />, but seems to have translations of its own. These translations should also point to <span tal:replace="mother/id" />.</b></p> 
    8686 
     
    104104                  type="submit" 
    105105                  name="form.button.add_translation" 
    106                   value="Add this as translation"  
     106                  value="Add translation"  
    107107                  tal:attributes="tabindex tabindex/next" 
    108108                  />