Changeset 2675


Ignore:
Timestamp:
16 Nov 2007, 09:45:30 (17 years ago)
Author:
joachim
Message:

new images directory structure

Location:
WAeUP_SRP/base
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • WAeUP_SRP/base/WAeUPTool.py

    r2670 r2675  
    5454images_base = os.path.join(i_home,"images")
    5555
     56def getImagesDir(student_id):
     57    return os.path.join("%s" % images_base,student_id[0],student_id)
    5658
    5759def getObject(object,name):
     
    468470    ###)
    469471
     472
    470473    security.declarePublic('loadStudentFoto') ###(
    471474    def loadStudentFoto(self,student,filename,folder):
     
    474477        picture ="%s/import/%s/%s" % (i_home,folder,filename)
    475478        student_id = student.getId()
    476         images_dir = os.path.join("%s" % images_base,student_id)
     479        images_dir = getImagesDir(student_id)
    477480        if not os.path.exists(images_dir):
    478481            os.mkdir(images_dir)
     
    847850                                                              brain.screening_type,
    848851                                                              brain.reg_no)
    849         images_dir = os.path.join("%s" % images_base,student_id)
     852        images_dir = getImagesDir(student_id)
     853        #images_dir = os.path.join("%s" % images_base,student_id)
     854        letter_dir,student_dir = os.path.split(images_dir)
     855        if not os.path.exists(letter_dir):
     856            os.mkdir(letter_dir)
    850857        if not os.path.exists(images_dir):
    851858            os.mkdir(images_dir)
     
    946953        if student_id is None:
    947954            return False
    948         picture_path = os.path.join(images_base,student_id)
     955        picture_path = getImagesDir(student_id)
     956        #picture_path = os.path.join(images_base,student_id)
    949957        if not os.path.exists(picture_path):
    950958            return False
     
    967975    def showFsPicture(self,path):
    968976        """return a picture from the filesystem"""
    969         picture_path = os.path.join(i_home,path)
     977        #picture_path = os.path.join(i_home,path)
     978        picture_path = os.path.join(images_base,path)
    970979        response = self.REQUEST.RESPONSE
    971980        #import pdb;pdb.set_trace()
     
    18511860    def moveImagesToFS(self,student_id="O738726"):
    18521861        "move the images to the filesystem"
    1853         images_dir = os.path.join("%s" % images_base,student_id)
     1862        images_dir = getImagesDir(student_id)
     1863        #images_dir = os.path.join("%s" % images_base,student_id)
    18541864        student_folder = getattr(self.portal_url.getPortalObject().campus.students,student_id)
    18551865        stool = getToolByName(self, 'portal_schemas')
  • WAeUP_SRP/base/Widgets.py

    r2663 r2675  
    2121from Products.WAeUP_SRP.Students import getStudentByRegNo
    2222from Products.WAeUP_SRP.Academics import makeCertificateCode
     23from Products.WAeUP_SRP.WAeUPTool import getImagesDir
    2324#from Products.ExtFile.ExtFile import ExtFile
    2425import logging,os,re
     
    18041805    )
    18051806    path = "images"
    1806     storage_path = "%s/%s" % (i_home,path)
     1807    #storage_path = "%s/%s" % (i_home,path)
    18071808    id_field = ""
    18081809    show_image = False
     
    18141815        else:
    18151816            student_id = datastructure[self.id_field]
    1816         student_path = os.path.join(self.storage_path,
    1817                                     student_id)
     1817        # student_path = os.path.join(self.storage_path,
     1818        #                             student_id)
     1819        student_path = getImagesDir(student_id)
    18181820        image_name = ''
    18191821        content_url = ''
     
    18271829            info['image_name'] = image_name
    18281830            info['content_url'] = os.path.join(self.portal_url(),
    1829                                    "viewimage",
    1830                                    self.path,
    1831                                    student_id,
    1832                                    image_name,
    1833                                    )
    1834             info['current_filename'] = os.path.join(student_id,
    1835                                                     image_name)
    1836             info['file_path'] = os.path.join(self.storage_path,
    1837                                              info['current_filename'])
     1831                                               "viewimage",
     1832                                               student_id,
     1833                                               image_name,
     1834                                              )
     1835            info['current_filename'] =  image_name
     1836            info['file_path'] = os.path.join(student_path, image_name)
    18381837        return info
    18391838
     
    19451944            student_id = datastructure[self.id_field]
    19461945        if student_id is not None:
    1947             student_path = os.path.join(self.storage_path,student_id)
     1946            # student_path = os.path.join(self.storage_path,
     1947            #                             student_id)
     1948            student_path = getImagesDir(student_id)
    19481949            if not os.path.exists(student_path):
    19491950                self.waeup_tool.moveImagesToFS(student_id)
     
    20382039                file.content_type = mimetype
    20392040            # Store the file in the filesystem
    2040             student_path = os.path.join(self.storage_path,student_id)
     2041            #student_path = os.path.join(self.storage_path,student_id)
     2042            student_path = getImagesDir(student_id)
    20412043            if not os.path.exists(student_path):
    20422044                os.mkdir(student_path)
  • WAeUP_SRP/base/skins/waeup_utilities/viewimage.py

    r2335 r2675  
    1717        pass
    1818if path is None and traverse_subpath:
     19    traverse_subpath.insert(0,traverse_subpath[0][0])
    1920    path = "/".join(traverse_subpath)
     21       
     22#set_trace()
    2023return context.waeup_tool.showFsPicture(path)
    2124#import logging
Note: See TracChangeset for help on using the changeset viewer.