def bidding_view_history_lot(request, id): #TODO: filter by state lot #TODO: add csrf_token to form lot = get_object_or_404(Lot, pk=id) form = BidForm(lot, request.GET or None) if form.is_valid(): if (not request.user.is_authenticated() ) or request.user.is_staff or request.user.is_superuser: return HttpResponseRedirect(settings.LOGIN_URL + "?next=" + request.get_full_path()) if not (lot.is_active() and lot.shop == request.shop): raise Http404 lot.bid(request.user, form.cleaned_data['amount'], request.META['REMOTE_ADDR']) request.flash['message'] = unicode(_("Bid successfully registered.")) request.flash['severity'] = "success" return HttpResponseRedirect( reverse('bidding_view_history_lot', args=[id])) history = [] for bid in lot.history(): history.append({ 'bidder_username': bid.bidder.username, 'bid_amount': money_format(bid.bid_amount, request.shop), 'bid_time': date(bid.bid_time, 'r'), }) t = loader.get_template('bidding/blocks/view_history_lot_description.html') c = RequestContext(request, {'lot': lot, 'form': form}) block_description = (t.render(c)) image = lot.image() lot_dic = { 'count_bidders': lot.count_bidders(), 'count_bids': lot.count_bids(), 'time_left_long': lot.time_left_long(), 'title': lot.title, 'dir_back': reverse('bidding_view_lot', args=[lot.id]), 'image': { 'original': image.image.url if image else None, 'small': image.image.url_100x100 if image else None, 'medium': image.image.url_400x400 if image else None, } } return HttpResponse( my_render( request, { 'history': history, 'description': block_description, 'page_title': lot.title, 'page_description': '%s, %s' % (lot.title, striptags(lot.description)), 'lot': lot_dic, }, 'view_history_lot'))
def bidding_view_lot(request, id): #TODO: filter by state lot #TODO: add csrf_token to form lot = get_object_or_404(Lot, pk=id) request.shop.add_view() form = BidForm(lot, request.GET or None) if form.is_valid(): if (not request.user.is_authenticated() ) or request.user.is_staff or request.user.is_superuser: return HttpResponseRedirect(settings.LOGIN_URL + "?next=" + request.get_full_path()) if not (lot.is_active() and lot.shop == request.shop): raise Http404 lot.bid(request.user, form.cleaned_data['amount'], request.META['REMOTE_ADDR']) request.flash['message'] = unicode(_("Bid successfully registered.")) request.flash['severity'] = "success" return HttpResponseRedirect(reverse('bidding_view_lot', args=[id])) t = loader.get_template('bidding/blocks/view_lot_form.html') c = RequestContext(request, {'form': form, 'lot': lot}) block_view_lot_form = (t.render(c)) images = [] for img in lot.imagelot_set.all(): images.append({ 'original': img.image.url if img else None, 'small': img.image.url_100x100 if img else None, 'medium': img.image.url_400x400 if img else None, }) param = { 'lot': { 'title': lot.title, 'category': lot.category.name, 'subcategory': lot.subcategory.name if lot.subcategory else "", 'time_left': lot.time_left(), 'session_end': lot.session.end, 'description': lot.description, }, 'user_is_logged': request.user.is_authenticated() and not request.shop.is_admin(request.user), 'form': block_view_lot_form, 'images': images, 'page_title': lot.title, 'page_description': '%s, %s' % (lot.title, striptags(lot.description)) } return HttpResponse(my_render(request, param, 'view_lot'))
def bidding_view_lot(request, id): #TODO: filter by state lot #TODO: add csrf_token to form lot = get_object_or_404(Lot, pk=id) request.shop.add_view() form = BidForm(lot, request.GET or None) if form.is_valid(): if (not request.user.is_authenticated()) or request.user.is_staff or request.user.is_superuser: return HttpResponseRedirect(settings.LOGIN_URL+"?next="+request.get_full_path()) if not (lot.is_active() and lot.shop == request.shop): raise Http404 lot.bid(request.user, form.cleaned_data['amount'], request.META['REMOTE_ADDR']) request.flash['message'] = unicode(_("Bid successfully registered.")) request.flash['severity'] = "success" return HttpResponseRedirect(reverse('bidding_view_lot', args=[id])) t = loader.get_template('bidding/blocks/view_lot_form.html') c = RequestContext(request, {'form': form, 'lot': lot}) block_view_lot_form = (t.render(c)) images = [] for img in lot.imagelot_set.all(): images.append({ 'original': img.image.url if img else None, 'small': img.image.url_100x100 if img else None, 'medium': img.image.url_400x400 if img else None, }) param = { 'lot': {'title': lot.title, 'category': lot.category.name, 'subcategory': lot.subcategory.name if lot.subcategory else "", 'time_left': lot.time_left(), 'session_end': lot.session.end, 'description': lot.description, }, 'user_is_logged': request.user.is_authenticated() and not request.shop.is_admin(request.user), 'form': block_view_lot_form, 'images': images, 'page_title': lot.title, 'page_description': '%s, %s' % (lot.title, striptags(lot.description)) } return HttpResponse(my_render(request, param, 'view_lot'))
def bidding_view_history_lot(request, id): #TODO: filter by state lot #TODO: add csrf_token to form lot = get_object_or_404(Lot, pk=id) form = BidForm(lot, request.GET or None) if form.is_valid(): if (not request.user.is_authenticated()) or request.user.is_staff or request.user.is_superuser: return HttpResponseRedirect(settings.LOGIN_URL+"?next="+request.get_full_path()) if not (lot.is_active() and lot.shop == request.shop): raise Http404 lot.bid(request.user, form.cleaned_data['amount'], request.META['REMOTE_ADDR']) request.flash['message'] = unicode(_("Bid successfully registered.")) request.flash['severity'] = "success" return HttpResponseRedirect(reverse('bidding_view_history_lot', args=[id])) history = [] for bid in lot.history(): history.append({'bidder_username': bid.bidder.username, 'bid_amount': money_format(bid.bid_amount, request.shop), 'bid_time': date(bid.bid_time, 'r'), }) t = loader.get_template('bidding/blocks/view_history_lot_description.html') c = RequestContext(request, {'lot': lot, 'form': form}) block_description = (t.render(c)) image = lot.image() lot_dic = {'count_bidders': lot.count_bidders(), 'count_bids': lot.count_bids(), 'time_left_long': lot.time_left_long(), 'title': lot.title, 'dir_back': reverse('bidding_view_lot', args=[lot.id]), 'image': {'original': image.image.url if image else None, 'small': image.image.url_100x100 if image else None, 'medium': image.image.url_400x400 if image else None, } } return HttpResponse(my_render(request, { 'history': history, 'description': block_description, 'page_title': lot.title, 'page_description': '%s, %s' % (lot.title, striptags(lot.description)), 'lot': lot_dic, }, 'view_history_lot'))