Changeset 3807


Ignore:
Timestamp:
8 Dec 2008, 16:12:01 (16 years ago)
Author:
Henrik Bettermann
Message:

resolve ticket #589 part 2

File:
1 edited

Legend:

Unmodified
Added
Removed
  • WAeUP_SRP/trunk/WAeUPTool.py

    r3806 r3807  
    12291229    def removePictureFolder(self,student_id):
    12301230        """remove picture_folder by renaming it"""
    1231         path = 'images'
    1232         picture_path = os.path.join(i_home,path,student_id)
    1233         if not os.path.exists(picture_path):
     1231        picture_path = getImagesDir(student_id)
     1232        dest_path = os.path.join("%s" % images_base,'removed',student_id)
     1233        dest_path = dest_path + "_removed"
     1234        if os.path.exists(dest_path) or not os.path.exists(picture_path):
    12341235            return False
    1235         os.rename(picture_path,picture_path + "_removed")
     1236        os.rename(picture_path,dest_path)
    12361237        return True
    12371238    ###)
     
    12401241    def restorePictureFolder(self,student_id):
    12411242        """restore picture_folder by renaming it"""
    1242         path = 'images'
    1243         picture_path = os.path.join(i_home,path,student_id)
    1244         if not os.path.exists(picture_path + "_removed"):
    1245             return False
     1243        picture_path = getImagesDir(student_id)
     1244        orig_path = os.path.join("%s" % images_base,'removed',student_id)
     1245        orig_path = orig_path + "_removed"
     1246        if os.path.exists(picture_path) or not os.path.exists(orig_path):
     1247            return False       
    12461248        os.rename(picture_path + "_removed",picture_path)
    12471249        return True
     
    12641266   
    12651267   
    1266     security.declareProtected(ModifyPortalContent,'findUnusedImageFolders') ###(
    1267     def findUnusedImageFolders(self):
     1268    security.declareProtected(ModifyPortalContent,'removeUnusedImageFolders') ###(
     1269    def removeUnusedImageFolders(self):
    12681270        """check if an unused image folders exists in the filesystem"""
    1269 
     1271        mtool = self.portal_membership
     1272        member = mtool.getAuthenticatedMember()
     1273        member_id = str(member)
     1274        logger = logging.getLogger('WAeUPTool.removeUnusedImageFolders')
    12701275        abc = os.listdir(images_base)
    12711276        ifolders = []
     
    12741279            ifolders.extend(os.listdir(picture_path))
    12751280        unused_ids = []
    1276         used_ids = []
    12771281        for id in ifolders:
    12781282            res = self.students_catalog(id=id)
    12791283            if not res:
    12801284                unused_ids.append(id)
    1281             else:
    1282                 used_ids.append(id)
    1283         return unused_ids
     1285                #import pdb;pdb.set_trace()   
     1286                if not id.endswith('removed'):
     1287                    removed = self.waeup_tool.removePictureFolder(id) 
     1288                    if removed:
     1289                        logger.info('%s: image folder %s successfully removed' % (member_id,id))
     1290                    else:
     1291                        logger.info('%s: image folder %s could not be removed' % (member_id,id))
     1292        return
    12841293       
    12851294    ###)   
Note: See TracChangeset for help on using the changeset viewer.