コード例 #1
0
ファイル: response.py プロジェクト: markdav-is/15thnight
def delete_response(uuid):
    """
    Delete a response to an alert.
    """
    return 'Not Implemented', 501 # We currently don't support a UI for this
    alert = Alert.get(uuid)
    if not alert:
        return api_error('Alert not found.', 404)
    if current_user.role == 'advocate' and alert.user.id != current_user.id:
        return api_error('Forbidden.', 403)

    alert.delete()
    return '', 202
コード例 #2
0
ファイル: alert.py プロジェクト: spectralsun/15thnight
def delete_alert(id):
    """
    Delete an alert.
    """
    return 'Not Implemented', 501 # We do not support a UI for this
    if current_user.role == 'advocate':
        alert = Alert.get_user_alert(current_user, id)
    else:
        alert = Alert.get(id)
    if not alert:
        return api_error('No alert was found.', 404)

    alert.delete()
    return '', 200
コード例 #3
0
def delete_alert(id):
    """
    Delete an alert.
    """
    return 'Not Implemented', 501  # We do not support a UI for this
    if current_user.role == 'advocate':
        alert = Alert.get_user_alert(current_user, id)
    else:
        alert = Alert.get(id)
    if not alert:
        return api_error('No alert was found.', 404)

    alert.delete()
    return '', 200
コード例 #4
0
ファイル: alert.py プロジェクト: spectralsun/15thnight
def get_alert(alert_id):
    alert = Alert.get(alert_id)
    if not alert:
        return api_error('Alert not found')
    if current_user.role == 'provider':
        if not alert.provider_has_permission(current_user):
            return api_error('Permission denied')
        data = alert.to_provider_json(current_user)
    elif current_user.role == 'advocate':
        if alert.user.id != current_user.id:
            return api_error('Permission denied')
        data = alert.to_advocate_json()
    else: # is an admin
        data = alert.to_json()
    return jsonify(data)
コード例 #5
0
def get_alert(alert_id):
    alert = Alert.get(alert_id)
    if not alert:
        return api_error('Alert not found')
    if current_user.role == 'provider':
        if not alert.provider_has_permission(current_user):
            return api_error('Permission denied')
        data = alert.to_provider_json(current_user)
    elif current_user.role == 'advocate':
        if alert.user.id != current_user.id:
            return api_error('Permission denied')
        data = alert.to_advocate_json()
    else: # is an admin
        data = alert.to_advocate_json()
    return jsonify(data)
コード例 #6
0
def resolve_all_alert_needs(alert_id):
    alert = Alert.get(alert_id)
    if not alert:
        return api_error('Alert not found')

    for need in alert.needs:
        need.resolved = True
        need.resolved_at = datetime.utcnow()
        need.save(False)

    alert.save()

    if ('notifyProvidersAllResolved' in request.json and
        request.json['notifyProvidersAllResolved']):
        send_out_alert_closed(alert)

    return '', 200
コード例 #7
0
ファイル: response.py プロジェクト: markdav-is/15thnight
def create_response():
    """
    Create a response to an alert.

    POST params:
        - alert_id: alert identifier
        - message: response message
    """
    if 'alert_id' not in request.json or 'needs_provided' not in request.json:
        return api_error('Invalid form')

    alert = Alert.get(int(request.json['alert_id']))

    if not alert:
        return api_error('Alert not found.', 404)

    respond_to_alert(current_user, request.json['needs_provided'], alert)

    return '', 201