示例#1
0
def generate_thumbnails(publication_uid):
    from common.thumbnails import generate_thumbnails, delete_thumbnails
    from domain.models import Publication

    try:
        publication = Publication.objects.get(uid=publication_uid)
    except Publication.DoesNotExist:
        logger.critical(traceback.format_exc(sys.exc_info()[2]))
        return None

    try:
        if publication.has_thumbnail:
            delete_thumbnails(publication)

        publication.has_thumbnail = generate_thumbnails(publication)
    except:
        publication.has_thumbnail = False
        logger.error(traceback.format_exc(sys.exc_info()[2]))

    publication.is_processing = False
    publication.save()

    return publication_uid
示例#2
0
def prepare_publication(publication_uid):

    from common.thumbnails import generate_thumbnails, delete_thumbnails
    from domain.models import Publication

    try:
        publication = Publication.objects.get(uid=publication_uid)
    except:
        logger.critical(traceback.format_exc(sys.exc_info()[2]))
        return None

    # Generate thumbnails

    try:
        if publication.has_thumbnail:
            delete_thumbnails(publication)

        publication.has_thumbnail = generate_thumbnails(publication)
    except:
        publication.has_thumbnail = False
        logger.error(traceback.format_exc(sys.exc_info()[2]))
    
    # Upload publication
    
    from common.fileservers import upload_to_server
    from domain.models import OrganizationUploadServer

    for server in OrganizationUploadServer.objects.filter(organization=publication.organization):
        try:
            upload_to_server(server, publication)
        except:
            logger.error(traceback.format_exc(sys.exc_info()[2]))

    publication.is_processing = False
    publication.save()

    return publication_uid
示例#3
0
def delete_publication(publication):
    if publication.has_thumbnail:
        delete_thumbnails(publication)

    publication.uploaded_file.delete()
    publication.delete()