Example #1
0
def page(request, page_url):
    template = 'page.html'
    context = {}
    search_form = SearchForm(data=request.GET)
    if not page_url:
        template = 'index.html'
        try:
            rent_id = DealType.objects.get(name=u'Арендовать').id
            buy_id = DealType.objects.get(name=u'Купить').id
        except DealType.DoesNotExist:
            rent_id = ''
            buy_id = ''
        
        all_realty_url = get_url_params({'deal' : [rent_id, buy_id, ], })
        keys_show_rtl = RealtyType.objects.filter(ind_show=True)
        values_show_rtl = [get_url_params({'realty' : [item.id, ],
                                           'deal' : [rent_id, buy_id,]})
                           for item in keys_show_rtl]
        show_realty_type_dict = dict(zip(keys_show_rtl, values_show_rtl))
        
        keys_rtl = RealtyType.objects.all()
        values_rtl = [get_url_params({'realty' : [item.id, ],
                                      'deal' : [rent_id, buy_id,]})
                      for item in keys_rtl]
        realty_type_dict = dict(zip(keys_rtl, values_rtl))
        
        realty_list = Realty.objects.filter(region__name=u'Екатеринбург').order_by('-date')
        filter_realty_list = [realty_detail for realty_detail in realty_list
                               if (datetime.datetime.now()-realty_detail.date) < datetime.timedelta(hours=12000)][:8]
        sp_list = Realty.objects.filter(sp=True)
        try:
            sp_realty = random.choice(sp_list)
        except IndexError:
            sp_realty = None
        search_form = SearchForm()
        context = {'show_realty_type_dict' : show_realty_type_dict,
                   'realty_type_dict' : realty_type_dict,
                   'realty_list' : filter_realty_list,
                   'sp_realty' : sp_realty,
                   'all_realty_url' : all_realty_url,
                   'search_form' : search_form,}
    else:
        page = get_object_or_404(Page, path=page_url)
        template = 'page.html'
        context = {'show_search_form' : True,
                   'search_form' : search_form, }

    return render(request, template, context)
Example #2
0
def getAuctionCode(driver, g_url, pid):
    tbToken = driver.get_cookie('_tb_token_')['value']
    adzoneid, siteid = utils.get_pid_by_mmid(pid)
    ps = utils.get_url_params(g_url)
    auctionid = ps['id']
    params1 = params.get_tg_link(auctionid, adzoneid, siteid, tbToken)
    return j_req(driver, 'GET',
                 'https://pub.alimama.com/common/code/getAuctionCode.json',
                 params1)
Example #3
0
 def common_actions(self, request):
     request.settings = cache.get('settings')
     if not request.settings:
         try:
             request.settings = Settings.objects.all()[0]
             cache.set('settings', request.settings, 60*60*24)
         except:
             pass
     
     request.infoblock = cache.get('infoblock')
     if not request.infoblock:
         try:
             request.infoblock = dict(
                 [(item.name, item.content) \
                  for item in InfoBlock.objects.all()]) 
             cache.set('infoblock', request.infoblock, 60*60*24)
         except:
             pass
     
     request.members_pages = cache.get('members_pages')
     if not request.members_pages:
         try:
             request.members_pages = Page.objects.get(path='members').get_children()
             cache.set('members_pages', request.members_pages, 60*60*24)
         except:
             pass
     try:
         request.rent_params = get_url_params({'region' : [Region.objects.get(name=u'Екатеринбург').id,],
                                               'deal' : [DealType.objects.get(name=u'Сдать в аренду').id,], })
         request.rent_count = len(Realty.objects.filter(deal__name=u'Сдать в аренду'))
         request.sale_params =  get_url_params({'region' : [Region.objects.get(name=u'Екатеринбург').id,],
                                                'deal' : [DealType.objects.get(name=u'Продать').id,]})
         request.sale_count = len(Realty.objects.filter(deal__name=u'Продать'))
     except Region.DoesNotExist:
         pass
     
     return request