コード例 #1
0
ファイル: views.py プロジェクト: jneighbs/newsfeed
def source(request, source_id):
	sources = NewsSource.objects.all()
	feeds = NewsFeed.objects.all()
	source = get_object_or_404(NewsSource, pk=source_id)
	source.viewCount += 1
	source.score += 1
	source.save()
	rating = utils.getRating(source_id, request.user)
	topEvents = NewsEvent.objects.all().order_by("score").reverse()[:5]
	articles = Article.objects.filter(newsSource=source_id).order_by("pub_date").reverse()[:20]
	tweets = Tweet.objects.all().reverse()[:5]
	recArticles, recSources = utils.getRecommendations(request.user)
	context = {'tweets':tweets, 'source': source, 'articles': articles, 'sources': sources, 'feeds': feeds, 'rating': rating, 'topEvents': topEvents, 'recArticles': recArticles, 'recSources': recSources}
	return render(request, 'source.html', context)
コード例 #2
0
ファイル: views.py プロジェクト: jneighbs/newsfeed
def event(request, event_id):
	sources = NewsSource.objects.all()
	feeds = NewsFeed.objects.all()
	articles = Article.objects.all()[:20]
	topEvents = NewsEvent.objects.all().order_by("score").reverse()[:5]
	event = NewsEvent.objects.get(id=event_id)
	event.viewCount += 1
	event.score += 1
	event.save()
	rating = utils.getRating(event_id, request.user)
	print rating
	canEdit = utils.canEdit(event_id, request.user)
	topEvents = NewsEvent.objects.all().order_by("score").reverse()[:5]
	tweets = Tweet.objects.all().reverse()[:5]
	recArticles, recSources = utils.getRecommendations(request.user)
	context = {'tweets':tweets, 'articles': articles, 'sources': sources, 'feeds': feeds, 'event': event, 'rating': rating, 'topEvents': topEvents, 'canEdit': canEdit, 'recArticles': recArticles, 'recSources': recSources}
	return render(request, 'event.html', context)
コード例 #3
0
ファイル: views.py プロジェクト: jneighbs/newsfeed
def feed(request, feed_id):
	sources = NewsSource.objects.all()
	feeds = NewsFeed.objects.all()
	feed = get_object_or_404(NewsFeed, pk=feed_id)
	feed.viewCount += 1
	feed.score += 1
	feed.save()
	feed_sources = feed.newsSources.all()

	sourceIds = [source.id for source in feed_sources]
	articles = Article.objects.filter(newsSource_id__in=sourceIds).order_by("pub_date").reverse()[:20]
	tweets = Tweet.objects.all().reverse()[:5]

	ratingValue = utils.getRating(feed_id, request.user)
	topEvents = NewsEvent.objects.all().order_by("score").reverse()[:5]
	context = RequestContext(request, {'user': request.user})
	canEdit = utils.canEditFeed(feed_id, request.user)

	recArticles, recSources = utils.getRecommendations(request.user)

	context = {'tweets':tweets, 'articles': articles, 'feed': feed, 'feed_sources': feed_sources, 'sources': sources, 'feeds': feeds, 'rating': ratingValue, 'topEvents': topEvents, 'canEdit': canEdit, 'recArticles': recArticles, 'recSources': recSources}
	return render(request, 'feed.html', context)