Esempio n. 1
0
File: home.py Progetto: daasara/riba
def sitemap(request):
    items = []
    if not items:
        items = []
        mega_drops = MegaDropDown.objects.filter(
            type="menu_level2_category",
            client=request.client.client).order_by('category__name')
        items_per_column = int(math.ceil(Decimal(len(mega_drops)) / 3))
        for item in mega_drops:
            sub_cats = CategoryGraph.objects.filter(parent=item.category)
            active_cats = []
            if item.category.id not in [1097, 974, 976, 962]:
                for cat in sub_cats:
                    if cat.category.has_products():
                        active_cats.append(cat)
                if utils.get_future_ecom_prod() == request.client.client:
                    if len(active_cats) == 1 or item.category.id == 1097:
                        active_cats = []
            mitems = {}
            mitems = {'item': item, 'active_cats': active_cats}
            if active_cats:
                items.append(mitems)
        items_first_column = items[:items_per_column]
        items_second_column = items[items_per_column:(2 * items_per_column)]
        items_third_column = items[(2 * items_per_column):]
    return render_to_response('pages/info/sitemap.html', {
        'items_first_column': items_first_column,
        'items_second_column': items_second_column,
        'items_third_column': items_third_column,
        'request': request,
    },
                              context_instance=RequestContext(request))
Esempio n. 2
0
def sitemap(request):
    items = []
    if not items:
        items = []
        mega_drops = MegaDropDown.objects.filter(type= "menu_level2_category",client=request.client.client).order_by('category__name')
        items_per_column = int(math.ceil(Decimal(len(mega_drops))/3))
        for item in mega_drops:
            sub_cats = CategoryGraph.objects.filter(parent=item.category)
            active_cats = []
            if item.category.id not in [1097, 974, 976, 962]:
                for cat in sub_cats:
                    if cat.category.has_products():
                        active_cats.append(cat)
                if utils.get_future_ecom_prod() == request.client.client:
                    if len(active_cats) == 1 or item.category.id == 1097:
                        active_cats = []
            mitems = {}
            mitems={'item':item, 'active_cats':active_cats}
            if active_cats:
                items.append(mitems)
        items_first_column = items[:items_per_column]
        items_second_column = items[items_per_column:(2*items_per_column)]
        items_third_column = items[(2*items_per_column):]
    return render_to_response('pages/info/sitemap.html',
            {
                'items_first_column':items_first_column,
                'items_second_column':items_second_column,
                'items_third_column':items_third_column,
                'request':request,
            },
            context_instance=RequestContext(request))
Esempio n. 3
0
def get_menu(request):
    if utils.get_future_ecom_prod() == request.client.client:
        return get_future_bazaar_menu(request)
    items = []
    banner_urls = {'dod':'', 'battle':'', 'top10':''}

    if not items:
        items = []
        steal_of_the_day = DailyDeal.objects.filter(starts_on__lte = datetime.now(), ends_on__gte = datetime.now(), client=request.client.client)
        if steal_of_the_day:
            steal_of_the_day = steal_of_the_day[0]
            products = steal_of_the_day.dailydealproduct_set.all()
            product = products[0].product
            view_more = False
            if len(products) > 1:
                view_more = True
            sku = product.primary_rate_chart()
            items.append({'type':'daily_deal', 'sku':sku, 'deal_product':product, 'deal':steal_of_the_day, 'view_more':view_more})
        category_items = []
        for item in MegaDropDown.objects.filter(client=request.client.client).order_by('sort_order'):            
            if item.type == 'category':
                sub_cats = CategoryGraph.objects.select_related(
                    'category').filter(parent=item.category)
                active_cats = []
                if item.category and item.category.id not in [1097, 974, 976, 962]:
                    for cat in sub_cats:
                        if cat.category.product_set.filter(status='active').count() > 0:
                            active_cats.append(cat)
                        else:
                            total = 0
                            for c in cat.category.get_all_children():
                                total += c.product_set.filter(status='active').count()
                            if total > 0:
                                active_cats.append(cat)
                    if utils.get_future_ecom_prod() == request.client.client:
                        active_cats = active_cats[:4]
                        if len(active_cats) == 1 or item.category.id == 1097:
                            active_cats = []
                mitems = {}
                mitems={'item':item, 'active_cats':active_cats, 'type':'category'}
                if active_cats:
                    items.append(mitems)
                category_items.append(mitems)
        #cache.set('mega_items',items,36000)
    return {'mega_items':items}
Esempio n. 4
0
def render_menu(request):
    menu_key = 'menu#%s' % (request.client.client.id)
    menu_context = cache.get(menu_key)
    if not menu_context:
        menu_context = get_menu(request)
        if utils.get_future_ecom_prod() == request.client.client:
            from lists.models import List
            menu_context['clearance_sale'] = get_clearance_tags(request)
        '''
        Caching Menu for 4 Hours
        '''
        cache.set(menu_key, menu_context, 14400)
    menu_context['request'] = request
    return menu_context
Esempio n. 5
0
def render_menu(request):
    menu_key = 'menu#%s' % (request.client.client.id)
    menu_context = cache.get(menu_key)
    if not menu_context:
        menu_context = get_menu(request)
        if utils.get_future_ecom_prod() == request.client.client:
            from lists.models import List
            menu_context['clearance_sale'] = get_clearance_tags(request)
        '''
        Caching Menu for 4 Hours
        '''
        cache.set(menu_key, menu_context, 14400)
    menu_context['request'] = request
    return menu_context
