Changeset 1551 in main for trunk


Ignore:
Timestamp:
07/24/12 14:43:25 (9 years ago)
Author:
pcosquer
Message:

gdoc: clone: also clone the document stored by google

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/openPLM/apps/gdoc/models.py

    r1271 r1551  
    101101        raise exc.DeleteFileError() 
    102102 
     103    def clone(self, *args, **kwargs): 
     104        c = super(GoogleDocumentController, self).clone(*args, **kwargs) 
     105        # try to copy the document in google docs 
     106        if not hasattr(self, "client"): 
     107            # TODO errors 
     108            try: 
     109                self.init_gclient() 
     110            except InvalidCredentialException: 
     111                return 
     112        entry = self.client.get_resource_by_id(self.resource_id) 
     113        copy = self.client.copy_resource(entry, self.name) 
     114        c.object.resource_id = copy.resource_id.text 
     115        c.object.name = self.name 
     116        c.object.save() 
     117        return c 
     118 
     119 
Note: See TracChangeset for help on using the changeset viewer.