Port IPR module to new schema, remove some cruft

- Legacy-Id: 6774
This commit is contained in:
Ole Laursen 2013-12-02 16:34:00 +00:00
parent f7bed5d0aa
commit e9638cb1c2
22 changed files with 192 additions and 496 deletions

View file

@ -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

View file

@ -1,2 +1 @@
# Copyright The IETF Trust 2007, All Rights Reserved

View file

@ -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):

View file

@ -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

View file

@ -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

View file

@ -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:]
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()
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

View file

@ -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) )

View file

@ -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<ipr_id>\d+)/$', views.show, name='ipr_show'),
(r'^update/$', redirect_to, { 'url': reverse_lazy('ipr_showlist') }),
(r'^update/(?P<ipr_id>\d+)/$', new.update),

View file

@ -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"]

View file

@ -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"]

View file

@ -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)

View file

@ -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 '<no name>'
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'
'''

View file

@ -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)

View file

@ -162,15 +162,15 @@ Template for {{ section_list.disclosure_type }}" where the submitter provided
{% if ipr.rfclist %}
<tr class="{% cycle row_parity %}"><td class="iprlabel">RFC Numbers:</td><td class="iprdata">{{ ipr.rfclist }}</td></tr>
{% else %}
{% for doc in ipr.rfcs.all %}
<tr class="{% cycle row_parity %}"><td class="iprlabel iprdata">RFC {{ doc.document.rfc_number }}:</td><td class="iprdata">"{{ doc.document.title }}"</td></tr>
{% for iprdocalias in ipr.rfcs %}
<tr class="{% cycle row_parity %}"><td class="iprlabel iprdata">RFC {{ iprdocalias.doc_alias.document.rfc_number }}:</td><td class="iprdata">"{{ iprdocalias.doc_alias.document.title }}"</td></tr>
{% endfor %}
{% endif %}
{% if ipr.draftlist %}
<tr class="{% cycle row_parity %}"><td class="iprlabel">I-D Filenames (draft-...):</td><td class="iprdata">{{ ipr.draftlist }}</td></tr>
{% else %}
{% for doc in ipr.drafts.all %}
<tr class="{% cycle row_parity %}"><td class="iprlabel">Internet-Draft:</td><td class="iprdata">"{{ doc.document.title }}"<br />({{ doc.document.filename }}{% if doc.revision %}-{{ doc.revision }}{% endif %})</td></tr>
{% for iprdocalias in ipr.drafts %}
<tr class="{% cycle row_parity %}"><td class="iprlabel">Internet-Draft:</td><td class="iprdata">"{{ iprdocalias.doc_alias.document.title }}"<br />({{ iprdocalias.doc_alias.name }}{% if iprdocalias.rev %}-{{ iprdocalias.rev }}{% endif %})</td></tr>
{% endfor %}
{% endif %}
{% if ipr.other_designations %}

View file

@ -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 %}

View file

@ -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.</p>
<p><a href="{% url ietf.ipr.views.default %}">Click here to submit an IPR disclosure</a></p>
<p><a href="{% url ietf.ipr.views.about %}">Click here to submit an IPR disclosure</a></p>
<a href="{% url ietf.ipr.search.search %}">Search the IPR Disclosures</a>

View file

@ -3,17 +3,17 @@
<td>{{ ipr.submitted_date }}</td>
<td>{{ ipr.ipr_id }}</td>
<td>
{% ifequal ipr.status 1 %}
{% if ipr.status == 1 %}
<a href="{% url ietf.ipr.views.show ipr.ipr_id %}">{{ ipr.title|escape }}</a>
{% else %}
{{ ipr.title|escape }}
<br/>This IPR disclosure was removed at the request of the submitter.
{% endifequal %}
{% endif %}
<br />
{% for item in ipr.updates.all %}
{% ifequal item.updated.status 1 %}
{% if item.updated.status == 1 %}
Updates ID <a href="{% url ietf.ipr.views.show item.updated.ipr_id %}">#{{ item.updated.ipr_id }}</a>.<br/>
{% endifequal %}
{% endif %}
{% endfor %}
{% for item in ipr.updated_by.all %}
{% if item.processed == 1 and item.ipr.status != 2 %}
@ -22,7 +22,7 @@
{% endfor %}
</td>
</tr>
{% ifequal ipr.status 1 %}
{% if ipr.status == 1 %}
{% if ipr.legacy_title_1 %}
<tr class="{{ forloop.counter|divisibleby:2|yesno:"oddrow,evenrow" }}">
<td></td>
@ -43,4 +43,4 @@
</td>
</tr>
{% endif %}
{% endifequal %}
{% endif %}

View file

@ -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 %}
<h1>{{ ipr.title|escape }}</h1>
<h1>{{ ipr.title }}</h1>
<font size="3">
This IPR disclosure was removed at the submitter's request.

View file

@ -11,12 +11,12 @@ label { float:left; width: 200px; }
<h1>IPR Search</h1>
<h2>Document Search</h2>
<div class="ietf-box search-form-box">
<form method="get">
<form>
<input type="hidden" name="option" value="document_search">
<label>I-D filename (draft-...):</label>
<input type="text" name="document_search" size="30">
<input type="submit" value="SEARCH" >
<label>I-D name (draft-...):</label>
<input type="text" name="document_search" size="30">
<input type="submit" value="SEARCH" >
</form>
<script language="javascript"><!--
@ -49,7 +49,7 @@ label { float:left; width: 200px; }
}
// -->
</script>
<form name="form_rfc_search" method="get">
<form name="form_rfc_search">
<input type="hidden" name="option" value="rfc_search">
<label>RFC Number:</label>
<input type="text" name="rfc_search" size="8">
@ -61,13 +61,13 @@ label { float:left; width: 200px; }
<div class="ietf-box search_form_box">
<form method="get">
<form>
<input type="hidden" name="option" value="patent_search">
<label>Name of patent owner/applicant:</label>
<input type="text" name="patent_search" size="30">
<input type="submit" value="SEARCH">
</form>
<form method="get">
<form>
<input type="hidden" name="option" value="patent_info_search"/>
<label>Characters in patent information (Full/Partial):</label>
<input type="text" name="patent_info_search" size="30"/>
@ -75,7 +75,7 @@ label { float:left; width: 200px; }
</form>
<font size="-1" color="red">* The search string must contain at least three characters, including at least one digit, and include punctuation marks. For best results, please enter the entire string, or as much of it as possible.</font>
<form method="get">
<form>
<input type="hidden" name="option" value="wg_search">
<label>Working group name:</label>
<select name="wg_search">
@ -85,13 +85,13 @@ label { float:left; width: 200px; }
</select>
<input type="submit" value="SEARCH" width="15">
</form>
<form method="get">
<form>
<input type="hidden" name="option" value="title_search"/>
<label>Words in document title:</label>
<input type="text" name="title_search" size="30" />
<input type="submit" value="SEARCH" />
</form>
<form method="get">
<form>
<input type="hidden" name="option" value="ipr_title_search" />
<label>Words in IPR disclosure title:</label>
<input type="text" name="ipr_title_search" size="30" />

View file

@ -18,8 +18,8 @@
<tbody bgcolor="#{% cycle dadada,eaeaea as bgcolor %}">
<tr >
<td colspan="3">
Search result on {{ doc.name|rfcspace|lstrip:"0"|rfcnospace }}, "{{ doc.document.title|escape }}"{% ifnotequal doc first %}{% if doc.related %}, that was {{ doc.relation|lower }} {{ doc.related.source|rfcspace|lstrip:"0"|rfcnospace }}, "{{ doc.related.source.title }}"{% endif %}
{% endifnotequal %}
Search result on {{ doc.name|rfcspace|lstrip:"0"|rfcnospace }}, "{{ doc.document.title|escape }}"{% if not forloop.first %}{% if doc.related %}, that was {{ doc.relation|lower }} {{ doc.related.source|rfcspace|lstrip:"0"|rfcnospace }}, "{{ doc.related.source.title }}"{% endif %}
{% endif %}
</td>
</tr>
{% if doc.iprs %}
@ -35,7 +35,7 @@
<td></td>
<td colspan="2">
No IPR disclosures have been submitted directly on <i>{{ doc.name|rfcspace|lstrip:"0" }}</i>{% if iprs %},
but there are disclosures on {% ifequal docs|length 2 %}a related document{% else %}related documents{% endifequal %}, listed on this page{% endif %}.
but there are disclosures on {% if docs|length == 2 %}a related document{% else %}related documents{% endif %}, listed on this page{% endif %}.
</b>
</td>
</tr>

View file

@ -23,16 +23,18 @@
<tr valign="top">
<td colspan="3">
{% block intro_prefix %}IPR that was submitted by <b><i>{{ q }}</i></b>, and{% endblock %}
{% block related %}
{% if not ipr.docs %}
is not related to a specific IETF contribution.
{% else %}
is related to
{% for item in ipr.docs %}
{% ifequal item ipr.last_draft %}<b> and </b>{% endifequal %}
<b><i>{{ item.document }}, "{{ item.document.title|escape }},"</i></b>{% if item.document.related %}, {{ item.document.relation }} {{ item.document.related }}, "{{ item.document.related.title|escape }}"{% endif %}
{% endfor %}
{% endif %}
{% block related %}
{% with ipr.docs as docs %}
{% if not docs %}
is not related to a specific IETF contribution.
{% else %}
is related to
{% for item in docs %}
{% if forloop.last and forloop.counter > 1 %}<b>and</b>{% endif %}
<b><i>{{ item.document }}, "{{ item.document.title|escape }},"</i></b>{% if item.document.related %}, {{ item.document.relation }} {{ item.document.related }}, "{{ item.document.related.title|escape }}"{% endif %}
{% endfor %}
{% endif %}
{% endwith %}
{% endblock %}
{% block intro_suffix %}{% endblock %}
</td>

View file

@ -31,9 +31,9 @@
<td width="90"><li>ID # {{ ipr.ipr_id }}</li></td>
<td>
{% for item in ipr.updates.all %}
{% ifequal item.updated.status 1 %}
{% if item.updated.status == 1 %}
IPR disclosure ID# {{ item.updated.ipr_id }}, "<a href="{% url ietf.ipr.views.show item.updated.ipr_id %}">{{ item.updated.title|escape }}</a>" Updated by
{% endifequal %}
{% endif %}
{% endfor %}
<a href="{% url ietf.ipr.views.show ipr.ipr_id %}">"{{ ipr.title|escape }}"</a>
</td>