From c8af089ab1a994576ff270856a56a110d59d30aa Mon Sep 17 00:00:00 2001 From: Henrik Levkowetz Date: Tue, 3 Jul 2012 13:46:23 +0000 Subject: [PATCH] Fix a bug which made the community tracking code crash when search results would show an old RFC without an associated draft. - Legacy-Id: 4569 --- ietf/community/views.py | 6 +++--- ietf/idrfc/idrfc_wrapper.py | 7 +++++++ ietf/templates/idrfc/search_result_row.html | 6 +++++- 3 files changed, 15 insertions(+), 4 deletions(-) diff --git a/ietf/community/views.py b/ietf/community/views.py index 604548239..5c5243de7 100644 --- a/ietf/community/views.py +++ b/ietf/community/views.py @@ -15,7 +15,7 @@ from django.utils.http import urlquote from ietf.community.models import CommunityList, Rule, EmailSubscription, ListNotification from ietf.community.forms import RuleForm, DisplayForm, SubscribeForm, UnSubscribeForm from ietf.group.models import Group -from ietf.doc.models import Document, DocEvent +from ietf.doc.models import Document, DocEvent, DocAlias def _manage_list(request, clist): @@ -77,7 +77,7 @@ def add_document(request, document_name): path = urlquote(request.get_full_path()) tup = settings.LOGIN_URL, REDIRECT_FIELD_NAME, path return HttpResponseRedirect('%s?%s=%s' % tup) - doc = get_object_or_404(Document, name=document_name) + doc = get_object_or_404(DocAlias, name=document_name).document clist = CommunityList.objects.get_or_create(user=request.user)[0] clist.update() return add_document_to_list(request, clist, doc) @@ -89,7 +89,7 @@ def remove_document(request, list_id, document_name): path = urlquote(request.get_full_path()) tup = settings.LOGIN_URL, REDIRECT_FIELD_NAME, path return HttpResponseRedirect('%s?%s=%s' % tup) - doc = get_object_or_404(Document, name=document_name) + doc = get_object_or_404(DocAlias, name=document_name).document clist.added_ids.remove(doc) clist.update() return HttpResponseRedirect(clist.get_manage_url()) diff --git a/ietf/idrfc/idrfc_wrapper.py b/ietf/idrfc/idrfc_wrapper.py index 3bdd19966..4e9332b29 100644 --- a/ietf/idrfc/idrfc_wrapper.py +++ b/ietf/idrfc/idrfc_wrapper.py @@ -43,6 +43,7 @@ from django.db import models from django.core.urlresolvers import reverse from django.conf import settings import types +import debug BALLOT_ACTIVE_STATES = ['In Last Call', 'Waiting for Writeup', @@ -390,6 +391,12 @@ class RfcWrapper: else: # TODO: get AD name of the draft return None + def filename(self): + debug.show('self') + debug.show('self._rfc') + debug.show('self._rfcindex') + debug.show('self._rfcindex.filename') + return self._rfcindex.filename @models.permalink def get_absolute_url(self): diff --git a/ietf/templates/idrfc/search_result_row.html b/ietf/templates/idrfc/search_result_row.html index 5b71046b5..af19ec72a 100644 --- a/ietf/templates/idrfc/search_result_row.html +++ b/ietf/templates/idrfc/search_result_row.html @@ -37,7 +37,11 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. {% if user.is_authenticated and show_add_to_list %} -Add to your personal ID list +{% if doc.id %} + Add to your personal ID list +{% else %} + Add to your personal ID list +{% endif %} {% endif %}