def user_feeds(request): context = {} if request.user.is_authenticated(): for feed in ['user', 'flat', 'aggregated', 'notification']: context[feed + '_feed'] = feed_manager.get_feed( feed, request.user.id) return context
def unseen_notifications(request): context = {} if request.user.is_authenticated(): feed = feed_manager.get_feed('notification', request.user.id) context['unseen_notifications'] = feed.get().get('unseen', 0) context['unread_notifications'] = feed.get().get('unread', 0) return context
def user_feeds(request): context = {} if request.user.is_authenticated(): for feed in ['user', 'flat', 'aggregated', 'notification']: context[feed + '_feed'] = feed_manager.get_feed(feed, request.user.id) return context
def activity_notify(self): targets = [] if self.city is not None: targets.append(feed_manager.get_feed('cityevents', self.city.slug.replace(" ", "_"))) return targets
def CityCommunityPostPage(request, cityslug): contextdata = {} SelectedCity = get_object_or_404(City, slug = cityslug) SelectedAthlete = get_object_or_404(Athlete, id=request.user.athlete.id) if request.method == 'POST' and request.is_ajax(): form = CommunityPostForm(request.POST) if form.is_valid(): user = request.user body = form.cleaned_data['body'] communitypost = CommunityPost(user=user, body=body, city=SelectedCity) communitypost.save() contextdata = { 'CommunityPost': communitypost } html = render_to_string('communitypost.html', contextdata, context_instance = RequestContext(request)) return JsonResponse({'html': html}) else: msg="AJAX post invalid" contextdata = {'form': form} return render(request, 'communitylocation/citypostpage.html', contextdata) if request.method == 'GET' and request.is_ajax(): if request.GET.get('postid'): if request.GET.get('verifiedathleteslug'): postid = request.GET['postid'] verifiedathleteslug = request.GET['verifiedathleteslug'] SelectedAthlete = get_object_or_404(Athlete, slug=verifiedathleteslug) Comments = Comment.objects.filter(user__username = SelectedAthlete.user.username).filter(object_pk = postid).order_by('submit_date') contextdata = { 'comment_list': Comments, 'postid': postid } commentshtml = render_to_string("comments/list.html", contextdata, context_instance = RequestContext(request)) return JsonResponse({'commentshtml': commentshtml}) else: postid = request.GET['postid'] Comments = Comment.objects.filter(object_pk = postid).order_by('submit_date') contextdata = { 'comment_list': Comments, 'postid': postid } commentshtml = render_to_string("comments/list.html", contextdata, context_instance = RequestContext(request)) return JsonResponse({'commentshtml': commentshtml}) if request.GET.get('postidreq'): postidreq = request.GET['postidreq'] SelectedPost = CommunityPost.objects.get(id = postidreq) SelectedPost.delete() return JsonResponse({'postID': postidreq}) if request.GET.get('commentidreq'): commentidreq = request.GET['commentidreq'] comment = get_object_or_404(comments.get_model(), pk=commentidreq, site__pk=settings.SITE_ID) perform_delete(request, comment) return JsonResponse({'commentID': commentidreq}) else: form = CommunityPostForm() enricher = Enrich() feed = feed_manager.get_feed('citypost', SelectedCity.name.replace(" ", "_")) activities = feed.get(limit=25)['results'] enricher.enrich_activities(activities) contextdata = { 'City': SelectedCity, 'form': form, 'activities': activities } return render(request, 'communitylocation/citypostpage.html', contextdata)