Example #1
0
def delete_photo_view(request, photo):
    request.app_context.catalog.unindex(photo)
    trash = find_trash(photo)
    trash_id = trash.trash(photo)
    response = HTTPFound(location=model_url(request, photo.__parent__))
    response.set_cookie('undo', 'trash:%s|Photo+deleted.' % trash_id)
    return response
Example #2
0
def undo_view(request, code):
    if not code.startswith('trash:'):
        return None

    # XXX Need security here.  Probably need to add api to trash to be able
    # to retrieve context(s) involved for purposes of security checking, before
    # performing undo operation.
    trash_id = code[6:]
    trash = find_trash(request.context)
    restored = trash.restore(trash_id, request.app_context.catalog)
    response = HTTPFound(location=model_url(request, restored))
    response.set_cookie('undo', '')
    return response
Example #3
0
def delete_photos_view(request, album):
    if request.subpath:
        visibility = request.subpath.pop(0)
    else:
        visibility = None

    photos = []
    for photo in album.photos():
        if visibility is None or photo.visibility == visibility:
            photos.append(photo)

    assert photos, "Nothing to delete."

    catalog = request.app_context.catalog
    catalog.unindex_photos_in_album(album, photos)

    trash = find_trash(album)
    trash_id = trash.trash_photos_in_album(album, photos)

    response = HTTPFound(location=model_url(request, album))
    response.set_cookie('undo', 'trash:%s|Deleted+photos' % trash_id)
    return response