Skip to content

Commit c71f1d9

Browse files
committed
Added redesign work-in-progress
- Legacy-Id: 2686
1 parent 443f417 commit c71f1d9

27 files changed

Lines changed: 1871 additions & 30 deletions

django/shortcuts/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,4 +98,4 @@ def get_list_or_404(klass, *args, **kwargs):
9898
obj_list = list(queryset.filter(*args, **kwargs))
9999
if not obj_list:
100100
raise Http404('No %s matches the given query.' % queryset.model._meta.object_name)
101-
return obj_list
101+
return obj_list

ietf/idrfc/idrfc_wrapper.py

Lines changed: 58 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
from datetime import date
3737
from django.utils import simplejson as json
3838
from django.db.models import Q
39+
from django.conf import settings
3940
import types
4041

4142
BALLOT_ACTIVE_STATES = ['In Last Call',
@@ -602,8 +603,64 @@ def ballot_set_other(self):
602603
return []
603604
else:
604605
return self._ballot_set.exclude(draft=self._idinternal)
605-
606+
606607
def _init(self):
608+
if not settings.USE_DB_REDESIGN_PROXY_CLASSES:
609+
self.old_init()
610+
return
611+
612+
from redesign.person.models import Email
613+
active_ads = Email.objects.filter(role__name="ad", role__group__state="active")
614+
615+
positions = []
616+
seen = {}
617+
618+
for pos in self.ballot.event_set.filter(type="changed_ballot_position").select_related('pos', 'ad').order_by("-time", '-id'):
619+
pos = pos.ballotposition
620+
if pos.ad not in seen:
621+
p = dict(ad_name=pos.ad.get_name(),
622+
ad_username="", # FIXME: don't seem to have username at the moment
623+
position=pos.pos.name,
624+
is_old_ad=pos.ad in active_ads,
625+
old_positions=[])
626+
627+
if pos.pos.slug == "discuss":
628+
p["has_text"] = True
629+
p["discuss_text"] = pos.discuss
630+
p["discuss_date"] = pos.discuss_time
631+
p["discuss_revision"] = pos.doc.rev # FIXME: wrong
632+
633+
if pos.comment:
634+
p["has_text"] = True
635+
p["comment_text"] = pos.comment
636+
p["comment_date"] = pos.comment_time
637+
p["comment_revision"] = pos.doc.rev # FIXME: wrong
638+
639+
positions.append(p)
640+
seen[pos.ad] = p
641+
else:
642+
latest = seen[pos.ad]
643+
if latest["old_positions"]:
644+
prev = latest["old_positions"][-1]
645+
else:
646+
prev = latest["position"]
647+
648+
if prev != pos.pos.name:
649+
seen[pos.ad]["old_positions"].append(pos.pos.name)
650+
651+
# add any missing ADs as No Record
652+
if self.ballot_active:
653+
for ad in active_ads:
654+
if ad not in seen:
655+
d = dict(ad_name=ad.get_name(),
656+
ad_username="", # FIXME: don't seem to have username at the moment
657+
position="No Record",
658+
)
659+
positions.append(d)
660+
661+
self._positions = positions
662+
663+
def old_init(self):
607664
try:
608665
ads = set()
609666
except NameError:

ietf/idrfc/views_doc.py

Lines changed: 25 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -147,21 +147,32 @@ def document_main(request, name):
147147
# doc is either IdWrapper or RfcWrapper
148148
def _get_history(doc, versions):
149149
results = []
150-
if doc.is_id_wrapper:
151-
comments = DocumentComment.objects.filter(document=doc.tracker_id).exclude(rfc_flag=1)
150+
if settings.USE_DB_REDESIGN_PROXY_CLASSES:
151+
for e in doc._draft.event_set.all().select_related('by').order_by('-time'):
152+
info = {}
153+
info['text'] = e.desc
154+
info['by'] = e.by.get_name()
155+
info['textSnippet'] = truncatewords_html(format_textarea(fill(info['text'], 80)), 25)
156+
info['snipped'] = info['textSnippet'][-3:] == "..."
157+
e.version = e.doc.rev
158+
results.append({'comment':e, 'info':info, 'date':e.time, 'is_com':True})
152159
else:
153-
comments = DocumentComment.objects.filter(document=doc.rfc_number,rfc_flag=1)
154-
if len(comments) > 0:
155-
# also include rfc_flag=NULL, but only if at least one
156-
# comment with rfc_flag=1 exists (usually NULL means same as 0)
157-
comments = DocumentComment.objects.filter(document=doc.rfc_number).exclude(rfc_flag=0)
158-
for comment in comments.order_by('-date','-time','-id').filter(public_flag=1).select_related('created_by'):
159-
info = {}
160-
info['text'] = comment.comment_text
161-
info['by'] = comment.get_fullname()
162-
info['textSnippet'] = truncatewords_html(format_textarea(fill(info['text'], 80)), 25)
163-
info['snipped'] = info['textSnippet'][-3:] == "..."
164-
results.append({'comment':comment, 'info':info, 'date':comment.datetime(), 'is_com':True})
160+
if doc.is_id_wrapper:
161+
comments = DocumentComment.objects.filter(document=doc.tracker_id).exclude(rfc_flag=1)
162+
else:
163+
comments = DocumentComment.objects.filter(document=doc.rfc_number,rfc_flag=1)
164+
if len(comments) > 0:
165+
# also include rfc_flag=NULL, but only if at least one
166+
# comment with rfc_flag=1 exists (usually NULL means same as 0)
167+
comments = DocumentComment.objects.filter(document=doc.rfc_number).exclude(rfc_flag=0)
168+
for comment in comments.order_by('-date','-time','-id').filter(public_flag=1).select_related('created_by'):
169+
info = {}
170+
info['text'] = comment.comment_text
171+
info['by'] = comment.get_fullname()
172+
info['textSnippet'] = truncatewords_html(format_textarea(fill(info['text'], 80)), 25)
173+
info['snipped'] = info['textSnippet'][-3:] == "..."
174+
results.append({'comment':comment, 'info':info, 'date':comment.datetime(), 'is_com':True})
175+
165176
if doc.is_id_wrapper and versions:
166177
for v in versions:
167178
if v['draft_name'] == doc.draft_name:

ietf/idtracker/admin.py

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,17 @@
11
#coding: utf-8
22
from django.contrib import admin
3+
from django.conf import settings
34
from ietf.idtracker.models import *
4-
5-
class AcronymAdmin(admin.ModelAdmin):
6-
list_display=('acronym', 'name')
7-
admin.site.register(Acronym, AcronymAdmin)
85

9-
class AreaAdmin(admin.ModelAdmin):
10-
list_display=('area_acronym', 'status')
11-
admin.site.register(Area, AreaAdmin)
6+
if not settings.USE_DB_REDESIGN_PROXY_CLASSES:
7+
class AcronymAdmin(admin.ModelAdmin):
8+
list_display=('acronym', 'name')
9+
admin.site.register(Acronym, AcronymAdmin)
10+
11+
if not settings.USE_DB_REDESIGN_PROXY_CLASSES:
12+
class AreaAdmin(admin.ModelAdmin):
13+
list_display=('area_acronym', 'status')
14+
admin.site.register(Area, AreaAdmin)
1215

1316
class AreaDirectorAdmin(admin.ModelAdmin):
1417
raw_id_fields=['person']
@@ -96,12 +99,13 @@ class IRTFAdmin(admin.ModelAdmin):
9699
pass
97100
admin.site.register(IRTF, IRTFAdmin)
98101

99-
class InternetDraftAdmin(admin.ModelAdmin):
100-
list_display=('filename', 'revision', 'title', 'status')
101-
search_fields=['filename', 'title']
102-
list_filter=['status']
103-
raw_id_fields=['replaced_by']
104-
admin.site.register(InternetDraft, InternetDraftAdmin)
102+
if not settings.USE_DB_REDESIGN_PROXY_CLASSES:
103+
class InternetDraftAdmin(admin.ModelAdmin):
104+
list_display=('filename', 'revision', 'title', 'status')
105+
search_fields=['filename', 'title']
106+
list_filter=['status']
107+
raw_id_fields=['replaced_by']
108+
admin.site.register(InternetDraft, InternetDraftAdmin)
105109

106110
class PersonOrOrgInfoAdmin(admin.ModelAdmin):
107111
fieldsets=((None, {'fields': (('first_name', 'middle_initial', 'last_name'), ('name_suffix', 'modified_by'))}), ('Obsolete Info', {'fields': ('record_type', 'created_by', 'address_type'), 'classes': 'collapse'}))

ietf/idtracker/models.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1087,6 +1087,11 @@ class DocumentWrapper(object):
10871087
def __init__(self, document):
10881088
self.document = document
10891089

1090+
if settings.USE_DB_REDESIGN_PROXY_CLASSES:
1091+
from redesign.doc.proxy import InternetDraft
1092+
from redesign.group.proxy import Area
1093+
from redesign.group.proxy import Acronym
1094+
10901095

10911096
# changes done by convert-096.py:changed maxlength to max_length
10921097
# removed core

ietf/settings.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,12 @@
88
import syslog
99
syslog.openlog("django", syslog.LOG_PID, syslog.LOG_LOCAL0)
1010

11-
1211
BASE_DIR = os.path.dirname(os.path.abspath(__file__))
1312

13+
import sys
14+
sys.path.append(os.path.abspath(BASE_DIR + "/.."))
15+
sys.path.append(os.path.abspath(BASE_DIR + "/../redesign"))
16+
1417
DEBUG = True
1518
TEMPLATE_DEBUG = DEBUG
1619

@@ -118,6 +121,11 @@
118121
'django.contrib.admin',
119122
'django.contrib.humanize',
120123
'south',
124+
'redesign.person',
125+
'redesign.name',
126+
'redesign.group',
127+
'redesign.doc',
128+
'redesign.issue',
121129
'ietf.announcements',
122130
'ietf.idindex',
123131
'ietf.idtracker',
@@ -187,6 +195,9 @@
187195
LIAISON_ATTACH_PATH = '/a/www/ietf-datatracker/documents/LIAISON/'
188196
LIAISON_ATTACH_URL = '/documents/LIAISON/'
189197

198+
# DB redesign
199+
USE_DB_REDESIGN_PROXY_CLASSES=True
200+
190201
# Put SECRET_KEY in here, or any other sensitive or site-specific
191202
# changes. DO NOT commit settings_local.py to svn.
192203
from settings_local import *

redesign/__init__.py

Whitespace-only changes.

redesign/doc/__init__.py

Whitespace-only changes.

redesign/doc/admin.py

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
from django.contrib import admin
2+
from models import *
3+
from person.models import *
4+
5+
class RelatedDocAdmin(admin.ModelAdmin):
6+
list_display = ["source", "relationship", "target"]
7+
search_fields = ["doc_alias__name", "related_document_set__name", ]
8+
list_display_links = ["relationship", ]
9+
admin.site.register(RelatedDoc, RelatedDocAdmin)
10+
11+
class DocumentAdmin(admin.ModelAdmin):
12+
list_display = ['name', 'rev', 'state', 'group', 'pages', 'intended_std_level', 'author_list', 'time']
13+
search_fields = ['name']
14+
raw_id_fields = ['authors', 'related', 'group', 'shepherd', 'ad']
15+
admin.site.register(Document, DocumentAdmin)
16+
17+
class DocHistoryAdmin(admin.ModelAdmin):
18+
list_display = ['doc', 'rev', 'state', 'group', 'pages', 'intended_std_level', 'author_list', 'time']
19+
search_fields = ['doc__name']
20+
ordering = ['time', 'doc', 'rev']
21+
raw_id_fields = ['authors', 'related']
22+
admin.site.register(DocHistory, DocHistoryAdmin)
23+
24+
class DocAliasAdmin(admin.ModelAdmin):
25+
list_display = [ 'name', 'document_link', ]
26+
search_fields = [ 'name', 'document__name', ]
27+
admin.site.register(DocAlias, DocAliasAdmin)
28+
29+
class SendQueueAdmin(admin.ModelAdmin):
30+
pass
31+
admin.site.register(SendQueue, SendQueueAdmin)
32+
33+
34+
# events
35+
36+
class EventAdmin(admin.ModelAdmin):
37+
raw_id_fields = ["doc", "by"]
38+
admin.site.register(Event, EventAdmin)
39+
40+
admin.site.register(Message, EventAdmin)
41+
admin.site.register(Text, EventAdmin)
42+
admin.site.register(BallotPosition, EventAdmin)
43+
admin.site.register(Expiration, EventAdmin)
44+
admin.site.register(Telechat, EventAdmin)
45+

0 commit comments

Comments
 (0)