IPR Form stuff:
* Added validation code for RFCs and Drafts. * Some stylesheet tweaks. - Legacy-Id: 144
This commit is contained in:
parent
d7b47093a7
commit
255e2e5a1a
|
@ -6,6 +6,7 @@ import django.newforms as forms
|
||||||
from django.shortcuts import render_to_response as render
|
from django.shortcuts import render_to_response as render
|
||||||
from ietf.utils import log
|
from ietf.utils import log
|
||||||
from ietf.ipr.view_sections import section_table
|
from ietf.ipr.view_sections import section_table
|
||||||
|
from ietf.idtracker.models import Rfc, InternetDraft
|
||||||
|
|
||||||
# ----------------------------------------------------------------
|
# ----------------------------------------------------------------
|
||||||
# Callback methods for special field cases.
|
# Callback methods for special field cases.
|
||||||
|
@ -111,11 +112,48 @@ def new(request, type):
|
||||||
|
|
||||||
BaseIprForm.__init__(self, *args, **kw)
|
BaseIprForm.__init__(self, *args, **kw)
|
||||||
# Special validation code
|
# Special validation code
|
||||||
def clean(self):
|
def clean_rfclist(self):
|
||||||
# Required:
|
rfclist = self.clean_data.get("rfclist", None)
|
||||||
# Submitter form filled in or 'same-as-ietf-contact' marked
|
if rfclist:
|
||||||
# Only one of rfc, draft, and other info fields filled in
|
rfclist = re.sub("(?i) *[,;]? *rfc[- ]?", " ", rfclist)
|
||||||
# RFC exists or draft exists and has right rev. or ...
|
rfclist = rfclist.strip().split()
|
||||||
|
for rfc in rfclist:
|
||||||
|
try:
|
||||||
|
Rfc.objects.get(rfc_number=int(rfc))
|
||||||
|
except:
|
||||||
|
raise forms.ValidationError("Unknown RFC number: %s - please correct this." % rfc)
|
||||||
|
rfclist = " ".join(rfclist)
|
||||||
|
else:
|
||||||
|
# Check that not all three fields are empty. We only need to
|
||||||
|
# do this for one of the fields.
|
||||||
|
draftlist = self.clean_data.get("draftlist", None)
|
||||||
|
other = self.clean_data.get("other_designations", None)
|
||||||
|
if not draftlist and not other:
|
||||||
|
raise forms.ValidationError("One of the Document fields below must be filled in")
|
||||||
|
return rfclist
|
||||||
|
def clean_draftlist(self):
|
||||||
|
draftlist = self.clean_data.get("draftlist", None)
|
||||||
|
if draftlist:
|
||||||
|
draftlist = re.sub(" *[,;] *", " ", draftlist)
|
||||||
|
draftlist = draftlist.strip().split()
|
||||||
|
for draft in draftlist:
|
||||||
|
if draft.endswith(".txt"):
|
||||||
|
draft = draft[:-4]
|
||||||
|
if re.search("-[0-9][0-9]$", draft):
|
||||||
|
filename = draft[:-3]
|
||||||
|
rev = draft[-2:]
|
||||||
|
else:
|
||||||
|
filename = draft
|
||||||
|
rev = None
|
||||||
|
#log("ID: %s, rev %s" % (filename, rev))
|
||||||
|
try:
|
||||||
|
id = InternetDraft.objects.get(filename=filename)
|
||||||
|
#log("ID Lookup result: %s, %s" % (id.filename, id.revision))
|
||||||
|
except Exception, e:
|
||||||
|
log("Exception: %s" % e)
|
||||||
|
raise forms.ValidationError("Unknown Internet-Draft: %s - please correct this." % filename)
|
||||||
|
if rev and id.revision != rev:
|
||||||
|
raise forms.ValidationError("Unexpected revision '%s' for draft %s - the current revision is %s. Please check this." % (rev, filename, id.revision))
|
||||||
pass
|
pass
|
||||||
|
|
||||||
if request.method == 'POST':
|
if request.method == 'POST':
|
||||||
|
|
|
@ -29,7 +29,8 @@
|
||||||
input[type="submit"] { width: auto; }
|
input[type="submit"] { width: auto; }
|
||||||
textarea { width: 68ex; height: 5em; font-family: sans-serif; font-size: 11pt; font-weight: normal; }
|
textarea { width: 68ex; height: 5em; font-family: sans-serif; font-size: 11pt; font-weight: normal; }
|
||||||
.required { color: red; float: right; padding-top: 0.7ex; font-size: 130%; }
|
.required { color: red; float: right; padding-top: 0.7ex; font-size: 130%; }
|
||||||
.errorlist { background: red; padding: 0 0 0 0.2ex; border: 0px; margin: 0px; }
|
.errorlist { background: red; color: white; padding: 0.2ex 0.2ex 0.2ex 0.5ex; border: 0px; margin: 0px; font-family: Arial, sans-serif; }
|
||||||
|
ul.errorlist { margin: 0px; }
|
||||||
.formlegend { }
|
.formlegend { }
|
||||||
.formlegend .required { float: none; vertical-align: -0.5ex; padding: 0; }
|
.formlegend .required { float: none; vertical-align: -0.5ex; padding: 0; }
|
||||||
/* baseline | sub | super | top | text-top | middle | bottom | text-bottom | <length> | <percentage> */
|
/* baseline | sub | super | top | text-top | middle | bottom | text-bottom | <length> | <percentage> */
|
||||||
|
|
Loading…
Reference in a new issue