Skip to content

Commit 9a3f6b0

Browse files
committed
Merged Django-1.8 upgrade work to trunk. Adjusted migration names, and added migrations as necessary. Fixed some instances of broken html.
- Legacy-Id: 12507
2 parents d5aa5d2 + 03d9016 commit 9a3f6b0

42 files changed

Lines changed: 431 additions & 530 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

bin/test-crawl

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,18 +43,20 @@ os.environ.setdefault("DJANGO_SETTINGS_MODULE", args.settings or "ietf.settings_
4343
import django
4444
import django.test
4545
import django.core.checks
46+
from django.conf import settings
4647

4748
django.setup()
4849

50+
4951
# This needs to come after we set up sys path to include the local django
5052
import debug # pyflakes:ignore
5153

5254
# prevent memory from leaking when settings.DEBUG=True
53-
from django.db import connection
54-
class DontSaveQueries(object):
55-
def append(self, x):
56-
pass
57-
connection.queries = DontSaveQueries()
55+
# from django.db import connection
56+
# class DontSaveQueries(list):
57+
# def append(self, x):
58+
# pass
59+
# connection.queries = DontSaveQueries()
5860

5961
from ietf.name.models import DocTypeName
6062

@@ -284,6 +286,13 @@ if __name__ == "__main__":
284286

285287
# Run django system checks and checks from ietf.checks:
286288
error_list = django.core.checks.run_checks()
289+
silenced = []
290+
for i in range(len(error_list)):
291+
if error_list[i].id in settings.SILENCED_SYSTEM_CHECKS:
292+
silenced.append(i)
293+
silenced.sort(reverse=True)
294+
for i in silenced:
295+
del error_list[i]
287296
if error_list:
288297
print("")
289298
for entry in error_list:

changelog

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ ietfdb (6.39.1) ietf; urgency=medium
4343
populate the review documents. Fixes #2064. Will patch into production.
4444

4545
* Added more document information to the personal profile pages at
46-
/person/<full name>, after a suggestion from Benoit Claise. Fixes issue
46+
/person/$FULL_NAME, after a suggestion from Benoit Claise. Fixes issue
4747
#2066.
4848

4949
* Added new display columns to the reviewer settings admin page.

env/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,4 @@
55
/local
66
/lib
77
/include
8+
/pip-selfcheck.json

ietf/dbtemplate/template.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
from docutils.utils import SystemMessage
55
import debug # pyflakes:ignore
66

7-
from django.template import Template as DjangoTemplate, TemplateDoesNotExist, TemplateEncodingError
7+
from django.template.base import Template as DjangoTemplate, TemplateDoesNotExist, TemplateEncodingError
88
from django.template.loader import BaseLoader
99
from django.utils.encoding import smart_unicode
1010

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# -*- coding: utf-8 -*-
2+
from __future__ import unicode_literals
3+
4+
from django.db import migrations, models
5+
6+
7+
class Migration(migrations.Migration):
8+
9+
dependencies = [
10+
('doc', '0018_auto_20161209_0421'),
11+
]
12+
13+
operations = [
14+
migrations.AlterField(
15+
model_name='docevent',
16+
name='type',
17+
field=models.CharField(max_length=50, choices=[(b'new_revision', b'Added new revision'), (b'new_submission', b'Uploaded new revision'), (b'changed_document', b'Changed document metadata'), (b'added_comment', b'Added comment'), (b'added_message', b'Added message'), (b'deleted', b'Deleted document'), (b'changed_state', b'Changed state'), (b'changed_stream', b'Changed document stream'), (b'expired_document', b'Expired document'), (b'extended_expiry', b'Extended expiry of document'), (b'requested_resurrect', b'Requested resurrect'), (b'completed_resurrect', b'Completed resurrect'), (b'changed_consensus', b'Changed consensus'), (b'published_rfc', b'Published RFC'), (b'added_suggested_replaces', b'Added suggested replacement relationships'), (b'reviewed_suggested_replaces', b'Reviewed suggested replacement relationships'), (b'changed_group', b'Changed group'), (b'changed_protocol_writeup', b'Changed protocol writeup'), (b'changed_charter_milestone', b'Changed charter milestone'), (b'initial_review', b'Set initial review time'), (b'changed_review_announcement', b'Changed WG Review text'), (b'changed_action_announcement', b'Changed WG Action text'), (b'started_iesg_process', b'Started IESG process on document'), (b'created_ballot', b'Created ballot'), (b'closed_ballot', b'Closed ballot'), (b'sent_ballot_announcement', b'Sent ballot announcement'), (b'changed_ballot_position', b'Changed ballot position'), (b'changed_ballot_approval_text', b'Changed ballot approval text'), (b'changed_ballot_writeup_text', b'Changed ballot writeup text'), (b'changed_rfc_editor_note_text', b'Changed RFC Editor Note text'), (b'changed_last_call_text', b'Changed last call text'), (b'requested_last_call', b'Requested last call'), (b'sent_last_call', b'Sent last call'), (b'scheduled_for_telechat', b'Scheduled for telechat'), (b'iesg_approved', b'IESG approved document (no problem)'), (b'iesg_disapproved', b'IESG disapproved document (do not publish)'), (b'approved_in_minute', b'Approved in minute'), (b'iana_review', b'IANA review comment'), (b'rfc_in_iana_registry', b'RFC is in IANA registry'), (b'rfc_editor_received_announcement', b'Announcement was received by RFC Editor'), (b'requested_publication', b'Publication at RFC Editor requested'), (b'sync_from_rfc_editor', b'Received updated information from RFC Editor'), (b'requested_review', b'Requested review'), (b'assigned_review_request', b'Assigned review request'), (b'closed_review_request', b'Closed review request')]),
18+
),
19+
migrations.AlterField(
20+
model_name='dochistory',
21+
name='tags',
22+
field=models.ManyToManyField(to='name.DocTagName', blank=True),
23+
),
24+
migrations.AlterField(
25+
model_name='document',
26+
name='tags',
27+
field=models.ManyToManyField(to='name.DocTagName', blank=True),
28+
),
29+
]

ietf/doc/models.py

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import datetime, os
44

55
from django.db import models
6+
from django.core import checks
67
from django.core.exceptions import ValidationError
78
from django.core.urlresolvers import reverse as urlreverse
89
from django.core.validators import URLValidator
@@ -26,6 +27,20 @@ class StateType(models.Model):
2627
def __unicode__(self):
2728
return self.slug
2829

30+
@checks.register('db-consistency')
31+
def check_statetype_slugs(app_configs, **kwargs):
32+
errors = []
33+
state_type_slugs = [ t.slug for t in StateType.objects.all() ]
34+
for type in DocTypeName.objects.all():
35+
if not type.slug in state_type_slugs:
36+
errors.append(checks.Error(
37+
"The document type '%s (%s)' does not have a corresponding entry in the doc.StateType table" % (type.name, type.slug),
38+
hint="You should add a doc.StateType entry with a slug '%s' to match the DocTypeName slug."%(type.slug),
39+
obj=type,
40+
id='datatracker.doc.E0015',
41+
))
42+
return errors
43+
2944
class State(models.Model):
3045
type = models.ForeignKey(StateType)
3146
slug = models.SlugField()
@@ -53,7 +68,7 @@ class DocumentInfo(models.Model):
5368
title = models.CharField(max_length=255)
5469

5570
states = models.ManyToManyField(State, blank=True) # plain state (Active/Expired/...), IESG state, stream state
56-
tags = models.ManyToManyField(DocTagName, blank=True, null=True) # Revised ID Needed, ExternalParty, AD Followup, ...
71+
tags = models.ManyToManyField(DocTagName, blank=True) # Revised ID Needed, ExternalParty, AD Followup, ...
5772
stream = models.ForeignKey(StreamName, blank=True, null=True) # IETF, IAB, IRTF, Independent Submission
5873
group = models.ForeignKey(Group, blank=True, null=True) # WG, RG, IAB, IESG, Edu, Tools
5974

@@ -277,7 +292,7 @@ def relations_that(self, relationship):
277292
if isinstance(self, Document):
278293
return RelatedDocument.objects.filter(target__document=self, relationship__in=relationship).select_related('source')
279294
elif isinstance(self, DocHistory):
280-
return RelatedDocHistory.objects.filter(target__document=self, relationship__in=relationship).select_related('source')
295+
return RelatedDocHistory.objects.filter(target__document=self.doc, relationship__in=relationship).select_related('source')
281296
else:
282297
return RelatedDocument.objects.none()
283298

ietf/doc/templatetags/ietf_filters.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
from ietf.utils.text import fill
1414
from django import template
1515
from django.conf import settings
16-
from django.utils.html import escape, fix_ampersands
16+
from django.utils.html import escape
1717
from django.template.defaultfilters import truncatewords_html, linebreaksbr, stringfilter, striptags, urlize
1818
from django.template import resolve_variable
1919
from django.utils.safestring import mark_safe, SafeData
@@ -69,7 +69,7 @@ def parse_email_list(value):
6969
(name, email) = parseaddr(addr)
7070
if not(name):
7171
name = email
72-
ret.append('<a href="mailto:%s">%s</a>' % ( fix_ampersands(email), escape(name) ))
72+
ret.append('<a href="mailto:%s">%s</a>' % ( email.replace('&', '&amp;'), escape(name) ))
7373
return mark_safe(", ".join(ret))
7474
else:
7575
return value

ietf/doc/utils_search.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ def fill_in_document_table_attributes(docs):
1212
docs_dict = dict((d.pk, d) for d in docs)
1313
doc_ids = docs_dict.keys()
1414

15-
rfc_aliases = dict(DocAlias.objects.filter(name__startswith="rfc", document__in=doc_ids).values_list("document_id", "name"))
15+
rfc_aliases = dict(DocAlias.objects.filter(name__startswith="rfc", document__in=doc_ids).values_list("document", "name"))
1616

1717
# latest event cache
1818
event_types = ("published_rfc",
@@ -79,9 +79,9 @@ def fill_in_document_table_attributes(docs):
7979
d.updated_by_list = []
8080

8181
xed_by = RelatedDocument.objects.filter(target__name__in=rfc_aliases.values(),
82-
relationship__in=("obs", "updates")).select_related('target__document_id')
82+
relationship__in=("obs", "updates")).select_related('target__document')
8383
rel_rfc_aliases = dict(DocAlias.objects.filter(name__startswith="rfc",
84-
document__in=[rel.source_id for rel in xed_by]).values_list('document_id', 'name'))
84+
document__in=[rel.source_id for rel in xed_by]).values_list('document', 'name'))
8585
for rel in xed_by:
8686
d = docs_dict[rel.target.document_id]
8787
if rel.relationship_id == "obs":
@@ -101,7 +101,7 @@ def prepare_document_table(request, docs, query=None, max_results=500):
101101
if not isinstance(docs, list):
102102
# evaluate and fill in attribute results immediately to decrease
103103
# the number of queries
104-
docs = docs.select_related("ad", "ad__person", "std_level", "intended_std_level", "group", "stream")
104+
docs = docs.select_related("ad", "std_level", "intended_std_level", "group", "stream")
105105
docs = docs.prefetch_related("states__type", "tags", "groupmilestone_set__group", "reviewrequest_set__team")
106106

107107
docs = list(docs[:max_results])

ietf/doc/views_material.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ class UploadMaterialForm(forms.Form):
3838
def __init__(self, doc_type, action, group, doc, *args, **kwargs):
3939
super(UploadMaterialForm, self).__init__(*args, **kwargs)
4040

41-
self.fields["state"].queryset = self.fields["state"].queryset.filter(type=doc_type)
41+
self.fields["state"].queryset = self.fields["state"].queryset.filter(type__slug=doc_type.slug)
4242

4343
self.doc_type = doc_type
4444
self.action = action

ietf/doc/views_stats.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ def model_to_timeline_data(model, field='time', **kwargs):
3636
a JsonResponse() argument. The model must have a DateTimeField field.
3737
If the time field is named something else than 'time', the name must
3838
be supplied."""
39-
assert field in model._meta.get_all_field_names()
39+
assert field in [ f.name for f in model._meta.get_fields() ]
4040

4141
objects = ( model.objects.filter(**kwargs)
4242
.order_by('date')

0 commit comments

Comments
 (0)