Beispiel #1
0
 def buildStoryTable(stories, maxPages, curPage):
     dict = {'page': curPage,
             'total':maxPages
             }    
     rows = []
     cnt = 0;
     h = feedFilter()
     for story in stories:
         cnt += 1
         score, evidence = h.Score(story, True)
         cleansed = story_table.understandEvidence(evidence)
         score = "%.2f" % score
         votes = ''
         if (story.Ups != None and story.Downs != None):
             votes = story.Ups - story.Downs
         rows.append({'id': story.id,
                      'cell':
                         [str(story.AddedTime.day),
                          story.category,
                          story_table.addLink(story.Url, story.title),
                          story_table.addCheckbox(story.id, story.valid, 'toggleValid'),
                          story_table.addCheckbox(story.id, story.VoteUp,'toggleVote'),
                          score,
                          votes   
                          ]
                     })
     dict['items'] = cnt
     dict['rows'] = rows
     return dict
Beispiel #2
0
def vote(request, story_id):
    p = get_object_or_404(Story, pk = story_id)
    filter = feedFilter()
    filter.UnTrain(p)
    p.valid =  not p.valid
    p.save()
    filter.Train(p)
    r = HttpResponse(mimetype='application/json')
    r.write(simplejson.dumps({'valid': str(p.valid)}))
    return r
Beispiel #3
0
 def retrain():
     h = feedFilter()
     h.TrainAll()
Beispiel #4
0
 def addFeed(feedUrl, category):
     filter = feedFilter()
     if (feedUrl.endswith('.xml')):
         addFeeds.addXmlFeed(feedUrl, category, filter)
     elif (feedUrl.endswith('.json')):
         addFeeds.addJsonFeed(feedUrl, category, filter)