11import re
22import models
33import ietf .utils
4+ import django .utils .html
45import django .newforms as forms
56from django .shortcuts import render_to_response as render
6- from django .utils .html import escape , linebreaks
7+ from django .utils .html import escape
78from ietf .contrib .form_decorator import form_decorator
89from ietf .utils import log as log
910
11+ def linebreaks (value ):
12+ if value :
13+ return django .utils .html .linebreaks (value )
14+ else :
15+ return value
16+
1017def default (request ):
1118 """Default page, with links to sub-pages"""
1219 return render ("ipr/disclosure.html" , {})
@@ -37,25 +44,25 @@ def list(request, template):
3744
3845section_table = {
3946 "index" : { "index" : True },
40- "specific" : { "index" : False , "title" : True ,
47+ "specific" : { "index" : False , "title" : True , "specific" : True ,
4148 "legacy_intro" : False , "new_intro" : True , "form_intro" : False ,
4249 "holder" : True , "holder_contact" : True , "ietf_contact" : True ,
4350 "ietf_doc" : True , "patent_info" : True , "licensing" : True ,
4451 "submitter" : True , "notes" : True , "form_submit" : False ,
4552 },
46- "generic" : { "index" : False , "title" : True ,
53+ "generic" : { "index" : False , "title" : True , "generic" : True ,
4754 "legacy_intro" : False , "new_intro" : True , "form_intro" : False ,
4855 "holder" : True , "holder_contact" : True , "ietf_contact" : False ,
4956 "ietf_doc" : False , "patent_info" : True , "licensing" : True ,
5057 "submitter" : True , "notes" : True , "form_submit" : False ,
5158 },
52- "third_party" : {"index" : False , "title" : True ,
59+ "third_party" : {"index" : False , "title" : True , "third_party" : True ,
5360 "legacy_intro" : False , "new_intro" : True , "form_intro" : False ,
5461 "holder" : True , "holder_contact" : False , "ietf_contact" : True ,
5562 "ietf_doc" : True , "patent_info" : True , "licensing" : False ,
5663 "submitter" : False , "notes" : False , "form_submit" : False ,
5764 },
58- "legacy" : { "index" : False , "title" : True ,
65+ "legacy" : { "index" : False , "title" : True , "legacy" : True ,
5966 "legacy_intro" : True , "new_intro" : False , "form_intro" : False ,
6067 "holder" : True , "holder_contact" : True , "ietf_contact" : False ,
6168 "ietf_doc" : True , "patent_info" : False , "licensing" : False ,
@@ -85,8 +92,10 @@ def show(request, ipr_id=None):
8592 ipr .discloser_identify = linebreaks (escape (ipr .discloser_identify ))
8693 ipr .comments = linebreaks (escape (ipr .comments ))
8794 ipr .other_notes = linebreaks (escape (ipr .other_notes ))
95+
8896 ipr .licensing_option = dict (models .LICENSE_CHOICES )[ipr .licensing_option ]
8997 ipr .selecttype = dict (models .SELECT_CHOICES )[ipr .selecttype ]
98+
9099 if ipr .selectowned :
91100 ipr .selectowned = dict (models .SELECT_CHOICES )[ipr .selectowned ]
92101 return render ("ipr/details.html" , {"ipr" : ipr , "section_list" : section_list })
@@ -103,9 +112,9 @@ def new(request, type):
103112 # define callback methods for special field cases.
104113 def ipr_detail_form_callback (field , ** kwargs ):
105114 if field .name == "licensing_option" :
106- return forms .IntegerField (widget = forms .RadioSelect (choices = models .LICENSE_CHOICES ))
115+ return forms .IntegerField (widget = forms .RadioSelect (choices = models .LICENSE_CHOICES ), required = False )
107116 if field .name in ["selecttype" , "selectowned" ]:
108- return forms .IntegerField (widget = forms .RadioSelect (choices = ((1 , "YES" ), (2 , "NO" ))))
117+ return forms .IntegerField (widget = forms .RadioSelect (choices = ((1 , "YES" ), (2 , "NO" ))), required = False )
109118 return field .formfield (** kwargs )
110119
111120 def ipr_contact_form_callback (field , ** kwargs ):
@@ -181,21 +190,22 @@ def clean(self):
181190 data = request .POST .copy ()
182191 if "ietf_contact_is_submitter" in data :
183192 for subfield in ["name" , "title" , "department" , "address1" , "address2" , "telephone" , "fax" , "email" ]:
184- log ("Fixing subfield subm_%s ..." % subfield )
185193 try :
186194 data ["subm_%s" % subfield ] = data ["ietf_%s" % subfield ]
187- log ("Set to %s" % data ["ietf_%s" % subfield ])
188195 except Exception , e :
189- log ("Caught exception: %s" % e )
196+ # log("Caught exception: %s"%e)
190197 pass
191198 form = IprForm (data )
192199 if form .ietf_contact_is_submitter :
193200 form .ietf_contact_is_submitter_checked = "checked"
194201 if form .is_valid ():
195202 #instance = form.save()
196203 #return HttpResponseRedirect("/ipr/ipr-%s" % instance.ipr_id)
197- return HttpResponseRedirect ("/ipr/" )
204+ #return HttpResponseRedirect("/ipr/")
205+ pass
198206 else :
207+ for error in form .errors :
208+ log ("Form error: %s" % error )
199209 # Fall through, and let the partially bound form, with error
200210 # indications, be rendered again.
201211 pass
0 commit comments