Skip to content

Commit 814e317

Browse files
committed
Replaced most of /idtracker/ (search, document page, ballot page, comment page) with directs to /doc/
- Legacy-Id: 2168
1 parent 8e4846b commit 814e317

10 files changed

Lines changed: 34 additions & 709 deletions

ietf/idtracker/forms.py

Lines changed: 0 additions & 21 deletions
This file was deleted.

ietf/idtracker/testurl.list

Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -6,31 +6,22 @@
66
200 /idtracker/status/
77
200 /idtracker/status/last-call/
88

9-
200 /idtracker/rfc3847/
9+
301 /idtracker/rfc3847/
1010
301 /idtracker/12689/
11-
200 /idtracker/draft-ietf-isis-link-attr/
12-
200 /idtracker/draft-ietf-isis-link-attr/comment/65232/
11+
301 /idtracker/draft-ietf-isis-link-attr/
12+
301 /idtracker/draft-ietf-isis-link-attr/comment/65232/
1313
301 /idtracker/draft-eronen-tls-psk/ # no IESG information
14-
200 /idtracker/comment/65232/
15-
200 /idtracker/ballot/1760/
16-
200 /idtracker/
14+
301 /idtracker/comment/65232/
15+
301 /idtracker/ballot/1760/
16+
301 /idtracker/
1717
200 /feed/comments/draft-ietf-isis-link-attr/
1818
200 /feed/comments/rfc3373/
19-
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=
20-
200 /idtracker/?search_rfcnumber=1234
21-
200 /idtracker/?search_job_owner=53&search_filename=nfs
22-
200 /idtracker/?sub_state_id=5
23-
200,heavy /idtracker/?sub_state_id=6
24-
200 /idtracker/?search_area_acronym=1260
25-
200 /idtracker/?search_group_acronym=tls
26-
200 /idtracker/?search_group_acronym=%EF%BD%8C #non-ASCII
27-
200 /idtracker/?search_filename=%EF%BD%8C #non-ASCII
2819
200 /feed/last-call/
2920

3021
# An RFC with no matching value in InternetDrafts. This tests
3122
# subtle cases of using the draft relation when it's not appropriate.
3223
# See ticket #218.
33-
200 /idtracker/rfc2444/
24+
301 /idtracker/rfc2444/
3425
200 /feed/comments/rfc2444/
3526

3627
# Test case for missing comment time (bug fixed in changeset 1733)

ietf/idtracker/urls.py

Lines changed: 8 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,9 @@
11
# Copyright The IETF Trust 2007, All Rights Reserved
22

33
from django.conf.urls.defaults import patterns
4-
from ietf.idtracker.models import IDInternal, IDState, IDSubState, DocumentComment, BallotInfo
4+
from ietf.idtracker.models import IDState, IDSubState
55
from ietf.idtracker import views
6-
7-
id_dict = {
8-
'queryset': IDInternal.objects.all().filter(rfc_flag=0),
9-
}
10-
rfc_dict = {
11-
'queryset': IDInternal.objects.all().filter(rfc_flag=1),
12-
}
13-
comment_dict = {
14-
'queryset': DocumentComment.objects.all().filter(public_flag=1),
15-
}
16-
17-
ballot_dict = {
18-
'queryset': BallotInfo.objects.all()
19-
}
6+
from django.views.generic.simple import redirect_to
207

218
urlpatterns = patterns('django.views.generic.simple',
229
(r'^help/state/$', 'direct_to_template', { 'template': 'idtracker/states.html', 'extra_context': { 'states': IDState.objects.all(), 'substates': IDSubState.objects.all() } }),
@@ -28,13 +15,13 @@
2815
(r'^status/last-call/$', views.last_call),
2916
)
3017
urlpatterns += patterns('',
31-
(r'^rfc(?P<object_id>\d+)/$', views.view_rfc),
18+
(r'^rfc0*(?P<rfc_number>\d+)/$', views.redirect_rfc),
3219
(r'^(?P<object_id>\d+)/$', views.redirect_id),
33-
(r'^(?P<slug>[^/]+)/$', views.view_id, dict(id_dict, slug_field='draft__filename')),
34-
(r'^comment/(?P<object_id>\d+)/$', views.view_comment, comment_dict),
35-
(r'^ballot/(?P<object_id>\d+)/$', views.view_ballot, ballot_dict),
36-
(r'^(?P<slug>[^/]+)/comment/(?P<object_id>\d+)/$', views.comment, comment_dict),
20+
(r'^(?P<filename>[^/]+)/$', views.redirect_filename),
21+
(r'^comment/(?P<object_id>\d+)/$', views.redirect_comment),
22+
(r'^ballot/(?P<object_id>\d+)/$', views.redirect_ballot),
23+
(r'^([^/]+)/comment/(?P<object_id>\d+)/$', views.redirect_comment),
3724
(r'^help/state/(?P<state>\d+)/$', views.state_desc),
3825
(r'^help/substate/(?P<state>\d+)/$', views.state_desc, { 'is_substate': 1 }),
39-
(r'^$', views.search),
26+
(r'^$', redirect_to, { 'url': '/doc/'}),
4027
)

