Skip to content

Commit b2d2816

Browse files
committed
Use a custom view for RFCs, not the generic view. The generic
view would try to access the PK value, which for IDInternal is an FK to InternetDraft, which is inappropriate for RFCs. Also use the IDInternal value for rfc_flag when deciding on the absolute url, not the comment table, since rfc_flag can be set wrong in the comment table. Fixes adamlaska#218. - Legacy-Id: 913
1 parent 9d119f2 commit b2d2816

4 files changed

Lines changed: 24 additions & 4 deletions

File tree

ietf/idtracker/models.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -544,7 +544,9 @@ class DocumentComment(models.Model):
544544
origin_state = models.ForeignKey(IDState, db_column='origin_state', null=True, related_name="comments_coming_from_state")
545545
ballot = models.IntegerField(null=True, choices=BALLOT_CHOICES)
546546
def get_absolute_url(self):
547-
if self.rfc_flag:
547+
# use self.document.rfc_flag, since
548+
# self.rfc_flag is not always set properly.
549+
if self.document.rfc_flag:
548550
return "/idtracker/rfc%d/comment/%d/" % (self.document_id, self.id)
549551
else:
550552
return "/idtracker/%s/comment/%d/" % (self.document.draft.filename, self.id)

ietf/idtracker/testurls.list

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,9 @@ skipredirect,200 /idtracker/ballot/1760/ https://datatracker.ietf.org/public/pid
1919
200 /feed/comments/rfc3373/
2020
200 /idtracker/?search_group_acronym=&search_job_owner=0&search_rfcnumber=&search_status_id=&sub_state_id=6&search_cur_state=&search_button=SEARCH&search_filename=bgp-m&search_area_acronym= https://datatracker.ietf.org/public/pidtracker.cgi?command=search_list&search_job_owner=0&search_group_acronym=&search_status_id=&search_cur_state=&sub_state_id=6&search_filename=bgp-m&search_rfcnumber=&search_area_acronym=&search_button=SEARCH
2121
200 /feed/last-call/
22+
23+
# An RFC with no matching value in InternetDrafts. This tests
24+
# subtle cases of using the draft relation when it's not appropriate.
25+
# See ticket #218.
26+
200 /idtracker/rfc2444/
27+
200 /feed/comments/rfc2444/

ietf/idtracker/urls.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,8 @@
2828
(r'^status/$', views.status),
2929
(r'^status/last-call/$', views.last_call),
3030
)
31-
urlpatterns += patterns('django.views.generic.list_detail',
32-
(r'^rfc(?P<object_id>\d+)/$', 'object_detail', rfc_dict),
33-
)
3431
urlpatterns += patterns('',
32+
(r'^rfc(?P<object_id>\d+)/$', views.view_rfc),
3533
(r'^(?P<object_id>\d+)/$', views.redirect_id),
3634
(r'^(?P<slug>[^/]+)/$', views.view_id, dict(id_dict, slug_field='draft__filename')),
3735
(r'^comment/(?P<object_id>\d+)/$', views.view_comment, comment_dict),

ietf/idtracker/views.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,20 @@ def view_id(request, queryset, slug, slug_field):
206206
return render_to_response('idtracker/idinternal_notfound.html', {'draft': draft}, context_instance=RequestContext(request))
207207
return render_to_response('idtracker/idinternal_detail.html', {'object': object}, context_instance=RequestContext(request))
208208

209+
def view_rfc(request, object_id):
210+
'''A replacement for the object_detail generic view for this
211+
specific case to work around the following problem:
212+
The object_detail generic view looks up the value of the
213+
primary key in order to hand it to populate_xheaders.
214+
In the IDInternal table, the primary key is a foreign key
215+
to InternetDraft. object_detail assumes that the PK is not
216+
an FK so doesn't do the foo_id trick, so the lookup is
217+
attempted and an exception raised if there is no match.
218+
This view gets the appropriate row from IDInternal and
219+
calls the template with the necessary context.'''
220+
object = get_object_or_404(IDInternal, pk=object_id, rfc_flag=1)
221+
return render_to_response('idtracker/idinternal_detail.html', {'object': object}, context_instance=RequestContext(request))
222+
209223
# Wrappers around object_detail to give permalink a handle.
210224
# The named-URLs feature in django 0.97 will eliminate the
211225
# need for these.

0 commit comments

Comments
 (0)