Skip to content

Commit 255e2e5

Browse files
committed
IPR Form stuff:
* Added validation code for RFCs and Drafts. * Some stylesheet tweaks. - Legacy-Id: 144
1 parent d7b4709 commit 255e2e5

2 files changed

Lines changed: 45 additions & 6 deletions

File tree

ietf/ipr/view_new.py

Lines changed: 43 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
from django.shortcuts import render_to_response as render
77
from ietf.utils import log
88
from ietf.ipr.view_sections import section_table
9+
from ietf.idtracker.models import Rfc, InternetDraft
910

1011
# ----------------------------------------------------------------
1112
# Callback methods for special field cases.
@@ -111,11 +112,48 @@ def __init__(self, *args, **kw):
111112

112113
BaseIprForm.__init__(self, *args, **kw)
113114
# Special validation code
114-
def clean(self):
115-
# Required:
116-
# Submitter form filled in or 'same-as-ietf-contact' marked
117-
# Only one of rfc, draft, and other info fields filled in
118-
# RFC exists or draft exists and has right rev. or ...
115+
def clean_rfclist(self):
116+
rfclist = self.clean_data.get("rfclist", None)
117+
if rfclist:
118+
rfclist = re.sub("(?i) *[,;]? *rfc[- ]?", " ", rfclist)
119+
rfclist = rfclist.strip().split()
120+
for rfc in rfclist:
121+
try:
122+
Rfc.objects.get(rfc_number=int(rfc))
123+
except:
124+
raise forms.ValidationError("Unknown RFC number: %s - please correct this." % rfc)
125+
rfclist = " ".join(rfclist)
126+
else:
127+
# Check that not all three fields are empty. We only need to
128+
# do this for one of the fields.
129+
draftlist = self.clean_data.get("draftlist", None)
130+
other = self.clean_data.get("other_designations", None)
131+
if not draftlist and not other:
132+
raise forms.ValidationError("One of the Document fields below must be filled in")
133+
return rfclist
134+
def clean_draftlist(self):
135+
draftlist = self.clean_data.get("draftlist", None)
136+
if draftlist:
137+
draftlist = re.sub(" *[,;] *", " ", draftlist)
138+
draftlist = draftlist.strip().split()
139+
for draft in draftlist:
140+
if draft.endswith(".txt"):
141+
draft = draft[:-4]
142+
if re.search("-[0-9][0-9]$", draft):
143+
filename = draft[:-3]
144+
rev = draft[-2:]
145+
else:
146+
filename = draft
147+
rev = None
148+
#log("ID: %s, rev %s" % (filename, rev))
149+
try:
150+
id = InternetDraft.objects.get(filename=filename)
151+
#log("ID Lookup result: %s, %s" % (id.filename, id.revision))
152+
except Exception, e:
153+
log("Exception: %s" % e)
154+
raise forms.ValidationError("Unknown Internet-Draft: %s - please correct this." % filename)
155+
if rev and id.revision != rev:
156+
raise forms.ValidationError("Unexpected revision '%s' for draft %s - the current revision is %s. Please check this." % (rev, filename, id.revision))
119157
pass
120158

121159
if request.method == 'POST':

ietf/templates/ipr/style.html

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@
2929
input[type="submit"] { width: auto; }
3030
textarea { width: 68ex; height: 5em; font-family: sans-serif; font-size: 11pt; font-weight: normal; }
3131
.required { color: red; float: right; padding-top: 0.7ex; font-size: 130%; }
32-
.errorlist { background: red; padding: 0 0 0 0.2ex; border: 0px; margin: 0px; }
32+
.errorlist { background: red; color: white; padding: 0.2ex 0.2ex 0.2ex 0.5ex; border: 0px; margin: 0px; font-family: Arial, sans-serif; }
33+
ul.errorlist { margin: 0px; }
3334
.formlegend { }
3435
.formlegend .required { float: none; vertical-align: -0.5ex; padding: 0; }
3536
/* baseline | sub | super | top | text-top | middle | bottom | text-bottom | <length> | <percentage> */

0 commit comments

Comments
 (0)