Example #1
0
def order(request, order):
    """
    The order form view. 
    """
    # take the json from access_api
    url = '%sorder/%s'%(settings.ACCESS_API_URL,str(order)) 
    f = urllib2.urlopen(url)
    j = f.read()
    f.close()
    json_order = json.loads(j)
    
    # compute the sum of all the assambly time
    assembly = 0
    # compute the sum of all the unit prices    
    total_pounds = 0
    
    for element in json_order['order_details']:
        assembly = assembly + element['plan']
        total_pounds = total_pounds + element['line_total']
    assembly = get_display_hours(assembly)
    
    return render_to_response(
            'order.html',{
                'order' : json_order,
                'assembly' : assembly, 
                'access_api_url' : settings.ACCESS_API_URL,
                'total_pounds' : total_pounds},
            context_instance=RequestContext(request))        
Example #2
0
def noise(request):
    """
    All the order details not ready in the past
    with no required date or a required in the past (not this week)
    """
    url = settings.ACCESS_API_URL + 'noise'
    f = urllib2.urlopen(url)
    j = f.read()
    f.close()
    noise = json.loads(j)
    total = get_display_hours(noise[0])  
    
    return render_to_response(
                'noise.html'
                ,{'noise' : noise, 'total': total, 'home_on_server' : settings.HOME_ON_SERVER}
                , context_instance=RequestContext(request)
                )
Example #3
0
def _get_rollovers_string(shop):
    rollover = pr.models.get_rollovers_total(shop)
    return get_display_hours(rollover)
Example #4
0
def line_ups(request):
    '''
    List the order details according to their delivery date
    and the type of delivery / pick up.
    '''
    #1. get the  list
    url = '%sline_ups/'%(settings.ACCESS_API_URL)
    f = urllib2.urlopen(url)
    j = f.read()
    f.close()
    data = json.loads(j)
    week = data['week']
    days = [] # list that will be passed to the template
    total_plan_week = 0

    for day in week:

        total_plan_day = 0
        date = day.keys()[0]

        # dictionary will contain the orders splitted by package type
        od_by_package = {}

        for od in day[date]:
            od = pr.models.get_line_ups_od(od)

            if od['assembled'] == 0:
                od['plan'] = int(od['plan'])
                total_plan_day += od['plan']

            if od['note'] == None:
                od['note'] = ""

            # add to every order the package information
            if od_by_package.has_key(od['package_type']):
                od_by_package[od['package_type']].append(od)
            else:
                od_by_package[od['package_type']] = []
                od_by_package[od['package_type']].append(od)

        total_plan_week += total_plan_day
        total_plan_day = str(datetime.timedelta(minutes=total_plan_day))[0:4]
        days.append([date, od_by_package, total_plan_day])


    sum = 0
    for od in data['past']:
        sum = sum + od['plan']
        if od['shop'] == 'Bricklane':
            od['shop'] = 'BR'
        else:
            od['shop'] = 'GR'

    # formatting rollover's total plan
    rollover_plan_total = datetime.timedelta(minutes=sum)
    rollover_plan_total = str(rollover_plan_total)
    rollover_plan_total = rollover_plan_total[0:4]

    tooltips = manual.models.get_lu_tooltips()

    return render_to_response('line_ups.html',
                {'week': days,
                 'past': data['past'],
                 'total_plan_week': get_display_hours(minutes=total_plan_week),
                 'rollover_plan_total': rollover_plan_total,
                 'tooltips': tooltips,
                 'home_on_server' : settings.HOME_ON_SERVER},
            context_instance=RequestContext(request))