Skip to content

Commit e9638cb

Browse files
committed
Port IPR module to new schema, remove some cruft
- Legacy-Id: 6774
1 parent f7bed5d commit e9638cb

22 files changed

Lines changed: 193 additions & 497 deletions

ietf/doc/proxy.py

Lines changed: 44 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -714,7 +714,6 @@ def all(self):
714714

715715
@property
716716
def ipr(self):
717-
from ietf.ipr.models import IprDraftProxy
718717
return IprDraftProxy.objects.filter(doc_alias__document=self.pk)
719718

720719
class Meta:
@@ -888,7 +887,6 @@ def filename(self):
888887

889888
@property
890889
def ipr(self):
891-
from ietf.ipr.models import IprDraftProxy
892890
return IprDraftProxy.objects.filter(doc_alias=self.pk)
893891

894892
class Meta:
@@ -996,3 +994,47 @@ class Meta:
996994
proxy = True
997995

998996

997+
998+
999+
# proxy stuff for ipr
1000+
from ietf.ipr.models import IprDocAlias
1001+
1002+
class IprDraftProxy(IprDocAlias):
1003+
objects = TranslatingManager(dict(document="doc_alias__name"))
1004+
1005+
# document = models.ForeignKey(InternetDraft, db_column='id_document_tag', "ipr")
1006+
# document = models.ForeignKey(Rfc, db_column='rfc_number', related_name="ipr")
1007+
@property
1008+
def document(self):
1009+
from ietf.doc.proxy import DraftLikeDocAlias
1010+
return DraftLikeDocAlias.objects.get(pk=self.doc_alias_id)
1011+
1012+
#revision = models.CharField(max_length=2)
1013+
@property
1014+
def revision(self):
1015+
return self.rev
1016+
1017+
class Meta:
1018+
proxy = True
1019+
1020+
IprDraft = IprDraftProxy
1021+
1022+
class IprRfcProxy(IprDocAlias):
1023+
objects = TranslatingManager(dict(document=lambda v: ("doc_alias__name", "rfc%s" % v)))
1024+
1025+
# document = models.ForeignKey(InternetDraft, db_column='id_document_tag', "ipr")
1026+
# document = models.ForeignKey(Rfc, db_column='rfc_number', related_name="ipr")
1027+
@property
1028+
def document(self):
1029+
from ietf.doc.proxy import DraftLikeDocAlias
1030+
return DraftLikeDocAlias.objects.get(pk=self.doc_alias_id)
1031+
1032+
#revision = models.CharField(max_length=2)
1033+
@property
1034+
def revision(self):
1035+
return self.rev
1036+
1037+
class Meta:
1038+
proxy = True
1039+
1040+
IprRfc = IprRfcProxy

ietf/ipr/__init__.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
1-
# Copyright The IETF Trust 2007, All Rights Reserved
21

ietf/ipr/admin.py

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,20 @@ class IprContactAdmin(admin.ModelAdmin):
88
admin.site.register(IprContact, IprContactAdmin)
99

1010
class IprDetailAdmin(admin.ModelAdmin):
11-
list_display = ['title', 'submitted_date', 'docs', ]
12-
search_fields = ['title', 'legal_name', ]
11+
list_display = ['title', 'submitted_date', 'docs', 'status']
12+
search_fields = ['title', 'legal_name']
13+
14+
def docs(self, ipr):
15+
res = []
16+
for iprdocalias in IprDocAlias.objects.filter(ipr=ipr).order_by("id").select_related("doc_alias"):
17+
if iprdocalias.doc_alias.name.startswith("rfc"):
18+
n = iprdocalias.doc_alias.name.upper()
19+
elif iprdocalias.rev:
20+
n = iprdocalias.doc_alias.name + iprdocalias.rev
21+
else:
22+
n = iprdocalias.doc_alias.name
23+
res.append(n)
24+
return u", ".join(res)
1325
admin.site.register(IprDetail, IprDetailAdmin)
1426

1527
class IprLicensingAdmin(admin.ModelAdmin):

ietf/ipr/feeds.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ def item_pubdate(self, item):
2222
# though the database has only date, not time
2323
return datetime.combine(item.submitted_date, time(0,0,0))
2424
def item_author_name(self, item):
25-
s = item.get_submitter()
25+
s = item.get_submitter()
2626
if s:
2727
return s.name
2828
return None

ietf/ipr/models.py

Lines changed: 5 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
11
# Copyright The IETF Trust 2007, All Rights Reserved
22

