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 #218. - Legacy-Id: 913
This commit is contained in:
parent
9d119f2989
commit
b2d2816b8f
|
@ -544,7 +544,9 @@ class DocumentComment(models.Model):
|
|||
origin_state = models.ForeignKey(IDState, db_column='origin_state', null=True, related_name="comments_coming_from_state")
|
||||
ballot = models.IntegerField(null=True, choices=BALLOT_CHOICES)
|
||||
def get_absolute_url(self):
|
||||
if self.rfc_flag:
|
||||
# use self.document.rfc_flag, since
|
||||
# self.rfc_flag is not always set properly.
|
||||
if self.document.rfc_flag:
|
||||
return "/idtracker/rfc%d/comment/%d/" % (self.document_id, self.id)
|
||||
else:
|
||||
return "/idtracker/%s/comment/%d/" % (self.document.draft.filename, self.id)
|
||||
|
|
|
@ -19,3 +19,9 @@ skipredirect,200 /idtracker/ballot/1760/ https://datatracker.ietf.org/public/pid
|
|||
200 /feed/comments/rfc3373/
|
||||
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
|
||||
200 /feed/last-call/
|
||||
|
||||
# An RFC with no matching value in InternetDrafts. This tests
|
||||
# subtle cases of using the draft relation when it's not appropriate.
|
||||
# See ticket #218.
|
||||
200 /idtracker/rfc2444/
|
||||
200 /feed/comments/rfc2444/
|
||||
|
|
|
@ -28,10 +28,8 @@ urlpatterns += patterns('',
|
|||
(r'^status/$', views.status),
|
||||
(r'^status/last-call/$', views.last_call),
|
||||
)
|
||||
urlpatterns += patterns('django.views.generic.list_detail',
|
||||
(r'^rfc(?P<object_id>\d+)/$', 'object_detail', rfc_dict),
|
||||
)
|
||||
urlpatterns += patterns('',
|
||||
(r'^rfc(?P<object_id>\d+)/$', views.view_rfc),
|
||||
(r'^(?P<object_id>\d+)/$', views.redirect_id),
|
||||
(r'^(?P<slug>[^/]+)/$', views.view_id, dict(id_dict, slug_field='draft__filename')),
|
||||
(r'^comment/(?P<object_id>\d+)/$', views.view_comment, comment_dict),
|
||||
|
|
|
@ -206,6 +206,20 @@ def view_id(request, queryset, slug, slug_field):
|
|||
return render_to_response('idtracker/idinternal_notfound.html', {'draft': draft}, context_instance=RequestContext(request))
|
||||
return render_to_response('idtracker/idinternal_detail.html', {'object': object}, context_instance=RequestContext(request))
|
||||
|
||||
def view_rfc(request, object_id):
|
||||
'''A replacement for the object_detail generic view for this
|
||||
specific case to work around the following problem:
|
||||
The object_detail generic view looks up the value of the
|
||||
primary key in order to hand it to populate_xheaders.
|
||||
In the IDInternal table, the primary key is a foreign key
|
||||
to InternetDraft. object_detail assumes that the PK is not
|
||||
an FK so doesn't do the foo_id trick, so the lookup is
|
||||
attempted and an exception raised if there is no match.
|
||||
This view gets the appropriate row from IDInternal and
|
||||
calls the template with the necessary context.'''
|
||||
object = get_object_or_404(IDInternal, pk=object_id, rfc_flag=1)
|
||||
return render_to_response('idtracker/idinternal_detail.html', {'object': object}, context_instance=RequestContext(request))
|
||||
|
||||
# Wrappers around object_detail to give permalink a handle.
|
||||
# The named-URLs feature in django 0.97 will eliminate the
|
||||
# need for these.
|
||||
|
|
Loading…
Reference in a new issue