Skip to content

Commit fb5013e

Browse files
committed
IPR disclosure form submission now works.
Closing the ipr_generic.cgi ticket, but leaving ipr.cgi and notify.cgi open till further testing has been done. Also adding a new task for the IPR update form. There may still be some dead code to clean out, but I'm committing what I have now since it provides working form submission :-) - Legacy-Id: 158
1 parent 2d3bbed commit fb5013e

5 files changed

Lines changed: 133 additions & 42 deletions

File tree

ietf/ipr/models.py

Lines changed: 24 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -79,11 +79,11 @@ class IprDetail(models.Model):
7979

8080
# Patent Information fieldset
8181
p_applications = models.TextField("Patent Applications", maxlength=255)
82-
date_applied = models.DateField(maxlength=255)
82+
date_applied = models.CharField(maxlength=255)
8383
country = models.CharField(maxlength=100)
8484
p_notes = models.TextField("Additional notes", blank=True)
85-
selecttype = models.IntegerField("Unpublished Pending Patent Application", null=True, choices=SELECT_CHOICES)
86-
selectowned = models.IntegerField("Applies to all IPR owned by Submitter", null=True, blank=True, choices=SELECT_CHOICES)
85+
selecttype = models.IntegerField("Unpublished Pending Patent Application", blank=True, choices=SELECT_CHOICES)
86+
selectowned = models.IntegerField("Applies to all IPR owned by Submitter", blank=True, choices=SELECT_CHOICES)
8787

8888
# Licensing Declaration fieldset
8989
#licensing_option = models.ForeignKey(IprLicensing, db_column='licensing_option')
@@ -94,16 +94,18 @@ class IprDetail(models.Model):
9494
comments = models.TextField("Licensing Comments", blank=True)
9595
lic_checkbox = models.BooleanField("All terms and conditions has been disclosed")
9696

97-
third_party = models.BooleanField(editable=False)
9897

9998
# Other notes fieldset
10099
other_notes = models.TextField(blank=True)
101100

102101
# Generated fields, not part of the submission form
102+
# Hidden fields
103+
third_party = models.BooleanField()
104+
generic = models.BooleanField()
105+
comply = models.BooleanField()
106+
103107
status = models.IntegerField(null=True, blank=True)
104-
comply = models.BooleanField(editable=False)
105-
generic = models.BooleanField(editable=False)
106-
submitted_date = models.DateField(null=True, blank=True)
108+
submitted_date = models.DateField(blank=True)
107109
update_notified_date = models.DateField(null=True, blank=True)
108110

109111
def __str__(self):
@@ -118,21 +120,21 @@ def selectownedtext(self):
118120
return "YES"
119121
else:
120122
return "NO"
121-
def get_patent_holder_contact(self):
122-
try:
123-
return self.contact.filter(contact_type=1)[0]
124-
except:
125-
return None
126-
def get_ietf_contact(self):
127-
try:
128-
return self.contact.filter(contact_type=2)[0]
129-
except:
130-
return None
131-
def get_submitter(self):
132-
try:
133-
return self.contact.filter(contact_type=3)[0]
134-
except:
135-
return None
123+
# def get_patent_holder_contact(self):
124+
# try:
125+
# return self.contact.filter(contact_type=1)[0]
126+
# except:
127+
# return None
128+
# def get_ietf_contact(self):
129+
# try:
130+
# return self.contact.filter(contact_type=2)[0]
131+
# except:
132+
# return None
133+
# def get_submitter(self):
134+
# try:
135+
# return self.contact.filter(contact_type=3)[0]
136+
# except:
137+
# return None
136138
def get_absolute_url(self):
137139
return "/ipr/ipr-%s" % self.ipr_id
138140
class Meta:

ietf/ipr/view_new.py

Lines changed: 91 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,13 @@
33
import ietf.utils
44
import django.utils.html
55
import django.newforms as forms
6+
7+
from datetime import datetime
68
from django.shortcuts import render_to_response as render
79
from ietf.utils import log
810
from ietf.ipr.view_sections import section_table
911
from ietf.idtracker.models import Rfc, InternetDraft
12+
from django.http import HttpResponseRedirect
1013

