예제 #1
0
파일: models.py 프로젝트: jamilatta/opac
def delelte_file_hook(mapper, connection, target):
    if target.path:
        media_root = current_app.config['MEDIA_ROOT']
        # Remover a imagem
        try:
            os.remove(os.path.join(media_root, target.path))
        except OSError:
            pass  # Se der erro não importa, o arquivo já não existe

        # Remover o thumbnail
        try:
            thumb_path = thumbgen_filename(target.path)
            os.remove(os.path.join(media_root, thumb_path))
        except OSError:
            pass  # Se der erro não importa, o arquivo já não existe
예제 #2
0
def delelte_image_hook(mapper, connection, target):
    if target.path:
        media_root = current_app.config['MEDIA_ROOT']
        # Remover a imagem
        try:
            os.remove(os.path.join(media_root, target.path))
        except OSError:
            pass  # Se der erro não importa, o arquivo já não existe

        # Remover o thumbnail
        try:
            thumb_path = thumbgen_filename(target.path)
            os.remove(os.path.join(media_root, thumb_path))
        except OSError:
            pass  # Se der erro não importa, o arquivo já não existe
예제 #3
0
파일: models.py 프로젝트: jamilatta/opac
 def get_thumbnail_absolute_url(self):
     media_url = current_app.config['MEDIA_URL']
     thumb_path = thumbgen_filename(self.path)
     return '%s/%s' % (media_url, thumb_path)
예제 #4
0
 def get_thumbnail_absolute_url(self):
     media_url = current_app.config['MEDIA_URL']
     thumb_path = thumbgen_filename(self.path)
     return '%s/%s' % (media_url, thumb_path)