ietf/idtracker/views.py

Lines changed: 19 additions & 164 deletions
Original file line numberDiff line numberDiff line change
@@ -2,137 +2,12 @@
22

33
# Create your views here.
44
from django.http import HttpResponsePermanentRedirect
5-
from django import forms
65
from django.template import RequestContext
76
from django.shortcuts import get_object_or_404, render_to_response
8-
from django.db.models import Q
97
from django.views.generic.list_detail import object_detail, object_list
10-
from ietf.idtracker.models import InternetDraft, IDInternal, IDState, IDSubState, Rfc, DocumentWrapper
11-
from ietf.idtracker.forms import IDSearch
12-
from ietf.utils import normalize_draftname
8+
from ietf.idtracker.models import InternetDraft, IDInternal, IDState, IDSubState, BallotInfo, DocumentComment
139
import re
1410

15-
def search(request):
16-
# for compatability with old tracker form, which has
17-
# "all substates" = 6.
18-
args = request.GET.copy()
19-
if args.get('sub_state_id', '') == '6':
20-
args['sub_state_id'] = ''
21-
# "job_owner" of "0" means "All/Any"
22-
if args.get('search_job_owner', '') == '0':
23-
args['search_job_owner'] = ''
24-
if args.has_key('search_filename'):
25-
args['search_filename'] = normalize_draftname(args['search_filename'])
26-
form = IDSearch(args)
27-
# if there's a post, do the search and supply results to the template
28-
searching = False
29-
# filename, rfc_number, group searches are seperate because
30-
# they can't be represented as simple searches in the data model.
31-
qdict = {
32-
'search_job_owner': 'job_owner',
33-
'search_cur_state': 'cur_state',
34-
'sub_state_id': 'cur_sub_state',
35-
'search_area_acronym': 'area_acronym',
36-
}
37-
q_objs = []
38-
for k in qdict.keys() + ['search_group_acronym', 'search_rfcnumber', 'search_filename', 'search_status_id']:
39-
if args.has_key(k):
40-
searching = True
41-
if args[k] != '' and qdict.has_key(k):
42-
q_objs.append(Q(**{qdict[k]: args[k]}))
43-
if form.is_valid() == False:
44-
searching = False
45-
if searching:
46-
# Non-ASCII group/filename doesn't match anything; this check
47-
# is currently needed to avoid complaints from MySQL.
48-
for k in ['search_group_acronym','search_filename']:
49-
try:
50-
tmp = str(args.get(k, ''))
51-
except:
52-
args[k] = '*NOSUCH*'
53-
54-
group = args.get('search_group_acronym', '')
55-
if group != '':
56-
rfclist = [rfc['rfc_number'] for rfc in Rfc.objects.all().filter(group_acronym=group).values('rfc_number')]
57-
draftlist = [draft['id_document_tag'] for draft in InternetDraft.objects.all().filter(group__acronym=group).values('id_document_tag')]
58-
if rfclist or draftlist:
59-
q_objs.append(Q(draft__in=draftlist)&Q(rfc_flag=0)|Q(draft__in=rfclist)&Q(rfc_flag=1))
60-
else:
61-
q_objs.append(Q(draft__isnull=True)) # no matches
62-
rfc_number = args.get('search_rfcnumber', '')
63-
if rfc_number != '':
64-
draftlist = [draft['id_document_tag'] for draft in InternetDraft.objects.all().filter(rfc_number=rfc_number).values('id_document_tag')]
65-
q_objs.append(Q(draft__in=draftlist)&Q(rfc_flag=0)|Q(draft=rfc_number)&Q(rfc_flag=1))
66-
filename = args.get('search_filename', '')
67-
if filename != '':
68-
q_objs.append(Q(draft__filename__icontains=filename,rfc_flag=0))
69-
status = args.get('search_status_id', '')
70-
if status != '':
71-
q_objs.append(Q(draft__status=status,rfc_flag=0))
72-
matches = IDInternal.objects.all().exclude(draft=999999).filter(*q_objs)
73-
matches = matches.order_by('cur_state', 'cur_sub_state', 'ballot', '-primary_flag')
74-
# sort by date in reverse
75-
# first build docstate groups, within which we sort
76-
# in each docstate group, we build ballot id groups, which we sort
77-
m1 = [] # list of: docstate, list of: event date; ballot id; list of: ms for the ballot id
78-
for m in matches:
79-
if m1 and m1[-1][0] == m.docstate():
80-
if m1[-1][1] and m1[-1][1][0][1] == m.ballot_id:
81-
m1[-1][1][0][4].append(m)
82-
else:
83-
m1[-1][1].append((m.event_date, m.ballot_id, m.primary_flag, m.draft_id, [m]))
84-
else:
85-
m1.append((m.docstate(), [(m.event_date, m.ballot_id, m.primary_flag, m.draft_id, [m])]))
86-
matches = []
87-
for ms in m1: ms[1].sort(reverse=True)
88-
for ms in m1:
89-
for mt in ms[1]:
90-
matches.extend(mt[4])
91-
#
92-
# Now search by I-D exists, if there could be any results.
93-
# If searching by job owner, current state or substate, there
94-
# can't be any "I-D exists" matches.
95-
if not(args.get('search_job_owner', 0) or args.get('search_cur_state', 0) or args.get('sub_state_id', 0)):
96-
if not(args.get('search_rfcnumber', 0)):
97-
in_tracker=[i['draft'] for i in IDInternal.objects.filter(rfc_flag=0).values('draft')]
98-
qdict = {
99-
'search_area_acronym': 'group__ietfwg__areagroup__area',
100-
'search_group_acronym': 'group__acronym',
101-
'search_filename': 'filename__icontains',
102-
#'search_status_id': 'status',
103-
}
104-
q_objs = [Q(**{qdict[k]: args[k]}) for k in qdict.keys() if args.get(k, '') != '']
105-
idmatches = InternetDraft.objects.filter(*q_objs).exclude(id_document_tag__in=in_tracker).filter(status__status='Active').order_by('filename')
106-
# resolve the queryset, append wrapper objects.
107-
matches = list(matches) + [DocumentWrapper(id) for id in idmatches]
108-
if not(args.get('search_filename', '') or args.get('search_status_id', 0)) and args.get('search_rfcnumber', 0):
109-
# the existing area acronym support in this function
110-
# in pidtracker.cgi is broken, since it compares an
111-
# area acronym string in the database against an
112-
# area acronym number in the form. We just ignore
113-
# the area (resulting in a different search, but
114-
# given that this search is only performed when there's
115-
# an explicit rfc number, it seems more or less silly
116-
# to filter it further anyway.)
117-
in_tracker=[i['draft'] for i in IDInternal.objects.filter(rfc_flag=1).values('draft')]
118-
qdict = {
119-
'search_group_acronym': 'group_acronym',
120-
'search_rfcnumber': 'rfc_number',
121-
'search_status_id': 'status',
122-
}
123-
q_objs = [Q(**{qdict[k]: args[k]}) for k in qdict.keys() if args.get(k, '') != '']
124-
rfcmatches = Rfc.objects.filter(*q_objs).exclude(rfc_number__in=in_tracker)
125-
matches = list(matches) + [DocumentWrapper(rfc) for rfc in rfcmatches]
126-
else:
127-
matches = None
128-
129-
return render_to_response('idtracker/idtracker_search.html', {
130-
'form': form,
131-
'matches': matches,
132-
'searching': searching,
133-
'spacing': True
134-
}, context_instance=RequestContext(request))
135-
13611
def state_desc(request, state, is_substate=0):
13712
if int(state) == 100:
13813
object = {
@@ -151,15 +26,6 @@ def state_desc(request, state, is_substate=0):
15126
return render_to_response('idtracker/state_desc.html', {'state': object},
15227
context_instance=RequestContext(request))
15328

154-
def comment(request, slug, object_id, queryset):
155-
rfcnum = re.match(r'^rfc(\d+)$', slug)
156-
if rfcnum:
157-
queryset = queryset.filter(document=rfcnum.groups()[0])
158-
else:
159-
draft = get_object_or_404(InternetDraft, filename=slug)
160-
queryset = queryset.filter(document=draft.id_document_tag)
161-
return object_detail(request, queryset=queryset, object_id=object_id)
162-
16329
def status(request):
16430
queryset = IDInternal.objects.filter(primary_flag=1).exclude(cur_state__state__in=('RFC Ed Queue', 'RFC Published', 'AD is watching', 'Dead')).order_by('cur_state', 'status_date', 'ballot')
16531
return object_list(request, template_name="idtracker/status_of_items.html", queryset=queryset, extra_context={'title': 'IESG Status of Items'})
@@ -173,36 +39,25 @@ def redirect_id(request, object_id):
17339
doc = get_object_or_404(InternetDraft, id_document_tag=object_id)
17440
return HttpResponsePermanentRedirect("/doc/"+doc.filename+"/")
17541

176-
# calling sequence similar to object_detail, but we have different
177-
# 404 handling: if the draft exists, render a not-found template.
178-
def view_id(request, queryset, slug, slug_field):
179-
try:
180-
object = IDInternal.objects.get(draft__filename=slug, rfc_flag=0)
181-
except IDInternal.DoesNotExist:
182-
draft = get_object_or_404(InternetDraft, filename=slug)
183-
return HttpResponsePermanentRedirect("/doc/"+draft.filename+"/")
184-
return render_to_response('idtracker/idinternal_detail.html', {'object': object, 'spacing': False}, context_instance=RequestContext(request))
42+
def redirect_rfc(request, rfc_number):
43+
return HttpResponsePermanentRedirect("/doc/rfc"+rfc_number+"/")
18544

186-
def view_rfc(request, object_id):
187-
'''A replacement for the object_detail generic view for this
188-
specific case to work around the following problem:
189-
The object_detail generic view looks up the value of the
190-
primary key in order to hand it to populate_xheaders.
191-
In the IDInternal table, the primary key is a foreign key
192-
to InternetDraft. object_detail assumes that the PK is not
193-
an FK so doesn't do the foo_id trick, so the lookup is
194-
attempted and an exception raised if there is no match.
195-
This view gets the appropriate row from IDInternal and
196-
calls the template with the necessary context.'''
197-
object = get_object_or_404(IDInternal, pk=object_id, rfc_flag=1)
198-
return render_to_response('idtracker/idinternal_detail.html', {'object': object, 'spacing': False}, context_instance=RequestContext(request))
45+
def redirect_filename(request, filename):
46+
return HttpResponsePermanentRedirect("/doc/"+filename+"/")
19947

200-
# Wrappers around object_detail to give permalink a handle.
201-
# The named-URLs feature in django 0.97 will eliminate the
202-
# need for these.
203-
def view_comment(*args, **kwargs):
204-
return object_detail(*args, **kwargs)
48+
def redirect_ballot(request, object_id):
49+
ballot = get_object_or_404(BallotInfo, pk=object_id)
50+
id = ballot.drafts.filter(primary_flag=1)[0]
51+
if id.rfc_flag:
52+
return HttpResponsePermanentRedirect("/doc/rfc"+str(id.draft_id)+"/#ballot")
53+
else:
54+
return HttpResponsePermanentRedirect("/doc/"+id.draft.filename+"/#ballot")
20555

206-
def view_ballot(*args, **kwargs):
207-
return object_detail(*args, **kwargs)
56+
def redirect_comment(request, object_id):
57+
comment = get_object_or_404(DocumentComment, pk=object_id)
58+
id = comment.document
59+
if id.rfc_flag:
60+
return HttpResponsePermanentRedirect("/doc/rfc"+str(id.draft_id)+"/#history-"+str(object_id))
61+
else:
62+
return HttpResponsePermanentRedirect("/doc/"+id.draft.filename+"/#history-"+str(object_id))
20863

ietf/templates/idtracker/ballotinfo_detail.html

Lines changed: 0 additions & 53 deletions
This file was deleted.

0 commit comments

Comments
 (0)