Exemplo n.º 1
0
def api_media_id_delete(id=None, auth_user=None, api_core=None, request=None):
    u"""Remove a media asset from the shared storage and update informations about it (set status to DELETED)."""
    media = api_core.get_media(spec={u'_id': id})
    if not media:
        raise IndexError(to_bytes(u'No media asset with id {0}.'.format(id)))
    if auth_user._id != media.user_id:
        flask.abort(403, u'You are not allowed to delete media asset with id {0}.'.format(id))
    api_core.delete_media(media)
    return ok_200(u'The media asset "{0}" has been deleted.'.format(media.metadata[u'title']), include_properties=False)
Exemplo n.º 2
0
def delete_medias(request, id):
    u"""Delete a media asset."""
    try:
        auth_user = request.args.get(u'ebuio_u_pk') or request.form.get(u'ebuio_u_pk')
        media = api_core.get_media(spec={u'_id': id})
        if not media:
            return {u'errors': [u'No media asset with id {0}.'.format(id)]}
        if auth_user != media.user_id:
            return {u'errors': [u'You are not allowed to delete media asset with id {0}.'.format(id)]}
        api_core.delete_media(media)
        return {u'infos': [u'The media asset "{0}" has been deleted.'.format(media.metadata[u'title'])]}
    except Exception as e:
        logging.exception(e)
        return {u'errors': [unicode(e)]}