Skip to content

Commit cccf7a9

Browse files
committed
* Skip 'ipr' and 'contact_type' fields in BaseContactForm
* Move update() to new.py * Get the update submitter in update() and overwrite the ipr submitter with it when updating. * Remove ? from trailing slash in about - the addslashes middleware will get there first anyway, and the ? confuses reverse() - Legacy-Id: 705
1 parent 06680fb commit cccf7a9

4 files changed

Lines changed: 90 additions & 15 deletions

File tree

ietf/ipr/new.py

Lines changed: 43 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ def ipr_contact_form_callback(field, **kwargs):
3232
numbers [0-9]; dash, period or space; parentheses, and an optional
3333
extension number indicated by 'x'. """
3434

35+
if field.name in ['ipr', 'contact_type']:
36+
return None
3537
if field.name == "telephone":
3638
return forms.RegexField(phone_re, error_message=error_message, **kwargs)
3739
if field.name == "fax":
@@ -76,7 +78,7 @@ def clean(self, *value):
7678
# Form processing
7779
# ----------------------------------------------------------------
7880

79-
def new(request, type, update=None):
81+
def new(request, type, update=None, submitter=None):
8082
"""Make a new IPR disclosure.
8183
8284
This is a big function -- maybe too big. Things would be easier if we didn't have
@@ -108,6 +110,8 @@ def __init__(self, *args, **kw):
108110
if update:
109111
for contact in update.contact.all():
110112
contact_initial[contact_type[contact.contact_type]] = contact.__dict__
113+
if submitter:
114+
contact_initial["submitter"] = submitter
111115
kwnoinit = kw.copy()
112116
kwnoinit.pop('initial', None)
113117
for contact in ["holder_contact", "ietf_contact", "submitter"]:
@@ -191,7 +195,11 @@ def clean_licensing_option(self):
191195
return licensing_option
192196

193197

194-
if request.method == 'POST':
198+
# If we're POSTed, but we got passed a submitter, it was the
199+
# POST of the "get updater" form, so we don't want to validate
200+
# this one. When we're posting *this* form, submitter is None,
201+
# even when updating.
202+
if request.method == 'POST' and not submitter:
195203
data = request.POST.copy()
196204
data["submitted_date"] = datetime.now().strftime("%Y-%m-%d")
197205
data["third_party"] = section_list["third_party"]
@@ -298,6 +306,39 @@ def clean_licensing_option(self):
298306
# ietf.utils.log(dir(form.ietf_contact_is_submitter))
299307
return render("ipr/details.html", {"ipr": form, "section_list":section_list, "debug": debug}, context_instance=RequestContext(request))
300308

309+
def update(request, ipr_id=None):
310+
"""Update a specific IPR disclosure"""
311+
# We're either asking for initial permission or we're in
312+
# the general ipr form. If the POST argument has the first
313+
# field of the ipr form, then we must be dealing with that,
314+
# so just pass through - otherwise, collect the updater's
315+
# info first.
316+
submitter = None
317+
if not(request.POST.has_key('legal_name')):
318+
class UpdateForm(BaseContactForm):
319+
def __init__(self, *args, **kwargs):
320+
self.base_fields["update_auth"] = forms.BooleanField("I am authorized to update this IPR disclosure, and I understand that notification of this update will be provided to the submitter of the original IPR disclosure and to the Patent Holder's Contact.")
321+
super(UpdateForm, self).__init__(*args, **kwargs)
322+
if request.method == 'POST':
323+
form = UpdateForm(request.POST)
324+
else:
325+
form = UpdateForm()
326+
327+
if not(form.is_valid()):
328+
for error in form.errors:
329+
log("Form error for field: %s: %s"%(error, form.errors[error]))
330+
return render("ipr/update.html", {"form": form}, context_instance=RequestContext(request))
331+
else:
332+
submitter = form.clean_data
333+
334+
ipr = models.IprDetail.objects.get(ipr_id=ipr_id)
335+
type = "specific"
336+
if ipr.generic:
337+
type = "generic"
338+
if ipr.third_party:
339+
type = "third-party"
340+
return new(request, type, ipr, submitter)
341+
301342

302343
def get_ipr_summary(data):
303344

ietf/ipr/urls.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33

