Changeset 2413


Ignore:
Timestamp:
22 Oct 2007, 11:48:58 (17 years ago)
Author:
joachim
Message:

modified loadstudentFoto to copy file

File:
1 edited

Legend:

Unmodified
Added
Removed
  • WAeUP_SRP/base/WAeUPTool.py

    r2396 r2413  
    4343from Students import makeCertificateCode
    4444from Globals import package_home,INSTANCE_HOME
    45 p_home = package_home(globals())
    46 i_home = INSTANCE_HOME
    4745import DateTime,time
    4846import logging
    4947import transaction
    5048import csv,re,os,sys
     49from shutil import copy2
    5150from Products.AdvancedQuery import Eq, Between, Le,In
     51
     52p_home = package_home(globals())
     53i_home = INSTANCE_HOME
     54images_base = os.path.join(i_home,"images")
     55
    5256
    5357def getObject(object,name):
     
    374378    def loadStudentFoto(self,student,filename,folder):
    375379        "return a student passport picture"
     380        #import pdb;pdb.set_trace()
     381        picture ="%s/import/%s/%s" % (i_home,folder,filename)
     382        student_id = student.getId()
     383        images_dir = os.path.join("%s" % images_base,student_id)
     384        if not os.path.exists(images_dir):
     385            os.mkdir(images_dir)
     386        image_name = os.path.join(images_dir,"passport_%(student_id)s.jpg" % vars())
     387        for extension in ('.jpg','.JPG'):
     388            fullname = "%(picture)s%(extension)s" % vars()
     389            if os.path.exists(fullname):
     390                copy2(fullname,image_name)
     391                return "successfully copied passport picture"
     392        return "passport picture not found %s.(jpg,.JPG)" % picture
     393    ###)
     394
     395    security.declarePublic('loadStudentFoto') ###(
     396    def old____loadStudentFoto(self,student,filename,folder):
     397        "return a student passport picture"
    376398        app = student.application
    377399        app_doc = app.getContent()
     
    15091531    def moveImagesToFS(self,student_id="O738726"):
    15101532        "move the images to the filesystem"
    1511         images_dir = os.path.join("%s/images" % i_home,student_id)
     1533        images_dir = os.path.join("%s" % images_base,student_id)
    15121534        student_folder = getattr(self.portal_url.getPortalObject().campus.students,student_id)
    15131535        stool = getToolByName(self, 'portal_schemas')
Note: See TracChangeset for help on using the changeset viewer.