From e9638cb1c2b380cfb99b7fcc2cf5aac4a62572c8 Mon Sep 17 00:00:00 2001
From: Ole Laursen
Date: Mon, 2 Dec 2013 16:34:00 +0000
Subject: [PATCH] Port IPR module to new schema, remove some cruft -
Legacy-Id: 6774
---
ietf/doc/proxy.py | 46 +++++-
ietf/ipr/__init__.py | 1 -
ietf/ipr/admin.py | 16 +-
ietf/ipr/feeds.py | 2 +-
ietf/ipr/models.py | 72 +-------
ietf/ipr/new.py | 104 ++++--------
ietf/ipr/search.py | 32 +---
ietf/ipr/urls.py | 4 +-
ietf/ipr/view_sections.py | 13 +-
ietf/ipr/views.py | 104 ++++--------
ietf/secr/ipradmin/forms.py | 11 +-
ietf/secr/ipradmin/models.py | 192 ----------------------
ietf/secr/ipradmin/views.py | 10 +-
ietf/templates/ipr/details.html | 8 +-
ietf/templates/ipr/drafts.html | 3 -
ietf/templates/ipr/list.html | 2 +-
ietf/templates/ipr/list_item.html | 12 +-
ietf/templates/ipr/removed.html | 4 +-
ietf/templates/ipr/search.html | 20 +--
ietf/templates/ipr/search_doc_result.html | 6 +-
ietf/templates/ipr/search_result.html | 22 +--
ietf/templates/ipr/search_wg_result.html | 4 +-
22 files changed, 192 insertions(+), 496 deletions(-)
delete mode 100644 ietf/templates/ipr/drafts.html
diff --git a/ietf/doc/proxy.py b/ietf/doc/proxy.py
index 6b2fbe15c..c302bd268 100644
--- a/ietf/doc/proxy.py
+++ b/ietf/doc/proxy.py
@@ -714,7 +714,6 @@ class InternetDraft(Document):
@property
def ipr(self):
- from ietf.ipr.models import IprDraftProxy
return IprDraftProxy.objects.filter(doc_alias__document=self.pk)
class Meta:
@@ -888,7 +887,6 @@ class DraftLikeDocAlias(DocAlias):
@property
def ipr(self):
- from ietf.ipr.models import IprDraftProxy
return IprDraftProxy.objects.filter(doc_alias=self.pk)
class Meta:
@@ -996,3 +994,47 @@ class IDState(State):
proxy = True
+
+
+# proxy stuff for ipr
+from ietf.ipr.models import IprDocAlias
+
+class IprDraftProxy(IprDocAlias):
+ objects = TranslatingManager(dict(document="doc_alias__name"))
+
+ # document = models.ForeignKey(InternetDraft, db_column='id_document_tag', "ipr")
+ # document = models.ForeignKey(Rfc, db_column='rfc_number', related_name="ipr")
+ @property
+ def document(self):
+ from ietf.doc.proxy import DraftLikeDocAlias
+ return DraftLikeDocAlias.objects.get(pk=self.doc_alias_id)
+
+ #revision = models.CharField(max_length=2)
+ @property
+ def revision(self):
+ return self.rev
+
+ class Meta:
+ proxy = True
+
+IprDraft = IprDraftProxy
+
+class IprRfcProxy(IprDocAlias):
+ objects = TranslatingManager(dict(document=lambda v: ("doc_alias__name", "rfc%s" % v)))
+
+ # document = models.ForeignKey(InternetDraft, db_column='id_document_tag', "ipr")
+ # document = models.ForeignKey(Rfc, db_column='rfc_number', related_name="ipr")
+ @property
+ def document(self):
+ from ietf.doc.proxy import DraftLikeDocAlias
+ return DraftLikeDocAlias.objects.get(pk=self.doc_alias_id)
+
+ #revision = models.CharField(max_length=2)
+ @property
+ def revision(self):
+ return self.rev
+
+ class Meta:
+ proxy = True
+
+IprRfc = IprRfcProxy
diff --git a/ietf/ipr/__init__.py b/ietf/ipr/__init__.py
index a4b306690..8b1378917 100644
--- a/ietf/ipr/__init__.py
+++ b/ietf/ipr/__init__.py
@@ -1,2 +1 @@
-# Copyright The IETF Trust 2007, All Rights Reserved
diff --git a/ietf/ipr/admin.py b/ietf/ipr/admin.py
index ca96d2b09..8cc9c81e3 100644
--- a/ietf/ipr/admin.py
+++ b/ietf/ipr/admin.py
@@ -8,8 +8,20 @@ class IprContactAdmin(admin.ModelAdmin):
admin.site.register(IprContact, IprContactAdmin)
class IprDetailAdmin(admin.ModelAdmin):
- list_display = ['title', 'submitted_date', 'docs', ]
- search_fields = ['title', 'legal_name', ]
+ list_display = ['title', 'submitted_date', 'docs', 'status']
+ search_fields = ['title', 'legal_name']
+
+ def docs(self, ipr):
+ res = []
+ for iprdocalias in IprDocAlias.objects.filter(ipr=ipr).order_by("id").select_related("doc_alias"):
+ if iprdocalias.doc_alias.name.startswith("rfc"):
+ n = iprdocalias.doc_alias.name.upper()
+ elif iprdocalias.rev:
+ n = iprdocalias.doc_alias.name + iprdocalias.rev
+ else:
+ n = iprdocalias.doc_alias.name
+ res.append(n)
+ return u", ".join(res)
admin.site.register(IprDetail, IprDetailAdmin)
class IprLicensingAdmin(admin.ModelAdmin):
diff --git a/ietf/ipr/feeds.py b/ietf/ipr/feeds.py
index b92a98a99..3afac4b13 100644
--- a/ietf/ipr/feeds.py
+++ b/ietf/ipr/feeds.py
@@ -22,7 +22,7 @@ class LatestIprDisclosures(Feed):
# though the database has only date, not time
return datetime.combine(item.submitted_date, time(0,0,0))
def item_author_name(self, item):
- s = item.get_submitter()
+ s = item.get_submitter()
if s:
return s.name
return None
diff --git a/ietf/ipr/models.py b/ietf/ipr/models.py
index 9b84a3a24..30e0c6941 100644
--- a/ietf/ipr/models.py
+++ b/ietf/ipr/models.py
@@ -1,11 +1,9 @@
# Copyright The IETF Trust 2007, All Rights Reserved
from django.db import models
-from django.conf import settings
-from ietf.utils.lazy import reverse_lazy
-# ------------------------------------------------------------------------
-# Models
+from ietf.doc.models import DocAlias
+
LICENSE_CHOICES = (
(1, 'a) No License Required for Implementers.'),
@@ -42,20 +40,14 @@ class IprSelecttype(models.Model):
type_id = models.AutoField(primary_key=True)
is_pending = models.IntegerField(unique=True, db_column="selecttype")
type_display = models.CharField(blank=True, max_length=15)
- def __str__(self):
+ def __unicode__(self):
return self.type_display
- class Meta:
- if not settings.USE_DB_REDESIGN_PROXY_CLASSES:
- db_table = 'ipr_selecttype'
class IprLicensing(models.Model):
licensing_option = models.AutoField(primary_key=True)
value = models.CharField(max_length=255, db_column='licensing_option_value')
- def __str__(self):
+ def __unicode__(self):
return self.value;
- class Meta:
- if not settings.USE_DB_REDESIGN_PROXY_CLASSES:
- db_table = 'ipr_licensing'
class IprDetail(models.Model):
@@ -115,17 +107,8 @@ class IprDetail(models.Model):
submitted_date = models.DateField(blank=True)
update_notified_date = models.DateField(null=True, blank=True)
- def __str__(self):
- return self.title
def __unicode__(self):
- if settings.USE_DB_REDESIGN_PROXY_CLASSES:
- # the latin-1 decode doesn't seem necessary anymore
- return self.title
- return self.title.decode("latin-1", 'replace')
- def docs(self):
- if settings.USE_DB_REDESIGN_PROXY_CLASSES:
- return list(IprDraftProxy.objects.filter(ipr=self))
- return list(self.drafts.all()) + list(self.rfcs.all())
+ return self.title
@models.permalink
def get_absolute_url(self):
return ('ietf.ipr.views.show', [str(self.ipr_id)])
@@ -173,8 +156,6 @@ class IprUpdate(models.Model):
processed = models.IntegerField(null=True, blank=True)
-from ietf.doc.models import DocAlias
-
class IprDocAlias(models.Model):
ipr = models.ForeignKey(IprDetail, related_name='documents')
doc_alias = models.ForeignKey(DocAlias)
@@ -189,46 +170,3 @@ class IprDocAlias(models.Model):
verbose_name = "IPR document alias"
verbose_name_plural = "IPR document aliases"
-# proxy stuff
-
-from ietf.utils.proxy import TranslatingManager
-
-class IprDraftProxy(IprDocAlias):
- objects = TranslatingManager(dict(document="doc_alias__name"))
-
- # document = models.ForeignKey(InternetDraft, db_column='id_document_tag', "ipr")
- # document = models.ForeignKey(Rfc, db_column='rfc_number', related_name="ipr")
- @property
- def document(self):
- from ietf.doc.proxy import DraftLikeDocAlias
- return DraftLikeDocAlias.objects.get(pk=self.doc_alias_id)
-
- #revision = models.CharField(max_length=2)
- @property
- def revision(self):
- return self.rev
-
- class Meta:
- proxy = True
-
-IprDraft = IprDraftProxy
-
-class IprRfcProxy(IprDocAlias):
- objects = TranslatingManager(dict(document=lambda v: ("doc_alias__name", "rfc%s" % v)))
-
- # document = models.ForeignKey(InternetDraft, db_column='id_document_tag', "ipr")
- # document = models.ForeignKey(Rfc, db_column='rfc_number', related_name="ipr")
- @property
- def document(self):
- from ietf.doc.proxy import DraftLikeDocAlias
- return DraftLikeDocAlias.objects.get(pk=self.doc_alias_id)
-
- #revision = models.CharField(max_length=2)
- @property
- def revision(self):
- return self.rev
-
- class Meta:
- proxy = True
-
-IprRfc = IprRfcProxy
diff --git a/ietf/ipr/new.py b/ietf/ipr/new.py
index 0aae2ed91..a1524898b 100644
--- a/ietf/ipr/new.py
+++ b/ietf/ipr/new.py
@@ -1,19 +1,17 @@
# Copyright The IETF Trust 2007, All Rights Reserved
import re
-import models
-import ietf.utils
-from django import forms
-from datetime import datetime
from django.shortcuts import render_to_response as render, get_object_or_404
from django.template import RequestContext
from django.http import Http404
from django.conf import settings
+from django import forms
+
from ietf.utils import log
from ietf.utils.mail import send_mail
+from ietf.ipr.models import IprDetail, IprDocAlias, IprContact, LICENSE_CHOICES, IprUpdate
from ietf.ipr.view_sections import section_table
-from ietf.idtracker.models import Rfc, InternetDraft
# ----------------------------------------------------------------
# Create base forms from models
@@ -22,21 +20,19 @@ from ietf.idtracker.models import Rfc, InternetDraft
phone_re = re.compile(r'^\+?[0-9 ]*(\([0-9]+\))?[0-9 -]+( ?x ?[0-9]+)?$')
phone_error_message = """Phone numbers may have a leading "+", and otherwise only contain numbers [0-9]; dash, period or space; parentheses, and an optional extension number indicated by 'x'."""
-from django.forms import ModelForm
-
-class BaseIprForm(ModelForm):
- licensing_option = forms.IntegerField(widget=forms.RadioSelect(choices=models.LICENSE_CHOICES), required=False)
+class BaseIprForm(forms.ModelForm):
+ licensing_option = forms.IntegerField(widget=forms.RadioSelect(choices=LICENSE_CHOICES), required=False)
is_pending = forms.IntegerField(widget=forms.RadioSelect(choices=((1, "YES"), (2, "NO"))), required=False)
applies_to_all = forms.IntegerField(widget=forms.RadioSelect(choices=((1, "YES"), (2, "NO"))), required=False)
class Meta:
- model = models.IprDetail
+ model = IprDetail
exclude = ('rfc_document', 'id_document_tag') # 'legacy_url_0','legacy_url_1','legacy_title_1','legacy_url_2','legacy_title_2')
-class BaseContactForm(ModelForm):
+class BaseContactForm(forms.ModelForm):
telephone = forms.RegexField(phone_re, error_message=phone_error_message)
fax = forms.RegexField(phone_re, error_message=phone_error_message, required=False)
class Meta:
- model = models.IprContact
+ model = IprContact
exclude = ('ipr', 'contact_type')
# Some subclassing:
@@ -102,19 +98,11 @@ def new(request, type, update=None, submitter=None):
setattr(self, contact, ContactForm(prefix=contact[:4], initial=contact_initial.get(contact, {}), *args, **kwnoinit))
rfclist_initial = ""
if update:
- if settings.USE_DB_REDESIGN_PROXY_CLASSES:
- from ietf.ipr.models import IprDocAlias
- rfclist_initial = " ".join(a.doc_alias.name.upper() for a in IprDocAlias.objects.filter(doc_alias__name__startswith="rfc", ipr=update))
- else:
- rfclist_initial = " ".join(["RFC%d" % rfc.document_id for rfc in update.rfcs.all()])
+ rfclist_initial = " ".join(a.doc_alias.name.upper() for a in IprDocAlias.objects.filter(doc_alias__name__startswith="rfc", ipr=update))
self.base_fields["rfclist"] = forms.CharField(required=False, initial=rfclist_initial)
draftlist_initial = ""
if update:
- if settings.USE_DB_REDESIGN_PROXY_CLASSES:
- from ietf.ipr.models import IprDocAlias
- draftlist_initial = " ".join(a.doc_alias.name + ("-%s" % a.rev if a.rev else "") for a in IprDocAlias.objects.filter(ipr=update).exclude(doc_alias__name__startswith="rfc"))
- else:
- draftlist_initial = " ".join([draft.document.filename + (draft.revision and "-%s" % draft.revision or "") for draft in update.drafts.all()])
+ draftlist_initial = " ".join(a.doc_alias.name + ("-%s" % a.rev if a.rev else "") for a in IprDocAlias.objects.filter(ipr=update).exclude(doc_alias__name__startswith="rfc"))
self.base_fields["draftlist"] = forms.CharField(required=False, initial=draftlist_initial)
if section_list.get("holder_contact", False):
self.base_fields["hold_contact_is_submitter"] = forms.BooleanField(required=False)
@@ -142,11 +130,7 @@ def new(request, type, update=None, submitter=None):
rfclist = rfclist.strip().split()
for rfc in rfclist:
try:
- if settings.USE_DB_REDESIGN_PROXY_CLASSES:
- from ietf.doc.models import DocAlias
- DocAlias.objects.get(name="rfc%s" % int(rfc))
- else:
- Rfc.objects.get(rfc_number=int(rfc))
+ DocAlias.objects.get(name="rfc%s" % int(rfc))
except:
raise forms.ValidationError("Unknown RFC number: %s - please correct this." % rfc)
rfclist = " ".join(rfclist)
@@ -167,19 +151,13 @@ def new(request, type, update=None, submitter=None):
filename = draft
rev = None
try:
- if settings.USE_DB_REDESIGN_PROXY_CLASSES:
- from ietf.doc.models import DocAlias
- id = DocAlias.objects.get(name=filename)
- # proxy attribute for code below
- id.revision = id.document.rev
- else:
- id = InternetDraft.objects.get(filename=filename)
- except Exception, e:
+ doc = Document.objects.get(docalias__name=filename)
+ except Exception as e:
log("Exception: %s" % e)
raise forms.ValidationError("Unknown Internet-Draft: %s - please correct this." % filename)
- if rev and id.revision != rev:
+ if rev and doc.rev != rev:
raise forms.ValidationError("Unexpected revision '%s' for draft %s - the current revision is %s. Please check this." % (rev, filename, id.revision))
- drafts.append("%s-%s" % (filename, id.revision))
+ drafts.append("%s-%s" % (filename, doc.rev))
return " ".join(drafts)
return ""
def clean_licensing_option(self):
@@ -205,7 +183,7 @@ def new(request, type, update=None, submitter=None):
data = request.POST.copy()
else:
data = request.GET.copy()
- data["submitted_date"] = datetime.now().strftime("%Y-%m-%d")
+ data["submitted_date"] = datetime.datetime.now().strftime("%Y-%m-%d")
data["third_party"] = section_list["third_party"]
data["generic"] = section_list["generic"]
data["status"] = "0"
@@ -222,7 +200,7 @@ def new(request, type, update=None, submitter=None):
form = IprForm(data)
if form.is_valid():
# Save data :
- # IprDetail, IprUpdate, IprContact+, IprDraft+, IprRfc+, IprNotification
+ # IprDetail, IprUpdate, IprContact+, IprDocAlias+, IprNotification
# Save IprDetail
instance = form.save(commit=False)
@@ -248,7 +226,7 @@ def new(request, type, update=None, submitter=None):
instance.save()
if update:
- updater = models.IprUpdate(ipr=instance, updated=update, status_to_be=1, processed=0)
+ updater = IprUpdate(ipr=instance, updated=update, status_to_be=1, processed=0)
updater.save()
contact_type = {"hold":1, "ietf":2, "subm": 3}
@@ -263,7 +241,7 @@ def new(request, type, update=None, submitter=None):
del cdata["contact_is_submitter"]
except KeyError:
pass
- contact = models.IprContact(**dict([(str(a),b) for a,b in cdata.items()]))
+ contact = IprContact(**dict([(str(a),b) for a,b in cdata.items()]))
contact.save()
# store this contact in the instance for the email
# similar to what views.show() does
@@ -279,34 +257,21 @@ def new(request, type, update=None, submitter=None):
# else:
# log("Invalid contact: %s" % contact)
- # Save IprDraft(s)
+ # Save draft links
for draft in form.cleaned_data["draftlist"].split():
- if settings.USE_DB_REDESIGN_PROXY_CLASSES:
- name = draft[:-3]
- rev = draft[-2:]
-
- from ietf.doc.models import DocAlias
- models.IprDocAlias.objects.create(
- doc_alias=DocAlias.objects.get(name=name),
- ipr=instance,
- rev=rev)
- else:
- id = InternetDraft.objects.get(filename=draft[:-3])
- iprdraft = models.IprDraft(document=id, ipr=instance, revision=draft[-2:])
- iprdraft.save()
+ name = draft[:-3]
+ rev = draft[-2:]
+
+ IprDocAlias.objects.create(
+ doc_alias=DocAlias.objects.get(name=name),
+ ipr=instance,
+ rev=rev)
- # Save IprRfc(s)
for rfcnum in form.cleaned_data["rfclist"].split():
- if settings.USE_DB_REDESIGN_PROXY_CLASSES:
- from ietf.doc.models import DocAlias
- models.IprDocAlias.objects.create(
- doc_alias=DocAlias.objects.get(name="rfc%s" % int(rfcnum)),
- ipr=instance,
- rev="")
- else:
- rfc = Rfc.objects.get(rfc_number=int(rfcnum))
- iprrfc = models.IprRfc(document=rfc, ipr=instance)
- iprrfc.save()
+ IprDocAlias.objects.create(
+ doc_alias=DocAlias.objects.get(name="rfc%s" % int(rfcnum)),
+ ipr=instance,
+ rev="")
send_mail(request, settings.IPR_EMAIL_TO, ('IPR Submitter App', 'ietf-ipr@ietf.org'), 'New IPR Submission Notification', "ipr/new_update_email.txt", {"ipr": instance, "update": update})
return render("ipr/submitted.html", {"update": update}, context_instance=RequestContext(request))
@@ -328,12 +293,12 @@ def new(request, type, update=None, submitter=None):
form = IprForm()
form.unbound_form = True
- # ietf.utils.log(dir(form.ietf_contact_is_submitter))
+ # log(dir(form.ietf_contact_is_submitter))
return render("ipr/details_edit.html", {"ipr": form, "section_list":section_list, "debug": debug}, context_instance=RequestContext(request))
def update(request, ipr_id=None):
"""Update a specific IPR disclosure"""
- ipr = get_object_or_404(models.IprDetail, ipr_id=ipr_id)
+ ipr = get_object_or_404(IprDetail, ipr_id=ipr_id)
if not ipr.status in [1,3]:
raise Http404
type = "specific"
@@ -386,6 +351,3 @@ def get_ipr_summary(data):
ipr = ", ".join(ipr[:-1]) + ", and " + ipr[-1]
return ipr
-
-# changes done by convert-096.py:changed newforms to forms
-# cleaned_data
diff --git a/ietf/ipr/search.py b/ietf/ipr/search.py
index 9ea73a09c..68fe4315b 100644
--- a/ietf/ipr/search.py
+++ b/ietf/ipr/search.py
@@ -3,28 +3,21 @@
import codecs
import re
import os.path
+
from django.http import HttpResponseRedirect, Http404
from django.shortcuts import render_to_response as render
from django.template import RequestContext
from django.conf import settings
-from ietf.ipr.models import IprDraft, IprDetail
+
+from ietf.ipr.models import IprDocAlias, IprDetail
from ietf.ipr.related import related_docs
from ietf.utils import log, normalize_draftname
from ietf.group.models import Group
from ietf.doc.models import DocAlias
-
-def mark_last_doc(iprs):
- for item in iprs:
- docs = item.docs()
- count = len(docs)
- if count > 1:
- item.last_draft = docs[count-1]
-
def iprs_from_docs(docs):
iprs = []
for doc in docs:
- from ietf.ipr.models import IprDocAlias
disclosures = [ x.ipr for x in IprDocAlias.objects.filter(doc_alias=doc, ipr__status__in=[1,3]) ]
doc.iprs = None
if disclosures:
@@ -57,7 +50,7 @@ def search(request, type="", q="", id=""):
q = value
if re.match(".*id", key):
id = value
- if type and q or id:
+ if (type and q) or id:
#log("Got query: type=%s, q=%s, id=%s" % (type, q, id))
# Search by RFC number or draft-identifier
@@ -82,14 +75,14 @@ def search(request, type="", q="", id=""):
doc = str(first)
docs = related_docs(first)
iprs, docs = iprs_from_docs(docs)
- iprs.sort(key=lambda x:(x.submitted_date,x.ipr_id))
- return render("ipr/search_doc_result.html", {"q": q, "first": first, "iprs": iprs, "docs": docs, "doc": doc },
+ iprs.sort(key=lambda x: (x.submitted_date, x.ipr_id))
+ return render("ipr/search_doc_result.html", {"q": q, "iprs": iprs, "docs": docs, "doc": doc },
context_instance=RequestContext(request) )
elif start.count():
return render("ipr/search_doc_list.html", {"q": q, "docs": start },
context_instance=RequestContext(request) )
else:
- return render("ipr/search_doc_result.html", {"q": q, "first": {}, "iprs": {}, "docs": {}, "doc": doc },
+ return render("ipr/search_doc_result.html", {"q": q, "iprs": {}, "docs": {}, "doc": doc },
context_instance=RequestContext(request) )
# Search by legal name
@@ -98,9 +91,6 @@ def search(request, type="", q="", id=""):
iprs = IprDetail.objects.filter(legal_name__icontains=q, status__in=[1,3]).order_by("-submitted_date", "-ipr_id")
count = iprs.count()
iprs = [ ipr for ipr in iprs if not ipr.updated_by.all() ]
- # Some extra information, to help us render 'and' between the
- # last two documents in a sequence
- mark_last_doc(iprs)
return render("ipr/search_holder_result.html", {"q": q, "iprs": iprs, "count": count },
context_instance=RequestContext(request) )
@@ -123,10 +113,7 @@ def search(request, type="", q="", id=""):
iprs.append(ipr)
count = len(iprs)
iprs = [ ipr for ipr in iprs if not ipr.updated_by.all() ]
- # Some extra information, to help us render 'and' between the
- # last two documents in a sequence
- iprs.sort(key=lambda x: x.ipr_id, reverse=True) # Reverse sort
- mark_last_doc(iprs)
+ iprs.sort(key=lambda x: x.ipr_id, reverse=True)
return render("ipr/search_patent_result.html", {"q": q, "iprs": iprs, "count": count },
context_instance=RequestContext(request) )
@@ -170,9 +157,6 @@ def search(request, type="", q="", id=""):
iprs = IprDetail.objects.filter(title__icontains=q, status__in=[1,3]).order_by("-submitted_date", "-ipr_id")
count = iprs.count()
iprs = [ ipr for ipr in iprs if not ipr.updated_by.all() ]
- # Some extra information, to help us render 'and' between the
- # last two documents in a sequence
- mark_last_doc(iprs)
return render("ipr/search_iprtitle_result.html", {"q": q, "iprs": iprs, "count": count },
context_instance=RequestContext(request) )
diff --git a/ietf/ipr/urls.py b/ietf/ipr/urls.py
index 43ad3749f..554215b0b 100644
--- a/ietf/ipr/urls.py
+++ b/ietf/ipr/urls.py
@@ -7,8 +7,8 @@ from django.views.generic.simple import redirect_to
urlpatterns = patterns('',
url(r'^$', views.showlist, name='ipr_showlist'),
- (r'^about/$', views.default),
- (r'^by-draft/$', views.list_drafts),
+ (r'^about/$', views.about),
+ (r'^by-draft/$', views.iprs_for_drafts_txt),
url(r'^(?P\d+)/$', views.show, name='ipr_show'),
(r'^update/$', redirect_to, { 'url': reverse_lazy('ipr_showlist') }),
(r'^update/(?P\d+)/$', new.update),
diff --git a/ietf/ipr/view_sections.py b/ietf/ipr/view_sections.py
index 385b18af2..45b41f6f6 100644
--- a/ietf/ipr/view_sections.py
+++ b/ietf/ipr/view_sections.py
@@ -1,6 +1,5 @@
# Copyright The IETF Trust 2007, All Rights Reserved
-
section_table = {
"specific": { "title": True,
"specific": 1, "generic": 0, "third_party": 0,
@@ -38,3 +37,15 @@ section_table = {
"per_rfc_disclosure": False, "also_specific": False,
},
}
+
+def section_list_for_ipr(ipr):
+ if ipr.legacy_url_0:
+ return section_table["legacy"]
+ elif ipr.generic:
+ #assert not ipr.third_party
+ return section_table["generic"]
+ elif ipr.third_party:
+ return section_table["third-party"]
+ else:
+ return section_table["specific"]
+
diff --git a/ietf/ipr/views.py b/ietf/ipr/views.py
index 4cca6d8f1..baadc323c 100644
--- a/ietf/ipr/views.py
+++ b/ietf/ipr/views.py
@@ -1,18 +1,18 @@
# Copyright The IETF Trust 2007, All Rights Reserved
+import os
+
from django.shortcuts import render_to_response as render, get_object_or_404
from django.template import RequestContext
from django.template.loader import render_to_string
from django.http import HttpResponse, Http404
from django.conf import settings
-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.utils import log
-import os
-def default(request):
- """Default page, with links to sub-pages"""
+from ietf.ipr.models import IprDetail, IprDocAlias, SELECT_CHOICES, LICENSE_CHOICES
+from ietf.ipr.view_sections import section_list_for_ipr
+from ietf.doc.models import Document
+
+def about(request):
return render("ipr/disclosure.html", {}, context_instance=RequestContext(request))
def showlist(request):
@@ -28,56 +28,6 @@ def showlist(request):
'thirdpty_disclosures': thirdpty_disclosures.order_by(* ['-submitted_date', ] ),
}, context_instance=RequestContext(request) )
-def list_drafts(request):
- iprs = IprDetail.objects.filter(status=1)
- docipr = {}
- docs = []
- for ipr in iprs:
- for draft in ipr.drafts.all():
- name = draft.document.filename
- if not name in docipr:
- docipr[name] = []
- docipr[name] += [ ipr.ipr_id ]
- for rfc in ipr.rfcs.all():
- name = "RFC%04d" % rfc.document.rfc_number
- if not name in docipr:
- docipr[name] = []
- docipr[name] += [ ipr.ipr_id ]
- docs = [ {"name":key, "iprs":value, } for key,value in docipr.items() ]
- return HttpResponse(render_to_string("ipr/drafts.html", { "docs":docs, },
- context_instance=RequestContext(request)),
- mimetype="text/plain")
-
-def list_draftsREDESIGN(request):
- from ietf.ipr.models import IprDocAlias
-
- docipr = {}
-
- for o in IprDocAlias.objects.filter(ipr__status=1).select_related("doc_alias"):
- name = o.doc_alias.name
- if name.startswith("rfc"):
- name = name.upper()
-
- if not name in docipr:
- docipr[name] = []
-
- docipr[name].append(o.ipr_id)
-
- docs = [ dict(name=name, iprs=sorted(iprs)) for name, iprs in docipr.iteritems() ]
-
- # drafts.html is not an HTML file
- return HttpResponse(render_to_string("ipr/drafts.html",
- dict(docs=docs),
- context_instance=RequestContext(request)),
- mimetype="text/plain")
-
-
-if settings.USE_DB_REDESIGN_PROXY_CLASSES:
- list_drafts = list_draftsREDESIGN
-
-
-# Details views
-
def show(request, ipr_id=None, removed=None):
"""Show a specific IPR disclosure"""
assert ipr_id != None
@@ -87,9 +37,9 @@ def show(request, ipr_id=None, removed=None):
context_instance=RequestContext(request))
if removed and ipr.status != 3:
raise Http404
- if not ipr.status == 1 and not removed:
+ if ipr.status != 1 and not removed:
raise Http404
- section_list = get_section_list(ipr)
+ section_list = section_list_for_ipr(ipr)
contacts = ipr.contact.all()
for contact in contacts:
if contact.contact_type == 1:
@@ -122,24 +72,30 @@ def show(request, ipr_id=None, removed=None):
# if file does not exist, iframe is used instead
pass
- if settings.USE_DB_REDESIGN_PROXY_CLASSES:
- from ietf.ipr.models import IprDraft, IprRfc
- ipr.drafts = IprDraft.objects.filter(ipr=ipr).exclude(doc_alias__name__startswith="rfc").order_by("id")
- ipr.rfcs = IprRfc.objects.filter(ipr=ipr).filter(doc_alias__name__startswith="rfc").order_by("id")
+ iprdocs = IprDocAlias.objects.filter(ipr=ipr).order_by("id").select_related("doc_alias", "doc_alias__document")
+
+ ipr.drafts = [x for x in iprdocs if not x.doc_alias.name.startswith("rfc")]
+ ipr.rfcs = [x for x in iprdocs if x.doc_alias.name.startswith("rfc")]
return render("ipr/details.html", {"ipr": ipr, "section_list": section_list},
context_instance=RequestContext(request))
+def iprs_for_drafts_txt(request):
+ docipr = {}
-# ---- Helper functions ------------------------------------------------------
+ for o in IprDocAlias.objects.filter(ipr__status=1).select_related("doc_alias"):
+ name = o.doc_alias.name
+ if name.startswith("rfc"):
+ name = name.upper()
+
+ if not name in docipr:
+ docipr[name] = []
+
+ docipr[name].append(o.ipr_id)
+
+ lines = [ u"# Machine-readable list of IPR disclosures by draft name" ]
+ for name, iprs in docipr.iteritems():
+ lines.append(name + "\t" + "\t".join(unicode(ipr_id) for ipr_id in sorted(iprs)))
+
+ return HttpResponse("\n".join(lines), mimetype="text/plain")
-def get_section_list(ipr):
- if ipr.legacy_url_0:
- return section_table["legacy"]
- elif ipr.generic:
- #assert not ipr.third_party
- return section_table["generic"]
- elif ipr.third_party:
- return section_table["third-party"]
- else:
- return section_table["specific"]
diff --git a/ietf/secr/ipradmin/forms.py b/ietf/secr/ipradmin/forms.py
index 7f601033b..a7d62d4c9 100644
--- a/ietf/secr/ipradmin/forms.py
+++ b/ietf/secr/ipradmin/forms.py
@@ -5,7 +5,7 @@ from django.utils.safestring import mark_safe
from django.forms.formsets import formset_factory
from django.utils import simplejson
-from ietf.ipr.models import IprDetail, IprContact, LICENSE_CHOICES, IprRfc, IprDraft, IprUpdate, SELECT_CHOICES, IprDocAlias
+from ietf.ipr.models import IprDetail, IprContact, LICENSE_CHOICES, IprUpdate, SELECT_CHOICES, IprDocAlias
from ietf.doc.models import DocAlias
from ietf.secr.utils.document import get_rfc_num
@@ -246,14 +246,7 @@ class IprDetailForm(BetterModelForm):
obj.status_to_be = old_ipr.status
obj.processed = 0
obj.save()
- '''
- IprRfc.objects.filter(ipr=ipr_detail).delete()
- IprDraft.objects.filter(ipr=ipr_detail).delete()
- for rfc in self.cleaned_data['rfc_num']:
- IprRfc.objects.create(ipr=ipr_detail, document=rfc)
- for draft in self.cleaned_data['id_filename']:
- IprDraft.objects.create(ipr=ipr_detail, document=draft)
- '''
+
IprDocAlias.objects.filter(ipr=ipr_detail).delete()
for doc in self.cleaned_data['rfc_num']:
IprDocAlias.objects.create(ipr=ipr_detail,doc_alias=doc)
diff --git a/ietf/secr/ipradmin/models.py b/ietf/secr/ipradmin/models.py
index e9c9bed54..137941ffa 100644
--- a/ietf/secr/ipradmin/models.py
+++ b/ietf/secr/ipradmin/models.py
@@ -1,193 +1 @@
-# Copyright The IETF Trust 2007, All Rights Reserved
-
from django.db import models
-#from django import newforms as forms
-#from sec.drafts.models import InternetDraft
-#from sec.drafts.models import Rfc
-
-from ietf.ipr.models import *
-
-# ------------------------------------------------------------------------
-# Models
-
-'''
-LICENSE_CHOICES = (
- (1, 'a) No License Required for Implementers.'),
- (2, 'b) Royalty-Free, Reasonable and Non-Discriminatory License to All Implementers.'),
- (3, 'c) Reasonable and Non-Discriminatory License to All Implementers with Possible Royalty/Fee.'),
- (4, 'd) Licensing Declaration to be Provided Later (implies a willingness'
- ' to commit to the provisions of a), b), or c) above to all implementers;'
- ' otherwise, the next option "Unwilling to Commit to the Provisions of'
- ' a), b), or c) Above". - must be selected).'),
- (5, 'e) Unwilling to Commit to the Provisions of a), b), or c) Above.'),
- (6, 'f) See Text Below for Licensing Declaration.'),
-)
-STDONLY_CHOICES = (
- (0, ""),
- (1, "The licensing declaration is limited solely to standards-track IETF documents."),
-)
-SELECT_CHOICES = (
- (0, 'NO'),
- (1, 'YES'),
- (2, 'NO'),
-)
-STATUS_CHOICES = (
- ( 0, "Waiting for approval" ),
- ( 1, "Approved and Posted" ),
- ( 2, "Rejected by Administrator" ),
- ( 3, "Removed by Request" ),
-)
-# not clear why this has both an ID and selecttype
-# Also not clear why a table for "YES" and "NO".
-class IprSelecttype(models.Model):
- type_id = models.AutoField(primary_key=True)
- is_pending = models.IntegerField(unique=True, db_column="selecttype")
- type_display = models.CharField(blank=True, max_length=15)
- def __str__(self):
- return self.type_display
- class Meta:
- db_table = 'ipr_selecttype'
-
-class IprLicensing(models.Model):
- licensing_option = models.AutoField(primary_key=True)
- value = models.CharField(max_length=255, db_column='licensing_option_value')
- def __str__(self):
- return self.value;
- class Meta:
- db_table = 'ipr_licensing'
-
-
-class IprDetail(models.Model):
- ipr_id = models.AutoField(primary_key=True)
- title = models.CharField(blank=True, db_column="document_title", max_length=255)
-
- # Legacy information fieldset
- legacy_url_0 = models.CharField(blank=True, null=True, db_column="old_ipr_url", max_length=255)
- legacy_url_1 = models.CharField(blank=True, null=True, db_column="additional_old_url1", max_length=255)
- legacy_title_1 = models.CharField(blank=True, null=True, db_column="additional_old_title1", max_length=255)
- legacy_url_2 = models.CharField(blank=True, null=True, db_column="additional_old_url2", max_length=255)
- legacy_title_2 = models.CharField(blank=True, null=True, db_column="additional_old_title2", max_length=255)
-
- # Patent holder fieldset
- legal_name = models.CharField("Legal Name", db_column="p_h_legal_name", max_length=255)
-
- # Patent Holder Contact fieldset
- # self.contact.filter(contact_type=1)
-
- # IETF Contact fieldset
- # self.contact.filter(contact_type=3)
-
- # Related IETF Documents fieldset
- rfc_number = models.IntegerField(null=True, editable=False, blank=True) # always NULL
- id_document_tag = models.IntegerField(null=True, editable=False, blank=True) # always NULL
- other_designations = models.CharField(blank=True, max_length=255)
- document_sections = models.TextField("Specific document sections covered", blank=True, max_length=255, db_column='disclouser_identify')
-
- # Patent Information fieldset
- patents = models.TextField("Patent Applications", db_column="p_applications", max_length=255)
- date_applied = models.CharField(max_length=255)
- country = models.CharField(max_length=100)
- notes = models.TextField("Additional notes", db_column="p_notes", blank=True)
- # AMS Change
- #is_pending = models.IntegerField("Unpublished Pending Patent Application", blank=True, choices=SELECT_CHOICES, db_column="selecttype")
- #is_pending = models.BooleanField(db_column="selecttype")
- is_pending = models.CharField(max_length=3,db_column="selecttype")
- applies_to_all = models.IntegerField("Applies to all IPR owned by Submitter", blank=True, choices=SELECT_CHOICES, db_column="selectowned")
-
- # Licensing Declaration fieldset
- #licensing_option = models.ForeignKey(IprLicensing, db_column='licensing_option')
- licensing_option = models.IntegerField(null=True, blank=True, choices=LICENSE_CHOICES)
- lic_opt_a_sub = models.IntegerField(editable=False, choices=STDONLY_CHOICES)
- lic_opt_b_sub = models.IntegerField(editable=False, choices=STDONLY_CHOICES)
- lic_opt_c_sub = models.IntegerField(editable=False, choices=STDONLY_CHOICES)
- comments = models.TextField("Licensing Comments", blank=True)
- lic_checkbox = models.BooleanField("All terms and conditions has been disclosed")
-
-
- # Other notes fieldset
- other_notes = models.TextField(blank=True)
-
- # Generated fields, not part of the submission form
- # Hidden fields
- third_party = models.BooleanField()
- generic = models.BooleanField()
- comply = models.BooleanField()
-
- status = models.IntegerField(null=True, blank=True, choices=STATUS_CHOICES)
- submitted_date = models.DateField(blank=True)
- update_notified_date = models.DateField(null=True, blank=True)
-
- def __str__(self):
- return self.title
- def docs(self):
- return list(self.drafts.all()) + list(self.rfcs.all())
- def get_absolute_url(self):
- return "/ipr/%d/" % self.ipr_id
- def get_submitter(self):
- try:
- return self.contact.get(contact_type=3)
- except IprContact.DoesNotExist:
- return None
- class Meta:
- db_table = 'ipr_detail'
-
-class IprContact(models.Model):
- TYPE_CHOICES = (
- (1, 'Patent Holder Contact'),
- (2, 'IETF Participant Contact'),
- (3, 'Submitter Contact'),
- )
- contact_id = models.AutoField(primary_key=True)
- ipr = models.ForeignKey(IprDetail, related_name="contact")
- contact_type = models.IntegerField(choices=TYPE_CHOICES)
- name = models.CharField(max_length=255)
- title = models.CharField(blank=True, max_length=255)
- department = models.CharField(blank=True, max_length=255)
- address1 = models.CharField(blank=True, max_length=255)
- address2 = models.CharField(blank=True, max_length=255)
- telephone = models.CharField(max_length=25)
- fax = models.CharField(blank=True, max_length=25)
- email = models.EmailField(max_length=255)
- def __str__(self):
- return self.name or ''
- class Meta:
- db_table = 'ipr_contacts'
-
-
-class IprDraft(models.Model):
- ipr = models.ForeignKey(IprDetail, related_name='drafts')
- document = models.ForeignKey(InternetDraft, db_column='id_document_tag', related_name="ipr")
- revision = models.CharField(max_length=2)
- def __str__(self):
- return "%s which applies to %s-%s" % ( self.ipr, self.document, self.revision )
- class Meta:
- db_table = 'ipr_ids'
-
-class IprNotification(models.Model):
- ipr = models.ForeignKey(IprDetail)
- notification = models.TextField(blank=True)
- date_sent = models.DateField(null=True, blank=True)
- time_sent = models.CharField(blank=True, max_length=25)
- def __str__(self):
- return "IPR notification for %s sent %s %s" % (self.ipr, self.date_sent, self.time_sent)
- class Meta:
- db_table = 'ipr_notifications'
-
-class IprRfc(models.Model):
- ipr = models.ForeignKey(IprDetail, related_name='rfcs')
- document = models.ForeignKey(Rfc, db_column='rfc_number', related_name="ipr")
- def __str__(self):
- return "%s applies to RFC%04d" % ( self.ipr, self.document_id )
- class Meta:
- db_table = 'ipr_rfcs'
-
-class IprUpdate(models.Model):
- id = models.IntegerField(primary_key=True)
- ipr = models.ForeignKey(IprDetail, related_name='updates')
- updated = models.ForeignKey(IprDetail, db_column='updated', related_name='updated_by')
- status_to_be = models.IntegerField(null=True, blank=True)
- processed = models.IntegerField(null=True, blank=True)
- class Meta:
- db_table = 'ipr_updates'
-
-'''
diff --git a/ietf/secr/ipradmin/views.py b/ietf/secr/ipradmin/views.py
index 7681de2da..8e0a325e6 100644
--- a/ietf/secr/ipradmin/views.py
+++ b/ietf/secr/ipradmin/views.py
@@ -15,7 +15,7 @@ from ietf.secr.ipradmin.forms import IprDetailForm, IPRContactFormset
from ietf.secr.utils.document import get_rfc_num, is_draft
import ietf.settings as settings
-from ietf.ipr.models import IprDetail, IprUpdate, IprRfc, IprDraft, IprContact, LICENSE_CHOICES, STDONLY_CHOICES, IprNotification
+from ietf.ipr.models import IprDetail, IprUpdate, IprContact, LICENSE_CHOICES, STDONLY_CHOICES, IprNotification
from ietf.utils.mail import send_mail_text
from ietf.doc.models import DocAlias
@@ -145,14 +145,6 @@ def admin_notify(request, ipr_id):
submitter_text = get_submitter_text(ipr_id, updated_ipr_id, from_page)
document_relatives = ''
- #drafts = IprDraft.objects.filter(ipr__ipr_id=ipr_id)
- #for draft in drafts:
- # document_relatives += get_document_relatives(ipr_id, draft, is_draft=1)
-
- #rfcs = IprRfc.objects.filter(ipr__ipr_id=ipr_id)
- #for rfc in rfcs:
- # document_relatives += get_document_relatives(ipr_id, rfc, is_draft=0)
- # REDESIGN
for iprdocalias in ipr_dtl.documents.all():
document_relatives += get_document_relatives(ipr_dtl, iprdocalias.doc_alias)
diff --git a/ietf/templates/ipr/details.html b/ietf/templates/ipr/details.html
index f63ae8181..d62c4edb6 100644
--- a/ietf/templates/ipr/details.html
+++ b/ietf/templates/ipr/details.html
@@ -162,15 +162,15 @@ Template for {{ section_list.disclosure_type }}" where the submitter provided
{% if ipr.rfclist %}
RFC Numbers: | {{ ipr.rfclist }} |
{% else %}
- {% for doc in ipr.rfcs.all %}
- RFC {{ doc.document.rfc_number }}: | "{{ doc.document.title }}" |
+ {% for iprdocalias in ipr.rfcs %}
+ RFC {{ iprdocalias.doc_alias.document.rfc_number }}: | "{{ iprdocalias.doc_alias.document.title }}" |
{% endfor %}
{% endif %}
{% if ipr.draftlist %}
I-D Filenames (draft-...): | {{ ipr.draftlist }} |
{% else %}
- {% for doc in ipr.drafts.all %}
- Internet-Draft: | "{{ doc.document.title }}" ({{ doc.document.filename }}{% if doc.revision %}-{{ doc.revision }}{% endif %}) |
+ {% for iprdocalias in ipr.drafts %}
+ Internet-Draft: | "{{ iprdocalias.doc_alias.document.title }}" ({{ iprdocalias.doc_alias.name }}{% if iprdocalias.rev %}-{{ iprdocalias.rev }}{% endif %}) |
{% endfor %}
{% endif %}
{% if ipr.other_designations %}
diff --git a/ietf/templates/ipr/drafts.html b/ietf/templates/ipr/drafts.html
deleted file mode 100644
index 07ca916ee..000000000
--- a/ietf/templates/ipr/drafts.html
+++ /dev/null
@@ -1,3 +0,0 @@
-# Machine-readable list of ipr disclosures by draft name
-{% for doc in docs %}{{doc.name}}{% for num in doc.iprs %} {{ num }}{% endfor %}
-{% endfor %}
\ No newline at end of file
diff --git a/ietf/templates/ipr/list.html b/ietf/templates/ipr/list.html
index 7b9ebc6d2..a96f2bfa7 100644
--- a/ietf/templates/ipr/list.html
+++ b/ietf/templates/ipr/list.html
@@ -12,7 +12,7 @@ The IETF takes no position regarding the validity or scope of any
intellectual property rights or other rights that might be claimed to
pertain to the implementation or use of the technology described in any IETF documents or the extent to
which any license under such rights might or might not be available; nor does it represent that it has made any independent effort to identify any such rights.
-Click here to submit an IPR disclosure
+Click here to submit an IPR disclosure
Search the IPR Disclosures
diff --git a/ietf/templates/ipr/list_item.html b/ietf/templates/ipr/list_item.html
index 65d82183c..4f916ff68 100644
--- a/ietf/templates/ipr/list_item.html
+++ b/ietf/templates/ipr/list_item.html
@@ -3,17 +3,17 @@
{{ ipr.submitted_date }} |
{{ ipr.ipr_id }} |
- {% ifequal ipr.status 1 %}
+ {% if ipr.status == 1 %}
{{ ipr.title|escape }}
{% else %}
{{ ipr.title|escape }}
This IPR disclosure was removed at the request of the submitter.
- {% endifequal %}
+ {% endif %}
{% for item in ipr.updates.all %}
- {% ifequal item.updated.status 1 %}
+ {% if item.updated.status == 1 %}
Updates ID #{{ item.updated.ipr_id }}.
- {% endifequal %}
+ {% endif %}
{% endfor %}
{% for item in ipr.updated_by.all %}
{% if item.processed == 1 and item.ipr.status != 2 %}
@@ -22,7 +22,7 @@
{% endfor %}
|
- {% ifequal ipr.status 1 %}
+ {% if ipr.status == 1 %}
{% if ipr.legacy_title_1 %}
|
@@ -43,4 +43,4 @@
{% endif %}
- {% endifequal %}
+ {% endif %}
diff --git a/ietf/templates/ipr/removed.html b/ietf/templates/ipr/removed.html
index 53a31604d..64dd488a0 100644
--- a/ietf/templates/ipr/removed.html
+++ b/ietf/templates/ipr/removed.html
@@ -1,9 +1,9 @@
{% extends "base.html" %}
{# Copyright The IETF Trust 2009, All Rights Reserved #}
-{% block title %}IPR Details - {{ ipr.title|escape }}{% endblock %}
+{% block title %}IPR Details - {{ ipr.title }}{% endblock %}
{% block content %}
-{{ ipr.title|escape }}
+{{ ipr.title }}
This IPR disclosure was removed at the submitter's request.
diff --git a/ietf/templates/ipr/search.html b/ietf/templates/ipr/search.html
index 2693e5e89..d7bbf2697 100644
--- a/ietf/templates/ipr/search.html
+++ b/ietf/templates/ipr/search.html
@@ -11,12 +11,12 @@ label { float:left; width: 200px; }
IPR Search
Document Search