mirror of
https://github.com/viq/NewsBlur.git
synced 2025-09-18 21:43:31 +00:00
Fixing trainer for stories in social feeds.
This commit is contained in:
parent
9a0a819146
commit
3324256f36
5 changed files with 30 additions and 11 deletions
|
@ -95,8 +95,8 @@ class MClassifierFeed(mongo.Document):
|
|||
|
||||
def __unicode__(self):
|
||||
user = User.objects.get(pk=self.user_id)
|
||||
feed = Feed.objects.get(pk=self.feed_id)
|
||||
return "%s - %s/%s: (%s) %s" % (user, self.feed_id, self.social_user_id, self.score, feed.feed_title[:30])
|
||||
feed = Feed.objects.get(pk=self.feed_id) if self.feed_id else None
|
||||
return "%s - %s/%s: (%s) %s" % (user, self.feed_id, self.social_user_id, self.score, feed)
|
||||
|
||||
|
||||
def apply_classifier_titles(classifiers, story):
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
from utils import log as logging
|
||||
from django.shortcuts import get_object_or_404
|
||||
from django.views.decorators.http import require_POST
|
||||
from mongoengine.queryset import OperationError
|
||||
# from mongoengine.queryset import OperationError
|
||||
from apps.rss_feeds.models import Feed
|
||||
from apps.reader.models import UserSubscription
|
||||
from apps.analyzer.models import MClassifierTitle, MClassifierAuthor, MClassifierFeed, MClassifierTag
|
||||
|
@ -80,7 +80,6 @@ def save_classifier(request):
|
|||
classifier_dict['feed_id'] = post_content
|
||||
# try:
|
||||
classifier, created = ClassifierCls.objects.get_or_create(**classifier_dict)
|
||||
print classifier_dict, classifier, created
|
||||
# except OperationError:
|
||||
# continue
|
||||
if score == 0:
|
||||
|
|
|
@ -1273,7 +1273,7 @@
|
|||
var $story_titles = this.$s.$story_titles;
|
||||
$folder = $folder || this.$s.$feed_list;
|
||||
var folder_view = NEWSBLUR.assets.folders.get_view($folder) ||
|
||||
this.active_folder.folder_view;
|
||||
this.active_folder && this.active_folder.folder_view;
|
||||
var folder_title = folder && folder.get('folder_title') || "Everything";
|
||||
|
||||
this.reset_feed();
|
||||
|
@ -1748,14 +1748,18 @@
|
|||
}
|
||||
},
|
||||
|
||||
open_story_trainer: function(story_id, feed_id) {
|
||||
open_story_trainer: function(story_id, feed_id, options) {
|
||||
options = options || {};
|
||||
console.log(["open_story_trainer", story_id, feed_id, options]);
|
||||
story_id = story_id || this.active_story && this.active_story.id;
|
||||
feed_id = feed_id || (story_id && this.model.get_story(story_id).get('story_feed_id'));
|
||||
|
||||
if (story_id && feed_id) {
|
||||
NEWSBLUR.classifier = new NEWSBLUR.ReaderClassifierStory(story_id, feed_id, {
|
||||
'feed_loaded': !this.flags['river_view']
|
||||
});
|
||||
options['feed_loaded'] = !this.flags['river_view'];
|
||||
if (this.flags['social_view']) {
|
||||
options['social_feed_id'] = this.active_feed;
|
||||
}
|
||||
NEWSBLUR.classifier = new NEWSBLUR.ReaderClassifierStory(story_id, feed_id, options);
|
||||
}
|
||||
},
|
||||
|
||||
|
|
|
@ -52,10 +52,12 @@ NEWSBLUR.ReaderClassifierStory = function(story_id, feed_id, options) {
|
|||
this.cache = {};
|
||||
this.story_id = story_id;
|
||||
this.feed_id = feed_id;
|
||||
if (options.social_feed_id) this.feed_id = options.social_feed_id;
|
||||
this.trainer_iterator = -1;
|
||||
this.options = $.extend({}, defaults, options);
|
||||
this.model = NEWSBLUR.assets;
|
||||
this.runner_story();
|
||||
console.log(["init story", feed_id, this.feed_id, options, this.options]);
|
||||
};
|
||||
|
||||
var classifier_prototype = {
|
||||
|
@ -100,6 +102,8 @@ var classifier_prototype = {
|
|||
},
|
||||
|
||||
runner_story: function() {
|
||||
this.options.social_feed = _.string.include(this.feed_id, 'social:');
|
||||
|
||||
if (!this.model.classifiers[this.feed_id]) {
|
||||
this.model.classifiers[this.feed_id] = _.extend({}, this.model.defaults['classifiers']);
|
||||
}
|
||||
|
@ -117,7 +121,7 @@ var classifier_prototype = {
|
|||
this.handle_cancel();
|
||||
this.open_modal();
|
||||
this.$modal.parent().bind('click.reader_classifer', $.rescope(this.handle_clicks, this));
|
||||
|
||||
console.log(["runner story", this.options, this.feed_id]);
|
||||
if (!this.options.feed_loaded) {
|
||||
_.defer(_.bind(function() {
|
||||
this.load_single_feed_trainer();
|
||||
|
@ -452,6 +456,13 @@ var classifier_prototype = {
|
|||
this.make_tags(story.get('story_tags'))
|
||||
)
|
||||
])),
|
||||
|
||||
(this.feed_publishers && this.feed_publishers.length && $.make('div', { className: 'NB-modal-field NB-fieldset NB-publishers' }, [
|
||||
$.make('h5', 'Sharing Stories From These Sites'),
|
||||
$.make('div', { className: 'NB-classifier-publishers NB-fieldset-fields NB-classifiers' },
|
||||
this.make_publishers(this.feed_publishers)
|
||||
)
|
||||
])),
|
||||
$.make('div', { className: 'NB-modal-field NB-fieldset' }, [
|
||||
$.make('h5', 'Everything by This Publisher'),
|
||||
$.make('div', { className: 'NB-fieldset-fields NB-classifiers' },
|
||||
|
|
|
@ -450,7 +450,12 @@ NEWSBLUR.Views.StoryDetailView = Backbone.View.extend({
|
|||
},
|
||||
|
||||
open_story_trainer: function() {
|
||||
NEWSBLUR.reader.open_story_trainer(this.model.id, this.model.get('story_feed_id'));
|
||||
var feed_id = this.model.get('story_feed_id');
|
||||
var options = {};
|
||||
if (NEWSBLUR.reader.flags['social_view']) {
|
||||
options['social_feed'] = true;
|
||||
}
|
||||
NEWSBLUR.reader.open_story_trainer(this.model.id, feed_id, options);
|
||||
},
|
||||
|
||||
star_story: function() {
|
||||
|
|
Loading…
Add table
Reference in a new issue