Exemplo n.º 1
0
def dashboard(request):
    # I get the number of the week and the year of now to pass to the view    
    today = datetime.datetime.now()
    week = str(int(today.strftime('%W'))+1)
    year = today.strftime('%Y')
    month = today.strftime('%m')

    rollovers = {'bricklane': get_display_hours(get_rollovers_total('bricklane')),
                 'garage': get_display_hours(get_rollovers_total('garage'))}

    preparations = Preparation.objects.all()

    # build a list for the template
    boxes = {}
    for preparation in preparations:
        boxes[preparation.name] = preparation.checked

    data = {'week': week}
    data['year'] = year
    data['month'] = month
    data['rollovers']= rollovers
    data['preparations'] = boxes
    data['home_on_server'] = settings.HOME_ON_SERVER
    data['clear_cache'] = settings.ACCESS_API_URL + 'clear_cache/'

    return render_to_response('landing.html', data,
                               context_instance=RequestContext(request))
def record_data_by_shop(shop):
    """
    insert in Record table the total of assembly and rollover
    """
    rollovers = Record()
    rollovers.date = datetime.datetime.today()
    rollovers.rollovers = get_rollovers_total(shop)
    rollovers.ready_to_assembly = get_assembly_buffer(shop)
    rollovers.shop = shop

    # if it cant handle the path set to 0 (Nello computer)
    try:
        path = get_ncfolder_path(shop, 'this_week')
        x, y, ready_to_machine = get_view_days(path)
        rollovers.ready_to_machine = ready_to_machine
    except:
        rollovers.ready_to_machine = 0

    rollovers.save();