def opinionate(request, item_id, opinion): next = reverse('f_item', args=[item_id]) if 'next' in request.GET: next = _check_next_url(request.GET['next']) or next item = get_object_or_404(FeedItem, id = item_id, category__owner=request.user) item.opinion = opinion item.was_viewed = True item.save() training.train_item(item, item.category, opinion) return HttpResponseRedirect(next)
def opinionate(request, item_id, opinion): next = reverse('f_item', args=[item_id]) if 'next' in request.GET: next = _check_next_url(request.GET['next']) or next item = get_object_or_404(FeedItem, id=item_id, category__owner=request.user) item.opinion = opinion item.was_viewed = True item.save() training.train_item(item, item.category, opinion) return HttpResponseRedirect(next)
def move(request, item_id, redirect=None): next = redirect or reverse('f_item', args=[item_id]) if 'next' in request.GET: next = _check_next_url(request.GET['next']) or next category_change_form = CategoryChangeForm(request.user, None, data=request.POST) if category_change_form.is_valid(): item = get_object_or_404(FeedItem, id = item_id, category__owner=request.user) category = item.category new_category = category_change_form.new_category training.train_item(item, category, training.BAD_OPINION) training.train_item(item, new_category, training.GOOD_OPINION) item.category = new_category item.opinion = training.GOOD_OPINION item.was_viewed = True item.save() else: print category_change_form.errors return HttpResponseRedirect(next)
def move(request, item_id, redirect=None): next = redirect or reverse('f_item', args=[item_id]) if 'next' in request.GET: next = _check_next_url(request.GET['next']) or next category_change_form = CategoryChangeForm(request.user, None, data=request.POST) if category_change_form.is_valid(): item = get_object_or_404(FeedItem, id=item_id, category__owner=request.user) category = item.category new_category = category_change_form.new_category training.train_item(item, category, training.BAD_OPINION) training.train_item(item, new_category, training.GOOD_OPINION) item.category = new_category item.opinion = training.GOOD_OPINION item.was_viewed = True item.save() else: print category_change_form.errors return HttpResponseRedirect(next)