1114
# ----------------------------------------------------------------
1215
# Callback methods for special field cases.
@@ -20,6 +23,8 @@ def ipr_detail_form_callback(field, **kwargs):
2023
if field.name in ["rfc_number", "id_document_tag"]:
2124
log(field.name)
2225
return forms.CharFieldField(required=False)
26+
if field.name in ["date_applied"]:
27+
return forms.DateField()
2328
return field.formfield(**kwargs)
2429

2530
def ipr_contact_form_callback(field, **kwargs):
@@ -136,6 +141,7 @@ def clean_draftlist(self):
136141
if draftlist:
137142
draftlist = re.sub(" *[,;] *", " ", draftlist)
138143
draftlist = draftlist.strip().split()
144+
drafts = []
139145
for draft in draftlist:
140146
if draft.endswith(".txt"):
141147
draft = draft[:-4]
@@ -145,19 +151,41 @@ def clean_draftlist(self):
145151
else:
146152
filename = draft
147153
rev = None
148-
#log("ID: %s, rev %s" % (filename, rev))
149154
try:
150155
id = InternetDraft.objects.get(filename=filename)
151-
#log("ID Lookup result: %s, %s" % (id.filename, id.revision))
152156
except Exception, e:
153157
log("Exception: %s" % e)
154158
raise forms.ValidationError("Unknown Internet-Draft: %s - please correct this." % filename)
155159
if rev and id.revision != rev:
156160
raise forms.ValidationError("Unexpected revision '%s' for draft %s - the current revision is %s. Please check this." % (rev, filename, id.revision))
157-
pass
161+
drafts.append("%s-%s" % (filename, id.revision))
162+
return " ".join(drafts)
163+
return ""
164+
def clean_holder_contact(self):
165+
return self.holder_contact.full_clean()
166+
def clean_ietf_contact(self):
167+
return self.ietf_contact.full_clean()
168+
def clean_submitter(self):
169+
return self.submitter.full_clean()
170+
158171

159172
if request.method == 'POST':
160173
data = request.POST.copy()
174+
data["submitted_date"] = datetime.now().strftime("%Y-%m-%d")
175+
data["third_party"] = section_list["third_party"]
176+
data["generic"] = section_list["generic"]
177+
data["status"] = "0"
178+
data["comply"] = "1"
179+
180+
if type == "general":
181+
data["document_title"] = """%(p_h_legal_name)s's General License Statement""" % data
182+
if type == "specific":
183+
data["ipr_summary"] = get_ipr_summary(data)
184+
data["document_title"] = """%(p_h_legal_name)s's Statement about IPR related to %(ipr_summary)s""" % data
185+
if type == "third-party":
186+
data["ipr_summary"] = get_ipr_summary(data)
187+
data["document_title"] = """%(submitter)s's Statement about IPR related to %(ipr_summary)s belonging to %(p_h_legal_name)s""" % data
188+
161189
for src in ["hold", "ietf"]:
162190
if "%s_contact_is_submitter" % src in data:
163191
for subfield in ["name", "title", "department", "address1", "address2", "telephone", "fax", "email"]:
@@ -167,15 +195,53 @@ def clean_draftlist(self):
167195
#log("Caught exception: %s"%e)
168196
pass
169197
form = IprForm(data)
170-
if form.ietf_contact_is_submitter:
171-
form.ietf_contact_is_submitter_checked = "checked"
172198
if form.is_valid():
173-
#instance = form.save()
174-
#return HttpResponseRedirect("/ipr/ipr-%s" % instance.ipr_id)
199+
# Save data :
200+
# IprDetail, IprContact+, IprDraft+, IprRfc+, IprNotification
201+
202+
# Save IprDetail
203+
instance = form.save()
204+
contact_type = {"hold":1, "ietf":2, "subm": 3}
205+
206+
# Save IprContact(s)
207+
for prefix in ["hold", "ietf", "subm"]:
208+
# cdata = {"ipr": instance.ipr_id, "contact_type":contact_type[prefix]}
209+
cdata = {"ipr": instance, "contact_type":contact_type[prefix]}
210+
for item in data:
211+
if item.startswith(prefix+"_"):
212+
cdata[item[5:]] = data[item]
213+
try:
214+
del cdata["contact_is_submitter"]
215+
except KeyError:
216+
pass
217+
contact = models.IprContact(**cdata)
218+
contact.save()
219+
# contact = ContactForm(cdata)
220+
# if contact.is_valid():
221+
# contact.save()
222+
# else:
223+
# log("Invalid contact: %s" % contact)
224+
225+
# Save IprDraft(s)
226+
for draft in form.clean_data["draftlist"].split():
227+
id = InternetDraft.objects.get(filename=draft[:-3])
228+
iprdraft = models.IprDraft(document=id, ipr=instance, revision=draft[-2:])
229+
iprdraft.save()
230+
231+
# Save IprRfc(s)
232+
for rfcnum in form.clean_data["rfclist"].split():
233+
rfc = Rfc.objects.get(rfc_number=int(rfcnum))
234+
iprrfc = models.IprRfc(rfc_number=rfc, ipr=instance)
235+
iprrfc.save()
236+
237+
return HttpResponseRedirect("/ipr/ipr-%s" % instance.ipr_id)
175238
#return HttpResponseRedirect("/ipr/")
176239

