示例#1
0
def index_anon(request, page_no):
    request.engine.register('auction', 'auction')
    request.engine.module = 'auction'

    if request.GET.get('tier') and request.GET['tier'] in settings.TIERS:
        filter = request.GET['tier']
    else:
        filter = None

    paginator = Paginator(request.engine.auction.items,
                          settings.DEFAULT_AUCTIONS_PER_PAGE,
                          body=8,
                          padding=2)
    selected = request.engine.auction.items[
        (int(page_no) - 1) * settings.DEFAULT_AUCTIONS_PER_PAGE:int(page_no) *
        settings.DEFAULT_AUCTIONS_PER_PAGE]

    try:
        current_page = paginator.page(page_no)
    except:
        raise Http404

    return {
        'page_no': int(page_no),
        'page': current_page,
        'selected': selected,
        'filter': filter,
        'items_count': len(request.engine.auction.items),
    }
示例#2
0
def album_list(request, page_no):
    albums = Album.objects.filter(is_active=True,
                                  is_locked=True,
                                  is_hidden=False).order_by('name')
    selected = albums[
        (int(page_no) - 1) *
        settings.DEFAULT_CARS_PER_ENCYCLOPEDIA_PAGE:int(page_no) *
        settings.DEFAULT_CARS_PER_ENCYCLOPEDIA_PAGE]
    paginator = Paginator(albums,
                          settings.DEFAULT_CARS_PER_ENCYCLOPEDIA_PAGE,
                          body=8,
                          padding=2)

    try:
        current_page = paginator.page(page_no)
    except:
        logging.debug('Page %s error for %s' % (page_no, manuf))
        raise Http404

    return {
        'albums': selected,
        'page_no': int(page_no),
        'page': current_page,
        'total': len(albums),
    }
示例#3
0
def index_anon(request, page_no):
    request.engine.register('auction', 'auction')
    request.engine.module = 'auction'

    if request.GET.get('tier') and request.GET['tier'] in settings.TIERS:
        filter = request.GET['tier']
    else:
        filter = None

    paginator = Paginator(request.engine.auction.items, settings.DEFAULT_AUCTIONS_PER_PAGE, body=8, padding=2)
    selected = request.engine.auction.items[
               (int(page_no) - 1) * settings.DEFAULT_AUCTIONS_PER_PAGE:int(page_no) * settings.DEFAULT_AUCTIONS_PER_PAGE
               ]

    try:
        current_page = paginator.page(page_no)
    except:
        raise Http404

    return {
        'page_no': int(page_no),
        'page': current_page,
        'selected': selected,
        'filter': filter,
        'items_count': len(request.engine.auction.items),
    }
示例#4
0
def car_list(request, manuf_url, page_no):
    try:
        manuf = Car.objects.get_manuf_dict()[manuf_url]
    except KeyError:
        logging.debug('Manuf %s key error' % (manuf_url))
        raise Http404

    cars = Car.objects.get_by_manuf(manuf=manuf)
    selected = cars[(int(page_no) - 1) *
                    settings.DEFAULT_CARS_PER_ENCYCLOPEDIA_PAGE:int(page_no) *
                    settings.DEFAULT_CARS_PER_ENCYCLOPEDIA_PAGE]
    paginator = Paginator(cars,
                          settings.DEFAULT_CARS_PER_ENCYCLOPEDIA_PAGE,
                          body=8,
                          padding=2)

    try:
        current_page = paginator.page(page_no)
    except:
        logging.debug('Page %s error for %s' % (page_no, manuf))
        raise Http404

    return {
        'manuf': manuf,
        'short_manuf': manuf_url,
        'cars': selected,
        'page_no': int(page_no),
        'page': current_page,
        'total': len(cars),
    }
示例#5
0
def car_list(request, manuf_url, page_no):
    try:
        manuf = Car.objects.get_manuf_dict()[manuf_url]
    except KeyError:
        logging.debug('Manuf %s key error' % (manuf_url))
        raise Http404

    cars = Car.objects.get_by_manuf(manuf=manuf)
    selected = cars[
               (int(page_no) - 1) * settings.DEFAULT_CARS_PER_ENCYCLOPEDIA_PAGE:int(
                   page_no) * settings.DEFAULT_CARS_PER_ENCYCLOPEDIA_PAGE
               ]
    paginator = Paginator(cars, settings.DEFAULT_CARS_PER_ENCYCLOPEDIA_PAGE, body=8, padding=2)

    try:
        current_page = paginator.page(page_no)
    except:
        logging.debug('Page %s error for %s' % (page_no, manuf))
        raise Http404

    return {
        'manuf': manuf,
        'short_manuf': manuf_url,
        'cars': selected,
        'page_no': int(page_no),
        'page': current_page,
        'total': len(cars),
    }
