Merge branch 'social' of github.com:samuelclay/NewsBlur into social

* 'social' of github.com:samuelclay/NewsBlur:
  fixing bug with feed exception when there is a duplicate feed id
This commit is contained in:
Samuel Clay 2012-07-17 14:19:16 -07:00
commit 54c68578db
4 changed files with 36 additions and 9 deletions

View file

@ -701,6 +701,20 @@ class Feed(models.Model):
return feed
@classmethod
def get_by_id(cls, feed_id):
feed = None
try:
feed = Feed.objects.get(pk=feed_id)
except Feed.DoesNotExist:
# Feed has been merged after updating. Find the right feed.
duplicate_feeds = DuplicateFeed.objects.filter(duplicate_feed_id=feed_id)
if duplicate_feeds:
feed = duplicate_feeds[0].feed
return feed
def add_update_stories(self, stories, existing_stories, verbose=False):
ret_values = {
ENTRY_NEW:0,

View file

@ -2,7 +2,7 @@ import datetime
from utils import log as logging
from django.shortcuts import get_object_or_404, render_to_response
from django.views.decorators.http import condition
from django.http import HttpResponseForbidden, HttpResponseRedirect, HttpResponse
from django.http import HttpResponseForbidden, HttpResponseRedirect, HttpResponse, Http404
from django.db.models import Q
from django.conf import settings
from django.contrib.auth.decorators import login_required
@ -172,7 +172,10 @@ def exception_retry(request):
user = get_user(request)
feed_id = get_argument_or_404(request, 'feed_id')
reset_fetch = json.decode(request.POST['reset_fetch'])
feed = get_object_or_404(Feed, pk=feed_id)
feed = Feed.get_by_id(feed_id)
if not feed:
raise Http404
feed.next_scheduled_update = datetime.datetime.utcnow()
feed.has_page_exception = False

View file

@ -268,9 +268,14 @@ _.extend(NEWSBLUR.ReaderFeedException.prototype, {
NEWSBLUR.reader.force_feed_refresh(feed_id);
$.modal.close();
}, function(data) {
$error.show().html((data && data.message) || "There was a problem fetching the feed from this URL.");
$loading.removeClass('NB-active');
$submit.removeClass('NB-disabled').attr('value', 'Parse this RSS/XML Feed');
if (data.new_feed_id) {
NEWSBLUR.reader.force_feed_refresh(feed_id, data.new_feed_id);
$.modal.close();
} else {
$error.show().html((data && data.message) || "There was a problem fetching the feed from this URL.");
$loading.removeClass('NB-active');
$submit.removeClass('NB-disabled').attr('value', 'Parse this RSS/XML Feed');
}
});
}
},
@ -292,9 +297,14 @@ _.extend(NEWSBLUR.ReaderFeedException.prototype, {
NEWSBLUR.reader.force_feed_refresh(feed_id);
$.modal.close();
}, function(data) {
$error.show().html((data && data.message) || "There was a problem fetching the feed from this URL.");
$loading.removeClass('NB-active');
$submit.removeClass('NB-disabled').attr('value', 'Fetch Feed from Website');
if (data.new_feed_id) {
NEWSBLUR.reader.force_feed_refresh(feed_id, data.new_feed_id);
$.modal.close();
} else {
$error.show().html((data && data.message) || "There was a problem fetching the feed from this URL.");
$loading.removeClass('NB-active');
$submit.removeClass('NB-disabled').attr('value', 'Fetch Feed from Website');
}
});
}
},

View file

@ -35,7 +35,7 @@ urlpatterns = patterns('',
url(r'zebra/', include('zebra.urls', namespace="zebra", app_name='zebra')),
)
if settings.DEVELOPMENT:
if settings.DEBUG:
urlpatterns += patterns('',
(r'^media/(?P<path>.*)$', 'django.views.static.serve',
{'document_root': settings.MEDIA_ROOT}),