Skip to content

Commit

Permalink
Merged Django-1.8 upgrade work to trunk. Adjusted migration names, an…
Browse files Browse the repository at this point in the history
…d added migrations as necessary. Fixed some instances of broken html.

 - Legacy-Id: 12507
  • Loading branch information
levkowetz committed Dec 13, 2016
2 parents d5aa5d2 + 03d9016 commit 9a3f6b0
Show file tree
Hide file tree
Showing 42 changed files with 431 additions and 530 deletions.
19 changes: 14 additions & 5 deletions bin/test-crawl
Expand Up @@ -43,18 +43,20 @@ os.environ.setdefault("DJANGO_SETTINGS_MODULE", args.settings or "ietf.settings_
import django
import django.test
import django.core.checks
from django.conf import settings

django.setup()


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

# prevent memory from leaking when settings.DEBUG=True
from django.db import connection
class DontSaveQueries(object):
def append(self, x):
pass
connection.queries = DontSaveQueries()
# from django.db import connection
# class DontSaveQueries(list):
# def append(self, x):
# pass
# connection.queries = DontSaveQueries()

from ietf.name.models import DocTypeName

Expand Down Expand Up @@ -284,6 +286,13 @@ if __name__ == "__main__":

# Run django system checks and checks from ietf.checks:
error_list = django.core.checks.run_checks()
silenced = []
for i in range(len(error_list)):
if error_list[i].id in settings.SILENCED_SYSTEM_CHECKS:
silenced.append(i)
silenced.sort(reverse=True)
for i in silenced:
del error_list[i]
if error_list:
print("")
for entry in error_list:
Expand Down
2 changes: 1 addition & 1 deletion changelog
Expand Up @@ -43,7 +43,7 @@ ietfdb (6.39.1) ietf; urgency=medium
populate the review documents. Fixes #2064. Will patch into production.

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

* Added new display columns to the reviewer settings admin page.
Expand Down
1 change: 1 addition & 0 deletions env/.gitignore
Expand Up @@ -5,3 +5,4 @@
/local
/lib
/include
/pip-selfcheck.json
2 changes: 1 addition & 1 deletion ietf/dbtemplate/template.py
Expand Up @@ -4,7 +4,7 @@
from docutils.utils import SystemMessage
import debug # pyflakes:ignore

from django.template import Template as DjangoTemplate, TemplateDoesNotExist, TemplateEncodingError
from django.template.base import Template as DjangoTemplate, TemplateDoesNotExist, TemplateEncodingError
from django.template.loader import BaseLoader
from django.utils.encoding import smart_unicode

Expand Down
29 changes: 29 additions & 0 deletions ietf/doc/migrations/0019_auto_20161207_1036.py
@@ -0,0 +1,29 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('doc', '0018_auto_20161209_0421'),
]

operations = [
migrations.AlterField(
model_name='docevent',
name='type',
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')]),
),
migrations.AlterField(
model_name='dochistory',
name='tags',
field=models.ManyToManyField(to='name.DocTagName', blank=True),
),
migrations.AlterField(
model_name='document',
name='tags',
field=models.ManyToManyField(to='name.DocTagName', blank=True),
),
]
19 changes: 17 additions & 2 deletions ietf/doc/models.py
Expand Up @@ -3,6 +3,7 @@
import datetime, os

from django.db import models
from django.core import checks
from django.core.exceptions import ValidationError
from django.core.urlresolvers import reverse as urlreverse
from django.core.validators import URLValidator
Expand All @@ -26,6 +27,20 @@ class StateType(models.Model):
def __unicode__(self):
return self.slug

@checks.register('db-consistency')
def check_statetype_slugs(app_configs, **kwargs):
errors = []
state_type_slugs = [ t.slug for t in StateType.objects.all() ]
for type in DocTypeName.objects.all():
if not type.slug in state_type_slugs:
errors.append(checks.Error(
"The document type '%s (%s)' does not have a corresponding entry in the doc.StateType table" % (type.name, type.slug),
hint="You should add a doc.StateType entry with a slug '%s' to match the DocTypeName slug."%(type.slug),
obj=type,
id='datatracker.doc.E0015',
))
return errors

class State(models.Model):
type = models.ForeignKey(StateType)
slug = models.SlugField()
Expand Down Expand Up @@ -53,7 +68,7 @@ class DocumentInfo(models.Model):
title = models.CharField(max_length=255)

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