44
urlpatterns = patterns('',
55
(r'^$', views.showlist),
6-
(r'^about/?$', views.default),
6+
(r'^about/$', views.default),
77
(r'^ipr-(?P<ipr_id>\d+)/$', views.show),
88
(r'^update/$', views.updatelist),
9-
(r'^update/(?P<ipr_id>\d+)/$', views.update),
9+
(r'^update/(?P<ipr_id>\d+)/$', new.update),
1010
(r'^new-(?P<type>(specific|generic|third-party))/$', new.new),
1111
(r'^search/$', search.search),
1212
)

ietf/ipr/views.py

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
from ietf.idtracker.models import IETFWG
66
from ietf.ipr.models import IprDetail, SELECT_CHOICES, LICENSE_CHOICES
77
from ietf.ipr.view_sections import section_table
8-
from ietf.ipr.new import new
98
from ietf.utils import log
109

1110
def linebreaks(value):
@@ -79,16 +78,6 @@ def show(request, ipr_id=None):
7978
return render("ipr/details.html", {"ipr": ipr, "section_list": section_list},
8079
context_instance=RequestContext(request))
8180

82-
def update(request, ipr_id=None):
83-
"""Update a specific IPR disclosure"""
84-
ipr = IprDetail.objects.get(ipr_id=ipr_id)
85-
type = "specific"
86-
if ipr.generic:
87-
type = "generic"
88-
if ipr.third_party:
89-
type = "third-party"
90-
return new(request, type, ipr)
91-
9281

9382

9483
def form(request):

ietf/templates/ipr/update.html

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
{% extends "base.html" %}
2+
{% block title %}IPR Update{% endblock %}
3+
{% block content %}
4+
5+
{% include "ipr/style.html" %}
6+
7+
<form name="form1" method="post">
8+
{% if form.errors %}
9+
<p class="errorlist">
10+
There were errors in the submitted form -- see below. Please correct these and resubmit.
11+
{% if form.non_field_errors %}
12+
<ul class="errorlist">
13+
{% for error in form.non_field_errors %}
14+
<li>{{ error }}</li>
15+
{% endfor %}
16+
</ul>
17+
{% endif %}
18+
</p>
19+
{% endif %}
20+
21+
<blockquote class="odd">
22+
<table border="0" cellpadding="0" cellspacing="0" class="ipr person">
23+
<tr class="{% cycle dark,light as row_parity %}"><th colspan="2" >
24+
Contact Information for Submitter of this Update.
25+
</th>
26+
</tr>
27+
<tr class="{% cycle row_parity %}"><td class="fixwidth">Name:</td> <td><b>{{ form.name }}</b></td></tr>
28+
<tr class="{% cycle row_parity %}"><td class="fixwidth">Title:</td> <td><b>{{ form.title }}</b></td></tr>
29+
<tr class="{% cycle row_parity %}"><td class="fixwidth">Department:</td> <td><b>{{ form.department }}</b></td></tr>
30+
<tr class="{% cycle row_parity %}"><td class="fixwidth">Address1:</td> <td><b>{{ form.address1 }}</b></td></tr>
31+
<tr class="{% cycle row_parity %}"><td class="fixwidth">Address2:</td> <td><b>{{ form.address2 }}</b></td></tr>
32+
<tr class="{% cycle row_parity %}"><td class="fixwidth">Telephone:</td> <td><b>{{ form.telephone }}</b></td></tr>
33+
<tr class="{% cycle row_parity %}"><td class="fixwidth">Fax:</td> <td><b>{{ form.fax }}</b></td></tr>
34+
<tr class="{% cycle row_parity %}"><td class="fixwidth">Email:</td> <td><b>{{ form.email }}</b></td></tr>
35+
</table>
36+
</blockquote>
37+
<p>
38+
{{ form.update_auth }}
39+
<b>I am authorized to update this IPR disclosure, and I understand that notification of this update will be provided to the submitter of the original IPR disclosure and to the Patent Holder's Contact.</b>
40+
</p>
41+
<input type="submit" name="submit" value="Submit">
42+
&nbsp; <input type="button" value="Cancel" onClick="history.go(-1);return true;"><br>
43+
</form>
44+
45+
{% endblock %}

0 commit comments

Comments
 (0)