Beispiel #1
0
    def get(self, request, *args, **kwargs):
        if request.user.is_authenticated():
            user = request.user

            updatetime = datetime.now()-timedelta(minutes=2)

            feedlist = Feed.objects.filter(updated__lte=updatetime)
            if feedlist:
                update_articles.apply_async(args=[feedlist])
                for feed in feedlist:
                    feed.updated = datetime.now()
                    feed.save()
            entrieslist = Articles.objects.filter(
                    feed__subscriptions__user=user
                    ).order_by('-published').select_related('feed')[:60]

            #Calls check_read, and returns a list of tuples, in the form of:
            #[(entry, True/False, True/False)]
            entries = check_read(entrieslist,user) 

            context = {
                    'entries' : entries,
                    'page_template' : 'main/entry_index_page.html',
                    }
        else:
            entries = "Please login or register!"
            context = {
                    'entries' : entries,
                    }
        return render_to_response(self.template_name, context, context_instance=RequestContext(request))
Beispiel #2
0
 def form_valid(self,form):
     feedlink = form.cleaned_data['feedlink']
     folder = form.cleaned_data['folder']
     user = self.request.user
     try:
         feed = Feed.objects.get(feedlink=feedlink)
     except Feed.DoesNotExist:
         feed = False
     if feed:
         Subscriptions.objects.get_or_create(user=user, feed=feed, defaults={'folder' : folder })
     else:
         form.save()
         feed =  Feed.objects.get(feedlink=feedlink)
         feed.icon = get_favicon(feedlink)
         feed.save()
         update_articles.apply_async(args=[[feed]])
         blah = Subscriptions(user_id=user.id, feed_id=feed.id, folder_id=folder.id)
         blah.save()
     return redirect(self.get_success_url())
Beispiel #3
0
    def get(self, request, feed_id):
        user=request.user
        entrieslist = Articles.objects.filter(feed=feed_id)\
                .order_by('-published').select_related('feed')[:60]

        updatetime = datetime.now()-timedelta(minutes=2)

        feed = Feed.objects.get(id=feed_id)
        if feed.updated <= updatetime:
            feed.updated = datetime.now()
            feed.save()
            update_articles.apply_async(args=[[feed]])

        entries = check_read(entrieslist,user)
        context = {'entries' : entries,
                'page_template' : 'main/entry_index_page.html',
                'title' : feed.title,
                'feedid' : feed.id}
        return render(request, self.template_name, context)