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
This commit is contained in:
Henrik Levkowetz 2012-07-03 13:46:23 +00:00
parent 71894599bf
commit c8af089ab1
3 changed files with 15 additions and 4 deletions

View file

@ -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())

View file

@ -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):

View file

@ -37,7 +37,11 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
<tr class="{{ forloop.counter|divisibleby:2|yesno:"oddrow,evenrow" }}">
{% if user.is_authenticated and show_add_to_list %}
<td class="addtolist">
<a href="{% url community_add_document doc.id.draft_name %}" title="Add to your personal ID list"><img src="/images/add_to_list.png" alt="Add to your personal ID list" /></a>
{% if doc.id %}
<a href="{% url community_add_document doc.id.draft_name %}" title="Add to your personal ID list"><img src="/images/add_to_list.png" alt="Add to your personal ID list" /></a>
{% else %}
<a href="{% url community_add_document doc.rfc.filename %}" title="Add to your personal ID list"><img src="/images/add_to_list.png" alt="Add to your personal ID list" /></a>
{% endif %}
</td>
{% endif %}
<td class="doc">