Ejemplo n.º 1
0
def generate_report_flush(request, flush_id):
    """
    Renders the report page for a particular flush.

    Builds a list of dates and total picked.
    It expects jqPlot to properly build the graph.
    """
    flush_obj = get_object_or_404(Flush, pk=flush_id)
    start_date = flush_obj.start_date
    if flush_obj.end_date is not None:
        end_date = flush_obj.end_date
    else:
        end_date = datetime.date.today()
    daily_totals = []
    for date in date_range(start_date, end_date):
        tmp = [
            date.strftime('%Y-%m-%d'),
        ]
        tmp.append(flush_obj.get_total_picked(date))
        daily_totals.append(tmp)
    return render_to_response('report.html', {
        'report_type': 'flush',
        'flush': flush_obj,
        'jqplot_data': daily_totals,
    })
Ejemplo n.º 2
0
def generate_report_room(request, room_id):
    """
    Renders the report page for a particular room.

    Builds a list of dates and total picked.
    It expects jqPlot to properly build the graph.
    """
    room_obj = get_object_or_404(Room, pk=room_id)
    try:
        start_date, end_date = get_date_from_request(request)
    except Exception as exc:
        error_list = [
            'Got an exception: {}'.format(exc),
        ]
        return render_to_response('error.html', {
            'error_list': error_list,
        })
    daily_totals = []
    for date in date_range(start_date, end_date):
        tmp = [
            date.strftime('%Y-%m-%d'),
        ]
        tmp.append(room_obj.get_total_picked(date))
        daily_totals.append(tmp)
    return render_to_response('report.html', {
        'report_type': 'room',
        'room': room_obj,
        'jqplot_data': daily_totals,
    })
Ejemplo n.º 3
0
def generate_report_picker(request, picker_id):
    """
    Renders the report page for a particular picker.

    Builds a list of dates, total picked and average per day.
    It expects jqPlot to properly build the graph.
    """
    try:
        start_date, end_date = get_date_from_request(request)
    except Exception as exc:
        error_list = [
            'Got an exception: {}'.format(exc),
        ]
        return render_to_response('error.html', {
            'error_list': error_list,
        })
    picker_obj = get_object_or_404(Picker, pk=picker_id)
    daily_totals = []
    for date in date_range(start_date, end_date):
        tmp = [
            date.strftime('%Y-%m-%d'),
        ]
        tmp.append(picker_obj.get_total_picked(date))
        hours_worked = picker_obj.get_time_worked(date).seconds / 3600.0
        avg = (tmp[1] / hours_worked) if hours_worked != 0 else 0.0
        tmp.append(avg)
        daily_totals.append(tmp)
    return render_to_response(
        'report.html', {
            'report_type': 'picker',
            'picker': picker_obj,
            'jqplot_data': daily_totals,
            'start_date': start_date,
            'end_date': end_date,
        })
Ejemplo n.º 4
0
def generate_report_picker(request, picker_id):
    """
    Renders the report page for a particular picker.

    Builds a list of dates, total picked and average per day.
    It expects jqPlot to properly build the graph.
    """
    try:
        start_date, end_date = get_date_from_request(request)
    except Exception as exc:
        error_list = ['Got an exception: {}'.format(exc),]
        return render_to_response('error.html', {
            'error_list': error_list,
        })
    picker_obj = get_object_or_404(Picker, pk = picker_id)
    daily_totals = []
    for date in date_range(start_date, end_date):
        tmp = [date.strftime('%Y-%m-%d'),]
        tmp.append(picker_obj.get_total_picked(date))
        hours_worked = picker_obj.get_time_worked(date).seconds / 3600.0
        avg = (tmp[1]/hours_worked) if hours_worked != 0 else 0.0
        tmp.append(avg)
        daily_totals.append(tmp)
    return render_to_response('report.html', {
        'report_type' : 'picker',
        'picker' :      picker_obj,
        'jqplot_data':  daily_totals,
        'start_date':   start_date,
        'end_date':     end_date,
    })
Ejemplo n.º 5
0
def generate_report_room(request, room_id):
    """
    Renders the report page for a particular room.

    Builds a list of dates and total picked.
    It expects jqPlot to properly build the graph.
    """
    room_obj = get_object_or_404(Room, pk = room_id)
    try:
        start_date, end_date = get_date_from_request(request)
    except Exception as exc:
        error_list = ['Got an exception: {}'.format(exc),]
        return render_to_response('error.html', {
            'error_list': error_list,
        })
    daily_totals = []
    for date in date_range(start_date, end_date):
        tmp = [date.strftime('%Y-%m-%d'),]
        tmp.append(room_obj.get_total_picked(date))
        daily_totals.append(tmp)
    return render_to_response('report.html', {
        'report_type' : 'room',
        'room' :        room_obj,
        'jqplot_data':  daily_totals,
    })
Ejemplo n.º 6
0
def generate_report_crop(request, crop_id):
    """
    Renders the report page for a particular crop.

    Builds a list of dates and total picked.
    It expects jqPlot to properly build the graph.
    """
    crop_obj = get_object_or_404(Crop, pk = crop_id)
    start_date = crop_obj.start_date
    if crop_obj.end_date is not None:
        end_date = crop_obj.end_date
    else:
        end_date = datetime.date.today()
    daily_totals = []
    for date in date_range(start_date, end_date):
        tmp = [date.strftime('%Y-%m-%d'),]
        tmp.append(crop_obj.get_total_picked(date))
        daily_totals.append(tmp)
    return render_to_response('report.html', {
        'report_type' : 'crop',
        'crop' :        crop_obj,
        'jqplot_data':  daily_totals,
    })