def inactive_orders(request): """ Display all records that are: 1. deleted in access server but still remain in local db 2.with the planned date = Null """ local_od_not_assembled = pr.models.inactive_orders() local_od_not_assembled = local_od_not_assembled.order_by('shop') # get the order detail from access db with the id of the local not timed order detail access_orders = get_access_order(local_od_not_assembled) # list of the possible inactive orders od_not_in_access = [] od_not_planned = [] # finding all records that dont exist in access for od in local_od_not_assembled: found = False for el in access_orders: if el['ac_od_id'] == od.ac_od_id: found = True if found == False: drop = {} drop['ac_od_id'] = od.ac_od_id drop['assembled'] = od.laminated drop['shop'] = od.shop drop['location'] = od.location od_not_in_access.append(drop) # finding all records without planned date for el in access_orders: if el['planned_date'] == "": od_not_planned.append(el) if el['planned_date'] == None: od_not_planned.append(el) if len(od_not_planned) == 0: print 'I haven\'t found inactive orders' #build a fake damn freaky example return render_to_response( 'inactive_orders.html',{ 'not_in_access':od_not_in_access ,'no_planned':od_not_planned ,'home_on_server' : settings.HOME_ON_SERVER}, context_instance=RequestContext(request))
def week(request, year, week, shop): """ Week Timer Report """ # get the orders from local table wlist = week_range(int(year),int(week)) monday = wlist[0] sunday = wlist[6] local_ods = get_timed_product(monday, sunday, shop) local_ods = local_ods.order_by('start_time') # get the order detail from access db with the id of the local timed order detail access_orders = get_access_order(local_ods) # definition of the variables for the merging date_format = '%A %d %B' # the current date has to be iniatialize out of loop with the date of the first order current_day = local_ods[0].start_time.strftime(date_format) current_day_list = [] days = {} template_data = [] # merging the two result set for od in local_ods: ac_order = {} for el in access_orders: if el['ac_od_id'] == od.ac_od_id: ac_order = el ac_order['actual'] = od.actual ac_order['pause'] = od.pause ac_order['total'] = od.pause + od.actual ac_order['status'] = od.status ac_order['start_time'] = od.start_time.strftime('%Y/%m/%d %H:%M:%S') ac_order['class'] = 'product timed' if od.start_time.strftime(date_format) == current_day: # append the order in the list current_day_list.append(ac_order) else: # append the order in the list, create a new assemble day in the dictionary, clean the temporary variables days[current_day] = current_day_list template_data.append(days) days = {} current_day = od.start_time.strftime(date_format) current_day_list = [] # empty the current day list current_day_list.append(ac_order) # last time out the loop days[current_day] = current_day_list template_data.append(days) days = {} # navigation url nav_dict = {} nav_dict['url_template'] = '/records/week/%s/%s/%s/' nav_dict['week_nr'] = week nav_dict['year'] = year nav_dict['shop'] = shop return render_to_response('week_utl_timer.html', {'week_nr': week, 'week': template_data, 'home_on_server': settings.HOME_ON_SERVER, 'navigation': get_navigation_url(nav_dict), 'shop': shop}, context_instance=RequestContext(request))