Beispiel #1
0
def archive():
    if not current_user.is_authenticated:
        return redirect("login")
    form = SelectDataShift()
    if form.validate_on_submit():
        date = handle_date(form.date_shift.data)
        shift = form.shift.data
        type_mechanism = form.type.data
        if type_mechanism == 'usm':
            # data = time_for_shift_usm(date, shift)
            data = usm_periods(time_for_shift_usm(date, shift))
        if type_mechanism == 'kran':
            data = time_for_shift_kran(date, shift)

        return render_template(
            "archive.html",
            data=data,
            type_mechanism=type_mechanism,
            shift=shift,
            date_shift=date.strftime("%d.%m.%Y"),
            form=form,
        )

    date, shift = today_shift_date()
    data = {}
    return render_template(
        "archive.html",
        data=data,
        shift=shift,
        date_shift=date.strftime("%d.%m.%Y"),
        form=form,
    )
Beispiel #2
0
def mech_periods(type_mechanism, date, shift):
    if type_mechanism == 'usm':
        data = usm_periods(time_for_shift_usm(date, shift))
    elif type_mechanism == 'kran':
        data = kran_periods(time_for_shift_kran(date, shift))
    elif type_mechanism == 'sennebogen':
        data = sennebogen_periods(time_for_shift_sennebogen(date, shift))
        # logger.info(data)
    else:
        data = None
    return data
Beispiel #3
0
def get_data_period_with_fio_now(type_mechanism):
    '''get data shift for by type of mechanism with work NOW'''
    if type_mechanism == 'usm':
        data = usm_periods(time_for_shift_usm(*today_shift_date()))
    if type_mechanism == 'kran':
        data = kran_periods(time_for_shift_kran(*today_shift_date()))
    if type_mechanism == 'sennebogen':
        data = sennebogen_periods(
            time_for_shift_sennebogen(*today_shift_date()))
    data_with_fio = add_fio(data, *today_shift_date())
    return jsonify(data_with_fio)
Beispiel #4
0
def get_data_period(type_mechanism, date_shift, shift):
    '''get data shift for by type of mechanism'''
    try:
        date = datetime.strptime(date_shift, '%d.%m.%Y').date()
    except ValueError:
        return make_response(jsonify({'error': 'Bad format date'}), 400)
    if type_mechanism == 'usm':
        data = usm_periods(time_for_shift_usm(date, shift))
    if type_mechanism == 'kran':
        data = time_for_shift_kran(date, shift)
    return jsonify(data)