示例#6
0
def index(request, tab, page_no):
    if not hasattr(request.engine, 'user'):
        return index_anon(request, page_no)

    request.engine.register('auction', tab)
    request.engine.module = 'auction'
    template_tab = 'auction'

    if request.GET.get('tier') and request.GET['tier'] in settings.TIERS:
        filter = request.GET['tier']
    else:
        filter = None

    if tab == 'auction':
        paginator = Paginator(request.engine.auction.items,
                              settings.DEFAULT_AUCTIONS_PER_PAGE,
                              body=8,
                              padding=2)
        selected = request.engine.auction.items[
            (int(page_no) - 1) *
            settings.DEFAULT_AUCTIONS_PER_PAGE:int(page_no) *
            settings.DEFAULT_AUCTIONS_PER_PAGE]

    elif tab == 'watch':
        pass

    elif tab in ('bidding', 'bidded'):
        paginator = Paginator(request.engine.auction.items,
                              settings.DEFAULT_AUCTIONS_PER_PAGE,
                              body=8,
                              padding=2)
        selected = request.engine.auction.items[
            (int(page_no) - 1) *
            settings.DEFAULT_AUCTIONS_PER_PAGE:int(page_no) *
            settings.DEFAULT_AUCTIONS_PER_PAGE]
        template_tab = 'status'

    else:
        return request.engine.redirect(reverse('auction'))

    try:
        current_page = paginator.page(page_no)
    except:
        raise Http404

    return {
        'TEMPLATE': 'auction/index_%s.fbml' % template_tab,
        'tab': tab,
        'page_no': int(page_no),
        'page': current_page,
        'selected': selected,
        'filter': filter,
        'items_count': len(request.engine.auction.items),
    }
示例#7
0
def index(request, tab, page_no):
    if not hasattr(request.engine, 'user'):
        return index_anon(request, page_no)

    request.engine.register('auction', tab)
    request.engine.module = 'auction'
    template_tab = 'auction'

    if request.GET.get('tier') and request.GET['tier'] in settings.TIERS:
        filter = request.GET['tier']
    else:
        filter = None

    if tab == 'auction':
        paginator = Paginator(request.engine.auction.items, settings.DEFAULT_AUCTIONS_PER_PAGE, body=8, padding=2)
        selected = request.engine.auction.items[
                   (int(page_no) - 1) * settings.DEFAULT_AUCTIONS_PER_PAGE:int(
                       page_no) * settings.DEFAULT_AUCTIONS_PER_PAGE
                   ]

    elif tab == 'watch':
        pass

    elif tab in ('bidding', 'bidded'):
        paginator = Paginator(request.engine.auction.items, settings.DEFAULT_AUCTIONS_PER_PAGE, body=8, padding=2)
        selected = request.engine.auction.items[
                   (int(page_no) - 1) * settings.DEFAULT_AUCTIONS_PER_PAGE:int(
                       page_no) * settings.DEFAULT_AUCTIONS_PER_PAGE
                   ]
        template_tab = 'status'

    else:
        return request.engine.redirect(reverse('auction'))

    try:
        current_page = paginator.page(page_no)
    except:
        raise Http404

    return {
        'TEMPLATE': 'auction/index_%s.fbml' % template_tab,
        'tab': tab,
        'page_no': int(page_no),
        'page': current_page,
        'selected': selected,
        'filter': filter,
        'items_count': len(request.engine.auction.items),
    }
示例#8
0
def album_list(request, page_no):
    albums = Album.objects.filter(is_active=True, is_locked=True, is_hidden=False).order_by('name')
    selected = albums[
               (int(page_no) - 1) * settings.DEFAULT_CARS_PER_ENCYCLOPEDIA_PAGE:int(
                   page_no) * settings.DEFAULT_CARS_PER_ENCYCLOPEDIA_PAGE
               ]
    paginator = Paginator(albums, settings.DEFAULT_CARS_PER_ENCYCLOPEDIA_PAGE, body=8, padding=2)

    try:
        current_page = paginator.page(page_no)
    except:
        logging.debug('Page %s error for %s' % (page_no, manuf))
        raise Http404

    return {
        'albums': selected,
        'page_no': int(page_no),
        'page': current_page,
        'total': len(albums),
    }
