* 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
This commit is contained in:
Bill Fenner 2007-06-27 17:11:38 +00:00
parent 06680fba8c
commit cccf7a9ca4
4 changed files with 90 additions and 15 deletions

View file

@ -32,6 +32,8 @@ def ipr_contact_form_callback(field, **kwargs):
numbers [0-9]; dash, period or space; parentheses, and an optional
extension number indicated by 'x'. """
if field.name in ['ipr', 'contact_type']:
return None
if field.name == "telephone":
return forms.RegexField(phone_re, error_message=error_message, **kwargs)
if field.name == "fax":
@ -76,7 +78,7 @@ class ContactForm(BaseContactForm):
# Form processing
# ----------------------------------------------------------------
def new(request, type, update=None):
def new(request, type, update=None, submitter=None):
"""Make a new IPR disclosure.
This is a big function -- maybe too big. Things would be easier if we didn't have
@ -108,6 +110,8 @@ def new(request, type, update=None):
if update:
for contact in update.contact.all():
contact_initial[contact_type[contact.contact_type]] = contact.__dict__
if submitter:
contact_initial["submitter"] = submitter
kwnoinit = kw.copy()
kwnoinit.pop('initial', None)
for contact in ["holder_contact", "ietf_contact", "submitter"]:
@ -191,7 +195,11 @@ def new(request, type, update=None):
return licensing_option
if request.method == 'POST':
# If we're POSTed, but we got passed a submitter, it was the
# POST of the "get updater" form, so we don't want to validate
# this one. When we're posting *this* form, submitter is None,
# even when updating.
if request.method == 'POST' and not submitter:
data = request.POST.copy()
data["submitted_date"] = datetime.now().strftime("%Y-%m-%d")
data["third_party"] = section_list["third_party"]
@ -298,6 +306,39 @@ def new(request, type, update=None):
# ietf.utils.log(dir(form.ietf_contact_is_submitter))
return render("ipr/details.html", {"ipr": form, "section_list":section_list, "debug": debug}, context_instance=RequestContext(request))
def update(request, ipr_id=None):
"""Update a specific IPR disclosure"""
# We're either asking for initial permission or we're in
# the general ipr form. If the POST argument has the first
# field of the ipr form, then we must be dealing with that,
# so just pass through - otherwise, collect the updater's
# info first.
submitter = None
if not(request.POST.has_key('legal_name')):
class UpdateForm(BaseContactForm):
def __init__(self, *args, **kwargs):
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.")
super(UpdateForm, self).__init__(*args, **kwargs)
if request.method == 'POST':
form = UpdateForm(request.POST)
else:
form = UpdateForm()
if not(form.is_valid()):
for error in form.errors:
log("Form error for field: %s: %s"%(error, form.errors[error]))
return render("ipr/update.html", {"form": form}, context_instance=RequestContext(request))
else:
submitter = form.clean_data
ipr = models.IprDetail.objects.get(ipr_id=ipr_id)
type = "specific"
if ipr.generic:
type = "generic"
if ipr.third_party:
type = "third-party"
return new(request, type, ipr, submitter)
def get_ipr_summary(data):

View file

@ -3,10 +3,10 @@ from ietf.ipr import models, views, new, search
urlpatterns = patterns('',
(r'^$', views.showlist),
(r'^about/?$', views.default),
(r'^about/$', views.default),
(r'^ipr-(?P<ipr_id>\d+)/$', views.show),
(r'^update/$', views.updatelist),
(r'^update/(?P<ipr_id>\d+)/$', views.update),
(r'^update/(?P<ipr_id>\d+)/$', new.update),
(r'^new-(?P<type>(specific|generic|third-party))/$', new.new),
(r'^search/$', search.search),
)

View file

@ -5,7 +5,6 @@ from django.utils.html import escape
from ietf.idtracker.models import IETFWG
from ietf.ipr.models import IprDetail, SELECT_CHOICES, LICENSE_CHOICES
from ietf.ipr.view_sections import section_table
from ietf.ipr.new import new
from ietf.utils import log
def linebreaks(value):
@ -79,16 +78,6 @@ def show(request, ipr_id=None):
return render("ipr/details.html", {"ipr": ipr, "section_list": section_list},
context_instance=RequestContext(request))
def update(request, ipr_id=None):
"""Update a specific IPR disclosure"""
ipr = IprDetail.objects.get(ipr_id=ipr_id)
type = "specific"
if ipr.generic:
type = "generic"
if ipr.third_party:
type = "third-party"
return new(request, type, ipr)
def form(request):

View file

@ -0,0 +1,45 @@
{% extends "base.html" %}
{% block title %}IPR Update{% endblock %}
{% block content %}
{% include "ipr/style.html" %}
<form name="form1" method="post">
{% if form.errors %}
<p class="errorlist">
There were errors in the submitted form -- see below. Please correct these and resubmit.
{% if form.non_field_errors %}
<ul class="errorlist">
{% for error in form.non_field_errors %}
<li>{{ error }}</li>
{% endfor %}
</ul>
{% endif %}
</p>
{% endif %}
<blockquote class="odd">
<table border="0" cellpadding="0" cellspacing="0" class="ipr person">
<tr class="{% cycle dark,light as row_parity %}"><th colspan="2" >
Contact Information for Submitter of this Update.
</th>
</tr>
<tr class="{% cycle row_parity %}"><td class="fixwidth">Name:</td> <td><b>{{ form.name }}</b></td></tr>
<tr class="{% cycle row_parity %}"><td class="fixwidth">Title:</td> <td><b>{{ form.title }}</b></td></tr>
<tr class="{% cycle row_parity %}"><td class="fixwidth">Department:</td> <td><b>{{ form.department }}</b></td></tr>
<tr class="{% cycle row_parity %}"><td class="fixwidth">Address1:</td> <td><b>{{ form.address1 }}</b></td></tr>
<tr class="{% cycle row_parity %}"><td class="fixwidth">Address2:</td> <td><b>{{ form.address2 }}</b></td></tr>
<tr class="{% cycle row_parity %}"><td class="fixwidth">Telephone:</td> <td><b>{{ form.telephone }}</b></td></tr>
<tr class="{% cycle row_parity %}"><td class="fixwidth">Fax:</td> <td><b>{{ form.fax }}</b></td></tr>
<tr class="{% cycle row_parity %}"><td class="fixwidth">Email:</td> <td><b>{{ form.email }}</b></td></tr>
</table>
</blockquote>
<p>
{{ form.update_auth }}
<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>
</p>
<input type="submit" name="submit" value="Submit">
&nbsp; <input type="button" value="Cancel" onClick="history.go(-1);return true;"><br>
</form>
{% endblock %}