Ejemplo n.º 1
0
def index():
    if not g.user.is_finance():
        abort(404)
    orders = list(FrameworkOrder.all())
    if request.args.get('selected_status'):
        status_id = int(request.args.get('selected_status'))
    else:
        status_id = -1

    orderby = request.args.get('orderby', '')
    search_info = request.args.get('searchinfo', '')
    location_id = int(request.args.get('selected_location', '-1'))
    page = int(request.args.get('p', 1))
    year = int(request.values.get('year', datetime.datetime.now().year))
    if location_id >= 0:
        orders = [o for o in orders if location_id in o.locations]
    if status_id >= 0:
        orders = [o for o in orders if o.contract_status == status_id]
    if search_info != '':
        orders = [
            o for o in orders if search_info.lower() in o.search_info.lower()]
    orders = [k for k in orders if k.client_start.year == year or k.client_end.year == year]
    if orderby and len(orders):
        orders = sorted(
            orders, key=lambda x: getattr(x, orderby), reverse=True)
    select_locations = TEAM_LOCATION_CN.items()
    select_locations.insert(0, (-1, u'全部区域'))
    select_statuses = CONTRACT_STATUS_CN.items()
    select_statuses.insert(0, (-1, u'全部合同状态'))
    paginator = Paginator(orders, ORDER_PAGE_NUM)
    try:
        orders = paginator.page(page)
    except:
        orders = paginator.page(paginator.num_pages)
    return tpl('/finance/framework_order/index.html', orders=orders,
               locations=select_locations, location_id=location_id,
               statuses=select_statuses, status_id=status_id,
               orderby=orderby, now_date=datetime.date.today(),
               search_info=search_info, page=page, year=year,
               params='&orderby=%s&searchinfo=%s&selected_location=%s&selected_status=%s&year=%s' %
                      (orderby, search_info, location_id, status_id, str(year)))
Ejemplo n.º 2
0
                                                    medium_money=i[
                                                        'medium_money'],
                                                    medium_money2=i[
                                                        'medium_money2'],
                                                    sale_money=i[
                                                        'sale_money'],
                                                    month_day=i['month'],
                                                    days=i['days'],
                                                    create_time=None)
                er.save()
    return True

if __name__ == '__main__':
    client_orders = ClientOrder.all()
    douban_orders = DoubanOrder.all()
    framework_orders = FrameworkOrder.all()
    medium_framework_orders = MediumFrameworkOrder.all()
    search_client_orders = searchAdClientOrder.all()
    search_rebate_orders = searchAdRebateOrder.all()
    search_framework_orders = searchAdFrameworkOrder.all()

    for c in client_orders:
        c.client_start_year = c.client_start.year
        c.client_end_year = c.client_end.year
        c.save()
        _insert_zhiqu_executive_report(c, 'reload')

    for d in douban_orders:
        d.client_start_year = d.client_start.year
        d.client_end_year = d.client_end.year
        d.save()
Ejemplo n.º 3
0
 def get_framework_order_count(self):
     return len([k for k in FrameworkOrder.all() if self in k.agents])
Ejemplo n.º 4
0
 def get_framework_order_count(self):
     return len([k for k in FrameworkOrder.all() if self in k.agents])