# HG changeset patch # User Brian Neal # Date 1300238385 0 # Node ID b2b37cdd020aa1eb033e53c7f4651d75dd42908c # Parent a1b03de20345cc0c80c6e832bc4a763f8bf8d693 Fixing #189; 500 error when deleting forum topic subscription. diff -r a1b03de20345 -r b2b37cdd020a gpp/forums/views/favorites.py --- a/gpp/forums/views/favorites.py Wed Mar 09 02:39:24 2011 +0000 +++ b/gpp/forums/views/favorites.py Wed Mar 16 01:19:45 2011 +0000 @@ -47,10 +47,9 @@ for topic in user.favorite_topics.filter(id__in=delete_ids): user.favorite_topics.remove(topic) - page_num = request.POST.get('page', 1) - else: - page_num = request.GET.get('page', 1) + return HttpResponseRedirect(reverse("forums-manage_favorites")) + page_num = request.GET.get('page', 1) topics = user.favorite_topics.select_related().order_by('-update_date') paginator = DiggPaginator(topics, 20, body=5, tail=2, margin=3, padding=2) try: diff -r a1b03de20345 -r b2b37cdd020a gpp/forums/views/subscriptions.py --- a/gpp/forums/views/subscriptions.py Wed Mar 09 02:39:24 2011 +0000 +++ b/gpp/forums/views/subscriptions.py Wed Mar 16 01:19:45 2011 +0000 @@ -94,7 +94,7 @@ topic = get_object_or_404(Topic, id=topic_id) try: sub = Subscription.objects.get(topic=topic, user=request.user) - except Subscriptions.DoesNotExist: + except Subscription.DoesNotExist: pass else: sub.delete() @@ -121,20 +121,19 @@ user = request.user if request.method == "POST": if request.POST.get('delete_all'): - user.subscriptions.clear() + Subscription.objects.filter(user=user).delete() else: delete_ids = request.POST.getlist('delete_ids') try: delete_ids = [int(id) for id in delete_ids] except ValueError: raise Http404 - for topic in user.subscriptions.filter(id__in=delete_ids): - user.subscriptions.remove(topic) - page_num = request.POST.get('page', 1) - else: - page_num = request.GET.get('page', 1) + Subscription.objects.filter(user=user, topic__in=delete_ids).delete() + return HttpResponseRedirect(reverse("forums-manage_subscriptions")) + + page_num = request.GET.get('page', 1) topics = user.subscriptions.select_related().order_by('-update_date') paginator = DiggPaginator(topics, 20, body=5, tail=2, margin=3, padding=2) try: