Commits

David Chambers committed eef0026

Removed ridiculous `try` statement.

Comments (0)

Files changed (1)

 
     comments = []
     if FORUM:
-        try:
-            # This call is only here for legacy and migration support, it will never return a value on Mango made threads
-            thread = DISQUS.get_thread_by_url(FORUM, document.urls['canon']['abs'])
-            if not thread:
-                thread = DISQUS.thread_by_identifier(FORUM, document.title, document.urls['canon']['rel'])['thread']
+        # This call is only here for legacy and migration support, it will never return a value on Mango made threads
+        thread = DISQUS.get_thread_by_url(FORUM, document.urls['canon']['abs'])
+        if not thread:
+            thread = DISQUS.thread_by_identifier(FORUM, document.title, document.urls['canon']['rel'])['thread']
 
-            if request.method == 'POST':
-                form = CommentForm(request.POST, request=request)
-                if form.is_valid():
-                    author_name = form.cleaned_data['author_name']
-                    author_email = form.cleaned_data['author_email']
-                    author_url = form.cleaned_data['author_url']
-                    message = form.cleaned_data['message']
-                    subscribe = form.cleaned_data['subscribe']
+        if request.method == 'POST':
+            form = CommentForm(request.POST, request=request)
+            if form.is_valid():
+                author_name = form.cleaned_data['author_name']
+                author_email = form.cleaned_data['author_email']
+                author_url = form.cleaned_data['author_url']
+                message = form.cleaned_data['message']
+                subscribe = form.cleaned_data['subscribe']
 
-                    if subscribe and SUBSCRIPTIONS: # don't assume that SUBSCRIPTIONS is True
-                        subscriptions = Subscription.objects.filter(
+                if subscribe and SUBSCRIPTIONS: # don't assume that SUBSCRIPTIONS is True
+                    subscriptions = Subscription.objects.filter(
+                            subscriber_email=author_email, url=document.urls['canon']['abs'])
+                    if not subscriptions:
+                        subscription = Subscription(subscriber_name=author_name,
                                 subscriber_email=author_email, url=document.urls['canon']['abs'])
-                        if not subscriptions:
-                            subscription = Subscription(subscriber_name=author_name,
-                                    subscriber_email=author_email, url=document.urls['canon']['abs'])
-                            subscription.save()
-                        if settings.DEBUG:
-                            print '%s is %s subscribed to comments on %s' % (author_name,
-                                    'already' if subscriptions else 'now', thread.title)
+                        subscription.save()
+                    if settings.DEBUG:
+                        print '%s is %s subscribed to comments on %s' % (author_name,
+                                'already' if subscriptions else 'now', thread.title)
 
-                    # send request to Disqus
-                    comment = DISQUS.create_post(FORUM, thread,
-                            message=message,
-                            author_name=author_name,
-                            author_email=author_email,
-                            author_url=author_url,
-                            ip_address=request.META['REMOTE_ADDR'])
+                # send request to Disqus
+                comment = DISQUS.create_post(FORUM, thread,
+                        message=message,
+                        author_name=author_name,
+                        author_email=author_email,
+                        author_url=author_url,
+                        ip_address=request.META['REMOTE_ADDR'])
 
-                    # store comment so that it can be displayed to the author even if withheld for moderation
-                    request.session['comment'] = comment
+                # store comment so that it can be displayed to the author even if withheld for moderation
+                request.session['comment'] = comment
 
-                    # send e-mail notification
-                    author = u'%s <%s>' % (author_name, author_email)
-                    subject = u'[%s] Comment: "%s"' % (SITE_TITLE, document.title)
-                    context = {
-                        'commenter': author,
-                        'comment': message,
-                        'base_url': BASE_URL,
-                        'path': path,
-                        'api_key': hashlib.sha1(DISQUS_API_KEY).hexdigest(),
-                        'post_id': comment.id,
-                        'thread_id': thread.id,
-                    }
-                    try:
-                        recipient = primary_author_email()
-                    except EmptySettingError as e:
-                        return http.HttpResponseServerError(e.html())
+                # send e-mail notification
+                author = u'%s <%s>' % (author_name, author_email)
+                subject = u'[%s] Comment: "%s"' % (SITE_TITLE, document.title)
+                context = {
+                    'commenter': author,
+                    'comment': message,
+                    'base_url': BASE_URL,
+                    'path': path,
+                    'api_key': hashlib.sha1(DISQUS_API_KEY).hexdigest(),
+                    'post_id': comment.id,
+                    'thread_id': thread.id,
+                }
+                try:
+                    recipient = primary_author_email()
+                except EmptySettingError as e:
+                    return http.HttpResponseServerError(e.html())
 
-                    msg = EmailMultiAlternatives(subject, loader.render_to_string('email/moderator.dtext', context),
-                            to=[recipient], headers={'Reply-To': author})
-                    msg.attach_alternative(loader.render_to_string('email/moderator.dhtml', context), 'text/html')
-                    msg.send(fail_silently=False)
+                msg = EmailMultiAlternatives(subject, loader.render_to_string('email/moderator.dtext', context),
+                        to=[recipient], headers={'Reply-To': author})
+                msg.attach_alternative(loader.render_to_string('email/moderator.dhtml', context), 'text/html')
+                msg.send(fail_silently=False)
 
-                    return http.HttpResponseRedirect('redirect/')
+                return http.HttpResponseRedirect('redirect/')
 
-            for c in DISQUS.get_thread_posts(FORUM, thread, limit=9999, exclude='killed'):
-                if c.has_been_moderated:
-                    comments.append(c)
-            comments.sort(key=lambda comment: comment.created_at)
-        except disqus.APIError:
-            pass
+        for c in DISQUS.get_thread_posts(FORUM, thread, limit=9999, exclude='killed'):
+            if c.has_been_moderated:
+                comments.append(c)
+        comments.sort(key=lambda comment: comment.created_at)
 
     context = _defaults(request, context={
         'comments': comments,