Exemplo n.º 1
0
def heartbeat():
    username = request.authorization.username
    extractor = Extractor.query.filter_by(username=username).first()

    extractor.last_contact = datetime.now()
    extractor.save()

    heartbeat_response = json.dumps({"received": request.json})
    slack_body_lines = []
    extractor_department = extractor.first_department()
    if extractor_department:
        slack_body_lines.append('For: {}'.format(extractor_department.name))
    else:
        slack_body_lines.append('Username: {}'.format(username))

    slack_date_line = 'No extraction start date in reply.'

    now = datetime.now()
    next_month = extractor.next_month if extractor.next_month else now.month
    next_year = extractor.next_year if extractor.next_year else now.year

    heartbeat_response = json.dumps({
        "received": request.json,
        "nextMonth": next_month,
        "nextYear": next_year
    })
    slack_date_line = 'Replied with extraction start date: {}/{}'.format(
        next_month, next_year)

    slack_body_lines.append(slack_date_line)
    send_slack_message('Comport Pinged by Extractor!', slack_body_lines)

    return heartbeat_response
Exemplo n.º 2
0
def heartbeat():
    username = request.authorization.username
    extractor = Extractor.query.filter_by(username=username).first()

    extractor.last_contact = datetime.now()
    extractor.save()

    heartbeat_response = json.dumps({"received": request.json})
    slack_body_lines = []
    extractor_department = extractor.first_department()
    if extractor_department:
        slack_body_lines.append('For: {}'.format(extractor_department.name))
    else:
        slack_body_lines.append('Username: {}'.format(username))

    slack_date_line = 'No extraction start date in reply.'

    if extractor.next_month and extractor.next_year:
        heartbeat_response = json.dumps({"received": request.json, "nextMonth": extractor.next_month, "nextYear": extractor.next_year})
        slack_date_line = 'Replied with extraction start date: {}/{}'.format(extractor.next_month, extractor.next_year)

    slack_body_lines.append(slack_date_line)
    send_slack_message('Comport Pinged by Extractor!', slack_body_lines)

    return heartbeat_response
Exemplo n.º 3
0
def heartbeat():
    username = request.authorization.username
    extractor = Extractor.query.filter_by(username=username).first()

    # set the extractor last contact datetime to now
    now = datetime.now()
    extractor.last_contact = now
    extractor.save()

    # get the month and year to tell the extractor to start from
    next_month = extractor.next_month if extractor.next_month else now.month
    next_year = extractor.next_year if extractor.next_year else now.year

    #
    # build and send a Slack notification about this ping
    slack_body_lines = []
    extractor_department = extractor.first_department()
    if extractor_department:
        slack_body_lines.append('For: {}'.format(extractor_department.name))
    else:
        slack_body_lines.append('Username: {}'.format(username))

    slack_date_line = 'No extraction start date in reply.'
    slack_date_line = 'Replied with extraction start date: {}/{}'.format(next_month, next_year)

    slack_body_lines.append(slack_date_line)
    send_slack_message('Comport Pinged by Extractor!', slack_body_lines)

    #
    # remove records for this department from the incidents_updated table
    IncidentsUpdated.delete_records(department_id=extractor_department.id)

    # respond to the extractor
    heartbeat_response = json.dumps({"received": request.json, "nextMonth": next_month, "nextYear": next_year})
    return heartbeat_response
Exemplo n.º 4
0
def heartbeat():
    username = request.authorization.username
    extractor = Extractor.query.filter_by(username=username).first()

    # set the extractor last contact datetime to now
    now = datetime.now()
    extractor.last_contact = now
    extractor.save()

    # get the month and year to tell the extractor to start from
    next_month = extractor.next_month if extractor.next_month else now.month
    next_year = extractor.next_year if extractor.next_year else now.year

    #
    # build and send a Slack notification about this ping
    slack_body_lines = []
    extractor_department = extractor.first_department()
    if extractor_department:
        slack_body_lines.append('For: {}'.format(extractor_department.name))
    else:
        slack_body_lines.append('Username: {}'.format(username))

    slack_date_line = 'No extraction start date in reply.'
    slack_date_line = 'Replied with extraction start date: {}/{}'.format(next_month, next_year)

    slack_body_lines.append(slack_date_line)
    send_slack_message('Comport Pinged by Extractor!', slack_body_lines)

    #
    # remove records for this department from the incidents_updated table
    IncidentsUpdated.delete_records(department_id=extractor_department.id)

    # respond to the extractor
    heartbeat_response = json.dumps({"received": request.json, "nextMonth": next_month, "nextYear": next_year})
    return heartbeat_response
Exemplo n.º 5
0
def home():
    form = InterestForm(request.form, csrf_enabled=False)
    if request.method == 'POST':
        if form.validate_on_submit():
            Interested.create(name=form.name.data,
                              agency=form.agency.data,
                              location=form.location.data,
                              phone=form.phone.data,
                              email=form.email.data,
                              comments=form.comments.data)
            # send a slack notification
            send_slack_message('New Interest Form Submission!', [
                form.name.data, form.agency.data, form.location.data,
                form.phone.data, form.email.data, form.comments.data
            ])
            flash("Thank you. We will be in contact shortly.", 'success')
            return redirect(url_for('public.home'))
        else:
            flash_errors(form)
    return render_template("public/interest_form.html", interest_form=form)