def _handle_reply(request, key, parent=None): """ @return: HttpResponseRedirect or None if comment not added successfully """ comment = request.POST.get("comment", None) if comment and comment.strip(): comment = comment.strip() twitter_username = request.POST.get("comment_twitter_username", None) if twitter_username: twitter_user = TwitterUser.get_or_none(twitter_username=twitter_username) if not twitter_user: twitter_user = TwitterUser.add(twitter_username) twitter_user.get_user_data() else: twitter_user = twitter_utils.current_twitter_user(request) Comment.add(message=comment, twitter_user=twitter_user, key=key, parent=parent) return HttpResponseRedirect(reverse("feedback", args=(key,))) return None
def _handle_reply(request, key, parent=None): """ @return: HttpResponseRedirect or None if comment not added successfully """ comment = request.POST.get('comment', None) if comment and comment.strip(): comment = comment.strip() twitter_username = request.POST.get('comment_twitter_username', None) if twitter_username: feed_url = 'http://twitter.com/statuses/user_timeline/%s.rss' % twitter_username feed = lib.feedparser.parse(feed_url) print feed['status'], type(feed['status']) if feed['status'] == 200: twitter_user = TwitterUser.get_or_none(twitter_username=twitter_username) if not twitter_user: twitter_user = TwitterUser.add(twitter_username) twitter_user.get_user_data() else: return None else: twitter_user = twitter_utils.current_twitter_user(request) Comment.add(message=comment, twitter_user=twitter_user, key=key, parent=parent) return HttpResponseRedirect(reverse('feedback', args=(key, ))) return None