Esempio n. 6
0
def sap_updates(request):
    log.info('######### request.POST = %s' % request.POST)
    #    log.info('HERE inside sap views')
    #    log.info('')
    #    log.info('###########')
    #    log.info('transactioncode = %s' % request.POST['transactioncode'])
    #    log.info('articleid = %s' % request.POST['articleid'])
    #    log.info('issuingsite = %s' % request.POST['issuingsite'])
    #    log.info('receivingsite = %s' % request.POST['receivingsite'])
    #    log.info('issuingsitestorageloc = %s' % request.POST['issuingstorageloc'])
    #    log.info('receivingsitestorageloc = %s' % request.POST['receivingstorageloc'])
    #    log.info('movementtype = %s' % request.POST['movementtype'])
    #    log.info('quantity = %s' % request.POST['quantity'])
    #    log.info('#############')

    try:
        with transaction.commit_on_success():
            transaction_code = str(request.POST['transactioncode']).strip()
            article_id = int(str(request.POST['articleid']).strip())
            issuing_site = str(request.POST['issuingsite']).strip()
            if issuing_site:
                issuing_site = int(issuing_site)
            receiving_site = str(request.POST['receivingsite']).strip()
            if receiving_site:
                receiving_site = int(receiving_site)
            issuing_storage_location = str(
                request.POST['issuingstorageloc']).strip()
            if issuing_storage_location:
                issuing_storage_location = int(issuing_storage_location)
            receiving_storage_location = str(
                request.POST['receivingstorageloc']).strip()
            if receiving_storage_location:
                receiving_storage_location = int(receiving_storage_location)
            movement_type = str(request.POST['movementtype']).strip()
            quantity = str(request.POST['quantity']).strip()
            if quantity:
                actual_quantity = Decimal(quantity)
                quantity = int(round(Decimal(quantity)))

            #Get rate_chart
            try:
                rate_chart = SellerRateChart.objects.get(
                    article_id=int(article_id), seller=87)
                fb_client = utils.get_future_ecom_prod()

                if receiving_site and receiving_storage_location and quantity:
                    dc = utils.get_dc(receiving_site, fb_client)
                    if dc:
                        sap_event = SapEvents.objects.create(
                            rate_chart=rate_chart,
                            dc=dc,
                            actual_quantity=actual_quantity,
                            quantity=quantity,
                            storage_location=int(receiving_storage_location),
                            type='inward')
                        if receiving_storage_location == int('10'):
                            inward_event(request, rate_chart, dc, quantity,
                                         sap_event)
                        sap_event.mark_sap_event_as_processed(request)

                if issuing_site and issuing_storage_location and quantity:
                    dc = utils.get_dc(issuing_site, fb_client)
                    if dc:
                        sap_event = SapEvents.objects.create(
                            rate_chart=rate_chart,
                            dc=dc,
                            actual_quantity=actual_quantity,
                            quantity=quantity,
                            storage_location=int(issuing_storage_location),
                            type='outward')
                        if issuing_storage_location == int('10'):
                            outward_event(request, rate_chart, dc, quantity,
                                          sap_event)
                        sap_event.mark_sap_event_as_processed(request)
            except SellerRateChart.DoesNotExist:
                fb_client = utils.get_future_ecom_prod()
                fb_seller = utils.get_seller(87)
                unprocessed_sap_event = UnprocessedSAPEvents.objects.create(
                    article_id=int(article_id),
                    receiving_storage_location=receiving_storage_location,
                    receiving_site=receiving_site,
                    issuing_storage_location=issuing_storage_location,
                    issuing_site=issuing_site,
                    quantity=quantity,
                    actual_quantity=actual_quantity,
                    seller=fb_seller,
                    client=fb_client)

    except Exception, e:
        log.exception('Cannot process SAP event')
        raise
Esempio n. 7
0
def get_menu(request):
    if utils.get_future_ecom_prod() == request.client.client:
        return get_future_bazaar_menu(request)
    items = []
    banner_urls = {'dod': '', 'battle': '', 'top10': ''}

    if not items:
        items = []
        steal_of_the_day = DailyDeal.objects.filter(
            starts_on__lte=datetime.now(),
            ends_on__gte=datetime.now(),
            client=request.client.client)
        if steal_of_the_day:
            steal_of_the_day = steal_of_the_day[0]
            products = steal_of_the_day.dailydealproduct_set.all()
            product = products[0].product
            view_more = False
            if len(products) > 1:
                view_more = True
            sku = product.primary_rate_chart()
            items.append({
                'type': 'daily_deal',
                'sku': sku,
                'deal_product': product,
                'deal': steal_of_the_day,
                'view_more': view_more
            })
        category_items = []
        for item in MegaDropDown.objects.filter(
                client=request.client.client).order_by('sort_order'):
            if item.type == 'category':
                sub_cats = CategoryGraph.objects.select_related(
                    'category').filter(parent=item.category)
                active_cats = []
                if item.category and item.category.id not in [
                        1097, 974, 976, 962
                ]:
                    for cat in sub_cats:
                        if cat.category.product_set.filter(
                                status='active').count() > 0:
                            active_cats.append(cat)
                        else:
                            total = 0
                            for c in cat.category.get_all_children():
                                total += c.product_set.filter(
                                    status='active').count()
                            if total > 0:
                                active_cats.append(cat)
                    if utils.get_future_ecom_prod() == request.client.client:
                        active_cats = active_cats[:4]
                        if len(active_cats) == 1 or item.category.id == 1097:
                            active_cats = []
                mitems = {}
                mitems = {
                    'item': item,
                    'active_cats': active_cats,
                    'type': 'category'
                }
                if active_cats:
                    items.append(mitems)
                category_items.append(mitems)
        #cache.set('mega_items',items,36000)
    return {'mega_items': items}