33
from django.db import models
4-
from django.conf import settings
5-
from ietf.utils.lazy import reverse_lazy
64

7-
# ------------------------------------------------------------------------
8-
# Models
5+
from ietf.doc.models import DocAlias
6+
97

108
LICENSE_CHOICES = (
119
(1, 'a) No License Required for Implementers.'),
@@ -42,20 +40,14 @@ class IprSelecttype(models.Model):
4240
type_id = models.AutoField(primary_key=True)
4341
is_pending = models.IntegerField(unique=True, db_column="selecttype")
4442
type_display = models.CharField(blank=True, max_length=15)
45-
def __str__(self):
43+
def __unicode__(self):
4644
return self.type_display
47-
class Meta:
48-
if not settings.USE_DB_REDESIGN_PROXY_CLASSES:
49-
db_table = 'ipr_selecttype'
5045

5146
class IprLicensing(models.Model):
5247
licensing_option = models.AutoField(primary_key=True)
5348
value = models.CharField(max_length=255, db_column='licensing_option_value')
54-
def __str__(self):
49+
def __unicode__(self):
5550
return self.value;
56-
class Meta:
57-
if not settings.USE_DB_REDESIGN_PROXY_CLASSES:
58-
db_table = 'ipr_licensing'
5951

6052

6153
class IprDetail(models.Model):
@@ -115,17 +107,8 @@ class IprDetail(models.Model):
115107
submitted_date = models.DateField(blank=True)
116108
update_notified_date = models.DateField(null=True, blank=True)
117109

118-
def __str__(self):
119-
return self.title
120110
def __unicode__(self):
121-
if settings.USE_DB_REDESIGN_PROXY_CLASSES:
122-
# the latin-1 decode doesn't seem necessary anymore
123-
return self.title
124-
return self.title.decode("latin-1", 'replace')
125-
def docs(self):
126-
if settings.USE_DB_REDESIGN_PROXY_CLASSES:
127-
return list(IprDraftProxy.objects.filter(ipr=self))
128-
return list(self.drafts.all()) + list(self.rfcs.all())
111+
return self.title
129112
@models.permalink
130113
def get_absolute_url(self):
131114
return ('ietf.ipr.views.show', [str(self.ipr_id)])
@@ -173,8 +156,6 @@ class IprUpdate(models.Model):
173156
processed = models.IntegerField(null=True, blank=True)
174157

175158

176-
from ietf.doc.models import DocAlias
177-
178159
class IprDocAlias(models.Model):
179160
ipr = models.ForeignKey(IprDetail, related_name='documents')
180161
doc_alias = models.ForeignKey(DocAlias)
@@ -189,46 +170,3 @@ class Meta:
189170
verbose_name = "IPR document alias"
190171
verbose_name_plural = "IPR document aliases"
191172

192-
# proxy stuff
193-
194-
from ietf.utils.proxy import TranslatingManager
195-
196-
class IprDraftProxy(IprDocAlias):
197-
objects = TranslatingManager(dict(document="doc_alias__name"))
198-
199-
# document = models.ForeignKey(InternetDraft, db_column='id_document_tag', "ipr")
200-
# document = models.ForeignKey(Rfc, db_column='rfc_number', related_name="ipr")
201-
@property
202-
def document(self):
203-
from ietf.doc.proxy import DraftLikeDocAlias
204-
return DraftLikeDocAlias.objects.get(pk=self.doc_alias_id)
205-
206-
#revision = models.CharField(max_length=2)
207-
@property
208-
def revision(self):
209-
return self.rev
210-
211-
class Meta:
212-
proxy = True
213-
214-
IprDraft = IprDraftProxy
215-
216-
class IprRfcProxy(IprDocAlias):
217-
objects = TranslatingManager(dict(document=lambda v: ("doc_alias__name", "rfc%s" % v)))
218-
219-
# document = models.ForeignKey(InternetDraft, db_column='id_document_tag', "ipr")
220-
# document = models.ForeignKey(Rfc, db_column='rfc_number', related_name="ipr")
221-
@property
222-
def document(self):
223-
from ietf.doc.proxy import DraftLikeDocAlias
224-
return DraftLikeDocAlias.objects.get(pk=self.doc_alias_id)
225-
226-
#revision = models.CharField(max_length=2)
227-
@property
228-
def revision(self):
229-
return self.rev
230-
231-
class Meta:
232-
proxy = True
233-
234-
IprRfc = IprRfcProxy

0 commit comments

Comments
 (0)