示例#9
0
def friend_send(request, car_id):
    car = Car.objects.get_by_id(car_id)

    if request.method == 'POST':
        if not request.POST.has_key('friend'):
            request.engine.log.message(message="You forgot to select a friend")
            return HttpResponseRedirect(reverse('friend_send', args=[car.id]))

        try:
            receiver = UserProfile.objects.get_by_id(request.POST['friend'])
        except UserProfile.DoesNotExist:
            request.engine.log.message(message="Incorrect friend selected")
            return HttpResponseRedirect(reverse('friend_send', args=[car.id]))

        garage = Garage.objects.get_by_user(user=request.engine.user.user)
        if not garage.has_car(car.id):
            request.engine.log.message(message="Incorrect car selected")
            return HttpResponseRedirect(reverse('friend_send', args=[car.id]))

        # dodajemy gift do pending
        g = UserGift.objects.get_by_user(user=receiver.user)
        g.engine = request.engine
        g.add_pending(car.id, request.engine.user.user.id)

        # usuwamy z garazu
        garage.engine = request.engine
        garage.remove_car(car.id)

        # wysylamy powiadomienie mailem
        Task(user=request.engine.user.user,
             task='mail',
             source='gift_received',
             comment=json.dumps({
                 'sender': request.engine.user.profile.user_id,
                 'recipient': receiver.user_id,
                 'car': car_id
             })).save()

        request.engine.log.message(message="Car sent to %s" % receiver)
        return HttpResponseRedirect(reverse('garage'))

    friend = Friend.objects.get_by_user(user=request.engine.user.user)
    page_no = request.GET.get('page_no') or 1

    selected = friend.friends[
        (int(page_no) - 1) *
        settings.DEFAULT_FRIENDS_PER_GIFT_PAGE:int(page_no) *
        settings.DEFAULT_FRIENDS_PER_GIFT_PAGE]
    paginator = Paginator(friend.friends,
                          settings.DEFAULT_FRIENDS_PER_GIFT_PAGE,
                          body=8,
                          padding=2)

    try:
        current_page = paginator.page(page_no)
    except:
        return HttpResponseRedirect(reverse('friend_send', args=[car_id]))

    return {
        'car': car,
        'friends': UserProfile.objects.get_many_by_user_ids(selected),
        'page_no': int(page_no),
        'page': current_page,
        'total': len(friend.friends),
    }
示例#10
0
def friend_send(request, car_id):
    car = Car.objects.get_by_id(car_id)

    if request.method == "POST":
        if not request.POST.has_key("friend"):
            request.engine.log.message(message="You forgot to select a friend")
            return HttpResponseRedirect(reverse("friend_send", args=[car.id]))

        try:
            receiver = UserProfile.objects.get_by_id(request.POST["friend"])
        except UserProfile.DoesNotExist:
            request.engine.log.message(message="Incorrect friend selected")
            return HttpResponseRedirect(reverse("friend_send", args=[car.id]))

        garage = Garage.objects.get_by_user(user=request.engine.user.user)
        if not garage.has_car(car.id):
            request.engine.log.message(message="Incorrect car selected")
            return HttpResponseRedirect(reverse("friend_send", args=[car.id]))

        # dodajemy gift do pending
        g = UserGift.objects.get_by_user(user=receiver.user)
        g.engine = request.engine
        g.add_pending(car.id, request.engine.user.user.id)

        # usuwamy z garazu
        garage.engine = request.engine
        garage.remove_car(car.id)

        # wysylamy powiadomienie mailem
        Task(
            user=request.engine.user.user,
            task="mail",
            source="gift_received",
            comment=json.dumps(
                {"sender": request.engine.user.profile.user_id, "recipient": receiver.user_id, "car": car_id}
            ),
        ).save()

        request.engine.log.message(message="Car sent to %s" % receiver)
        return HttpResponseRedirect(reverse("garage"))

    friend = Friend.objects.get_by_user(user=request.engine.user.user)
    page_no = request.GET.get("page_no") or 1

    selected = friend.friends[
        (int(page_no) - 1)
        * settings.DEFAULT_FRIENDS_PER_GIFT_PAGE : int(page_no)
        * settings.DEFAULT_FRIENDS_PER_GIFT_PAGE
    ]
    paginator = Paginator(friend.friends, settings.DEFAULT_FRIENDS_PER_GIFT_PAGE, body=8, padding=2)

    try:
        current_page = paginator.page(page_no)
    except:
        return HttpResponseRedirect(reverse("friend_send", args=[car_id]))

    return {
        "car": car,
        "friends": UserProfile.objects.get_many_by_user_ids(selected),
        "page_no": int(page_no),
        "page": current_page,
        "total": len(friend.friends),
    }