Skip to content

Commit

Permalink
Fixing numerous exceptions. Story training when not having a story se…
Browse files Browse the repository at this point in the history
…lected. Forbidden RSS feeds throwing exceptions instead of 403s.
  • Loading branch information
samuelclay committed Dec 12, 2012
1 parent dac88c0 commit f9918a4
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 9 deletions.
4 changes: 2 additions & 2 deletions apps/oauth/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ def follow_twitter_account(request):
logging.user(request, "~BB~FR~SKFollowing Twitter: %s" % username)

if username not in ['samuelclay', 'newsblur']:
return HttpResponseForbidden
return HttpResponseForbidden()

social_services = MSocialServices.objects.get(user_id=request.user.pk)
try:
Expand All @@ -175,7 +175,7 @@ def unfollow_twitter_account(request):
logging.user(request, "~BB~FRUnfollowing Twitter: %s" % username)

if username not in ['samuelclay', 'newsblur']:
return HttpResponseForbidden
return HttpResponseForbidden()

social_services = MSocialServices.objects.get(user_id=request.user.pk)
try:
Expand Down
8 changes: 5 additions & 3 deletions apps/social/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -1049,9 +1049,10 @@ def ignore_follower(request):
return {'code': code}


@required_params('query')
@json.json_view
def find_friends(request):
query = request.GET.get('query')
query = request.GET['query']
limit = int(request.GET.get('limit', 3))
profiles = MSocialProfile.objects.filter(username__icontains=query)[:limit]
if not profiles:
Expand Down Expand Up @@ -1161,7 +1162,7 @@ def shared_stories_rss_feed(request, user_id, username):
current_site = current_site and current_site.domain

if social_profile.private:
return HttpResponseForbidden
return HttpResponseForbidden()

data = {}
data['title'] = social_profile.title
Expand Down Expand Up @@ -1205,9 +1206,10 @@ def shared_stories_rss_feed(request, user_id, username):
))
return HttpResponse(rss.writeString('utf-8'))

@required_params('user_id')
@json.json_view
def social_feed_trainer(request):
social_user_id = request.REQUEST.get('user_id')
social_user_id = request.REQUEST['user_id']
social_profile = MSocialProfile.get_user(social_user_id)
social_user = get_object_or_404(User, pk=social_user_id)
user = get_user(request)
Expand Down
5 changes: 3 additions & 2 deletions media/js/newsblur/reader/reader.js
Original file line number Diff line number Diff line change
Expand Up @@ -1825,14 +1825,15 @@
options = options || {};
story_id = story_id || this.active_story && this.active_story.id;
feed_id = feed_id || (story_id && this.model.get_story(story_id).get('story_feed_id'));
var story = this.model.get_story(story_id);
// console.log(["open_story_trainer", story_id, feed_id, options]);

if (story_id && feed_id) {
options['feed_loaded'] = !this.flags['river_view'];
if (this.flags['social_view'] && !_.string.contains(this.active_feed, 'river:')) {
options['social_feed_id'] = this.active_feed;
} else if (this.flags['social_view'] && this.active_story.get('friend_user_ids')) {
options['social_feed_id'] = 'social:' + this.active_story.get('friend_user_ids')[0];
} else if (this.flags['social_view'] && story.get('friend_user_ids')) {
options['social_feed_id'] = 'social:' + story.get('friend_user_ids')[0];
}
NEWSBLUR.classifier = new NEWSBLUR.ReaderClassifierStory(story_id, feed_id, options);
}
Expand Down
4 changes: 2 additions & 2 deletions utils/view_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,15 +78,15 @@ def view_wrapper(self, request, fn, *args, **kwargs):

def disallowed(self, param=None, param_type=None, method=False, status_code=400):
if method:
message = "Invalid method. Use %s." % self.method
message = "Invalid HTTP method. Use %s." % self.method
elif param_type:
message = "Invalid paramter: %s - needs to be %s" % (
param,
param_type,
)
else:
message = "Missing parameter: %s" % param
print status_code

return HttpResponse(json.encode({
'message': message,
'code': -1,
Expand Down

0 comments on commit f9918a4

Please sign in to comment.