Expand Down Expand Up @@ -277,7 +292,7 @@ def relations_that(self, relationship):
if isinstance(self, Document):
return RelatedDocument.objects.filter(target__document=self, relationship__in=relationship).select_related('source')
elif isinstance(self, DocHistory):
return RelatedDocHistory.objects.filter(target__document=self, relationship__in=relationship).select_related('source')
return RelatedDocHistory.objects.filter(target__document=self.doc, relationship__in=relationship).select_related('source')
else:
return RelatedDocument.objects.none()

Expand Down
4 changes: 2 additions & 2 deletions ietf/doc/templatetags/ietf_filters.py
Expand Up @@ -13,7 +13,7 @@
from ietf.utils.text import fill
from django import template
from django.conf import settings
from django.utils.html import escape, fix_ampersands
from django.utils.html import escape
from django.template.defaultfilters import truncatewords_html, linebreaksbr, stringfilter, striptags, urlize
from django.template import resolve_variable
from django.utils.safestring import mark_safe, SafeData
Expand Down Expand Up @@ -69,7 +69,7 @@ def parse_email_list(value):
(name, email) = parseaddr(addr)
if not(name):
name = email
ret.append('<a href="mailto:%s">%s</a>' % ( fix_ampersands(email), escape(name) ))
ret.append('<a href="mailto:%s">%s</a>' % ( email.replace('&', '&amp;'), escape(name) ))
return mark_safe(", ".join(ret))
else:
return value
Expand Down
8 changes: 4 additions & 4 deletions ietf/doc/utils_search.py
Expand Up @@ -12,7 +12,7 @@ def fill_in_document_table_attributes(docs):
docs_dict = dict((d.pk, d) for d in docs)
doc_ids = docs_dict.keys()

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

# latest event cache
event_types = ("published_rfc",
Expand Down Expand Up @@ -79,9 +79,9 @@ def fill_in_document_table_attributes(docs):
d.updated_by_list = []

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

docs = list(docs[:max_results])
Expand Down
2 changes: 1 addition & 1 deletion ietf/doc/views_material.py
Expand Up @@ -38,7 +38,7 @@ class UploadMaterialForm(forms.Form):
def __init__(self, doc_type, action, group, doc, *args, **kwargs):
super(UploadMaterialForm, self).__init__(*args, **kwargs)

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

self.doc_type = doc_type
self.action = action
Expand Down
2 changes: 1 addition & 1 deletion ietf/doc/views_stats.py
Expand Up @@ -36,7 +36,7 @@ def model_to_timeline_data(model, field='time', **kwargs):
a JsonResponse() argument. The model must have a DateTimeField field.
If the time field is named something else than 'time', the name must
be supplied."""
assert field in model._meta.get_all_field_names()
assert field in [ f.name for f in model._meta.get_fields() ]

objects = ( model.objects.filter(**kwargs)
.order_by('date')
Expand Down
2 changes: 1 addition & 1 deletion ietf/idindex/index.py
Expand Up @@ -101,7 +101,7 @@ def all_id2_txt():
# this returns a lot of data so try to be efficient

drafts = Document.objects.filter(type="draft").exclude(name__startswith="rfc").order_by('name')
drafts = drafts.select_related('group', 'group__parent', 'ad', 'ad__email', 'intended_std_level', 'shepherd', 'shepherd__email')
drafts = drafts.select_related('group', 'group__parent', 'ad', 'intended_std_level', 'shepherd', )
drafts = drafts.prefetch_related("states")

rfc_aliases = dict(DocAlias.objects.filter(name__startswith="rfc",
Expand Down
44 changes: 44 additions & 0 deletions ietf/ipr/migrations/0009_auto_20161207_1046.py
@@ -0,0 +1,44 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('ipr', '0008_auto_20160720_0218'),
]

operations = [
migrations.AlterField(
model_name='genericiprdisclosure',
name='holder_contact_email',
field=models.EmailField(max_length=254),
),
migrations.AlterField(
model_name='holderiprdisclosure',
name='holder_contact_email',
field=models.EmailField(max_length=254),
),
migrations.AlterField(
model_name='holderiprdisclosure',
name='ietfer_contact_email',
field=models.EmailField(max_length=254, blank=True),
),
migrations.AlterField(
model_name='iprdisclosurebase',
name='submitter_email',
field=models.EmailField(max_length=254, blank=True),
),
migrations.AlterField(
model_name='nondocspecificiprdisclosure',
name='holder_contact_email',
field=models.EmailField(max_length=254),
),
migrations.AlterField(
model_name='thirdpartyiprdisclosure',
name='ietfer_contact_email',
field=models.EmailField(max_length=254),
),
]

0 comments on commit 9a3f6b0

Please sign in to comment.