コード例 #1
0
ファイル: views.py プロジェクト: chilimuffin/news-pet
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)
コード例 #2
0
ファイル: views.py プロジェクト: securitywarrior/news-pet
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)
コード例 #3
0
ファイル: views.py プロジェクト: chilimuffin/news-pet
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)
コード例 #4
0
ファイル: views.py プロジェクト: securitywarrior/news-pet
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)