Changeset 400 in main


Ignore:
Timestamp:
10/17/11 14:38:02 (8 years ago)
Author:
pcosquer
Message:

models: store relative paths

Location:
trunk/openPLM/plmapp
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/openPLM/plmapp/controllers/document.py

    r379 r400  
    277277            filename = doc_file.filename 
    278278            path = models.docfs.get_available_name(filename) 
    279             shutil.copy(doc_file.file.path, path) 
     279            shutil.copy(doc_file.file.path, models.docfs.path(path)) 
    280280            new_doc = models.DocumentFile.objects.create(file=path, 
    281281                filename=filename, size=doc_file.size, document=rev.object) 
  • trunk/openPLM/plmapp/models.py

    r399 r400  
    646646        md5.update(basename) 
    647647        md5_value = md5.hexdigest() + "-%s" + ext 
    648         path = os.path.join(settings.DOCUMENTS_DIR, ext2, md5_value % rand()) 
     648        path = os.path.join(ext2, md5_value % rand()) 
    649649        while os.path.exists(path): 
    650             path = os.path.join(settings.DOCUMENTS_DIR, ext2, md5_value % rand()) 
     650            path = os.path.join(ext2, md5_value % rand()) 
    651651        return path 
    652652 
  • trunk/openPLM/plmapp/tests/controllers/document.py

    r379 r400  
    149149        self.assertEqual(f2.size, f.size) 
    150150        self.assertEqual(f2.file.read(), "data") 
    151         self.assertEqual(file(f2.file.name).read(), "data") 
     151        self.assertEqual(file(f2.file.path).read(), "data") 
    152152        self.assertEqual(os.path.splitext(f2.file.name)[1], ".txt") 
    153153        self.failIf("temp" in f2.file.path) 
    154         self.failUnless(f2.file.name.startswith(os.path.join( 
    155             settings.DOCUMENTS_DIR, "txt"))) 
     154        self.failUnless(f2.file.path.startswith(settings.DOCUMENTS_DIR)) 
    156155        self.failUnless(os.access(f2.file.path, os.F_OK)) 
    157156        self.failUnless(os.access(f2.file.path, os.R_OK)) 
Note: See TracChangeset for help on using the changeset viewer.