177240
pass
178241
else:
242+
if form.ietf_contact_is_submitter:
243+
form.ietf_contact_is_submitter_checked = "checked"
244+
179245
for error in form.errors:
180246
log("Form error for field: %s"%error)
181247
# Fall through, and let the partially bound form, with error
@@ -187,3 +253,21 @@ def clean_draftlist(self):
187253

188254
# ietf.utils.log(dir(form.ietf_contact_is_submitter))
189255
return render("ipr/details.html", {"ipr": form, "section_list":section_list, "debug": debug})
256+
257+
258+
def get_ipr_summary(data):
259+
260+
rfc_ipr = [ "RFC %s" % item for item in data["rfclist"].split() ]
261+
draft_ipr = data["draftlist"].split()
262+
ipr = rfc_ipr + draft_ipr
263+
if data["other_designations"]:
264+
ipr += [ data["other_designations"] ]
265+
266+
if len(ipr) == 1:
267+
ipr = ipr[0]
268+
elif len(ipr) == 2:
269+
ipr = " and ".join(ipr)
270+
else:
271+
ipr = ", ".join(ipr[:-1] + ", and " + ipr[-1])
272+
273+
return ipr

ietf/ipr/view_sections.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,26 @@
11

22
section_table = {
33
"index": { "index": True },
4-
"specific": { "index": False, "title": True, "specific": True,
4+
"specific": { "index": False, "title": True,
5+
"specific": 1, "generic": 0, "third_party": 0,
56
"legacy_intro": False, "new_intro": True, "form_intro": False,
67
"holder": True, "holder_contact": True, "ietf_contact": True,
78
"ietf_doc": True, "patent_info": True, "licensing": True,
89
"submitter": True, "notes": True, "form_submit": False,
910
"disclosure_type": "Specific", "form_legend": False,
1011
"per_rfc_disclosure": True, "also_specific": False,
1112
},
12-
"generic": { "index": False, "title": True, "generic": True,
13+
"generic": { "index": False, "title": True,
14+
"specific": 0, "generic": 1, "third_party": 0,
1315
"legacy_intro": False, "new_intro": True, "form_intro": False,
1416
"holder": True, "holder_contact": True, "ietf_contact": False,
1517
"ietf_doc": False, "patent_info": True, "licensing": True,
1618
"submitter": True, "notes": True, "form_submit": False,
1719
"disclosure_type": "Generic", "form_legend": False,
1820
"per_rfc_disclosure": False, "also_specific": True,
1921
},
20-
"third-party": {"index": False, "title": True, "third_party": True,
22+
"third-party": {"index": False, "title": True,
23+
"specific": 0, "generic": 0, "third_party": 1,
2124
"legacy_intro": False, "new_intro": True, "form_intro": False,
2225
"holder": True, "holder_contact": False, "ietf_contact": True,
2326
"ietf_doc": True, "patent_info": True, "licensing": False,

ietf/ipr/views.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
from django.utils.html import escape
66
from ietf.ipr.view_new import new
77
from ietf.ipr.view_sections import section_table
8+
from ietf.utils import log
89

910
def linebreaks(value):
1011
if value:
@@ -54,17 +55,18 @@ def show(request, ipr_id=None):
5455
elif contact.contact_type == 3:
5556
ipr.submitter = contact
5657
else:
57-
raise KeyError("Unexpected contact_type in ipr_contacts: ipr_id=%s" % ipr.ipr_id)
58+
raise KeyError("Unexpected contact_type (%s) in ipr_contacts for ipr_id=%s" % (contact.contact_type, ipr.ipr_id))
5859
# do escaping and line-breaking here instead of in the template,
5960
# so that we can use the template for the form display, too.
6061
ipr.p_notes = linebreaks(escape(ipr.p_notes))
6162
ipr.discloser_identify = linebreaks(escape(ipr.discloser_identify))
6263
ipr.comments = linebreaks(escape(ipr.comments))
6364
ipr.other_notes = linebreaks(escape(ipr.other_notes))
6465

65-
ipr.licensing_option = dict(models.LICENSE_CHOICES)[ipr.licensing_option]
66-
ipr.selecttype = dict(models.SELECT_CHOICES)[ipr.selecttype]
67-
66+
if ipr.licensing_option:
67+
ipr.licensing_option = dict(models.LICENSE_CHOICES)[ipr.licensing_option]
68+
if ipr.selecttype:
69+
ipr.selecttype = dict(models.SELECT_CHOICES)[ipr.selecttype]
6870
if ipr.selectowned:
6971
ipr.selectowned = dict(models.SELECT_CHOICES)[ipr.selectowned]
7072
return render("ipr/details.html", {"ipr": ipr, "section_list": section_list})
@@ -82,9 +84,9 @@ def get_section_list(ipr):
8284
if ipr.old_ipr_url:
8385
return section_table["legacy"]
8486
elif ipr.generic:
85-
assert not ipr.third_party
87+
#assert not ipr.third_party
8688
return section_table["generic"]
8789
elif ipr.third_party:
88-
return section_table["third_party"]
90+
return section_table["third-party"]
8991
else:
9092
return section_table["specific"]

ietf/templates/ipr/details.html

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -359,10 +359,7 @@ <h4 class="ipr">The Patent Disclosure and Licensing Declaration Template for {{
359359
</tr>
360360
<tr>
361361
<td colspan="2">
362-
<b>{{ ipr.licensing_option }}
363-
{{ ipr.get_lic_opt_a_sub_display }}
364-
{{ ipr.get_lic_opt_b_sub_display }}
365-
{{ ipr.get_lic_opt_c_sub_display }}</b>
362+
<b>{{ ipr.licensing_option }}</b>
366363
</td>
367364
</tr>
368365
</tbody>
@@ -475,6 +472,9 @@ <h4 class="ipr">The Patent Disclosure and Licensing Declaration Template for {{
475472
{% endif %}
476473

477474
{% if section_list.form_submit %}
475+
<input type="hidden" name="third_party" value="{{ section_list.third_party }}">
476+
<input type="hidden" name="generic" value="{{ section_list.generic }}">
477+
<input type="hidden" name="comply" value="1">
478478
<center><input type="submit" name="submit" value="Submit"></center>
479479
</form>
480480
<blockquote>

0 commit comments

Comments
 (0)