Exemplo n.º 1
0
def get_or_create_user(username):
    user = User.query.filter_by(username=username).first()
    if user is None:
        user = User(username)
        db.add(user)
        db.commit()
    return user
Exemplo n.º 2
0
def update_event_tracking_status(event_id):
    attribs_required_for_complete_event = 2
    event = get_event(event_id)
    if event.event_type is not None:
        attribs_required_for_complete_event -= 1
    # if event.event_severity is not None:
    #     attribs_required_for_complete_event -= 1
    if event.event_duration is not None:
        attribs_required_for_complete_event -= 1

    if attribs_required_for_complete_event == 0:
        event.event_tracking_status_name = 'COMPLETE'
    elif attribs_required_for_complete_event < 2:
        event.event_tracking_status_name = 'PARTIALLY_COMPLETE'
    else:
        event.event_tracking_status_name = 'CREATED'
    db.commit()
Exemplo n.º 3
0
def update_event_severity(event_id, severity):
    event = get_event(event_id)
    event.event_severity = severity
    db.commit()
Exemplo n.º 4
0
def update_event_duration(event_id, duration):
    event = get_event(event_id)
    event.event_duration = duration
    db.commit()
Exemplo n.º 5
0
def update_event_type(event_id, event_type):
    event = get_event(event_id)
    event.event_type = event_type
    db.commit()
Exemplo n.º 6
0
def update_event(event):
    db.commit()
Exemplo n.º 7
0
def delete_event(event_id):
    Event.query.filter_by(id=event_id).delete()
    db.commit()
Exemplo n.º 8
0
def create_event(user_id, event_time,
                 event_type=None, severity=None, duration=None):
    event = Event(user_id, event_time, event_type, severity, duration)
    db.add(event)
    db.commit()
    return event