diff --git a/ietf/dbtemplate/template.py b/ietf/dbtemplate/template.py index 3445984fb..f4276a9ef 100644 --- a/ietf/dbtemplate/template.py +++ b/ietf/dbtemplate/template.py @@ -4,7 +4,7 @@ from docutils.core import publish_string 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 diff --git a/ietf/doc/models.py b/ietf/doc/models.py index 355d25d07..083742ba5 100644 --- a/ietf/doc/models.py +++ b/ietf/doc/models.py @@ -53,7 +53,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 @@ -277,7 +277,7 @@ class DocumentInfo(models.Model): 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() diff --git a/ietf/doc/templatetags/ietf_filters.py b/ietf/doc/templatetags/ietf_filters.py index db88b4d3c..50ffb8a08 100644 --- a/ietf/doc/templatetags/ietf_filters.py +++ b/ietf/doc/templatetags/ietf_filters.py @@ -13,7 +13,7 @@ from ietf.doc.models import ConsensusDocEvent from ietf.doc.utils import get_document_content 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 @@ -69,7 +69,7 @@ def parse_email_list(value): (name, email) = parseaddr(addr) if not(name): name = email - ret.append('%s' % ( fix_ampersands(email), escape(name) )) + ret.append('%s' % ( email.replace('&', '&'), escape(name) )) return mark_safe(", ".join(ret)) else: return value diff --git a/ietf/doc/utils_search.py b/ietf/doc/utils_search.py index c7345596d..0087e026d 100644 --- a/ietf/doc/utils_search.py +++ b/ietf/doc/utils_search.py @@ -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", @@ -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": @@ -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]) diff --git a/ietf/doc/views_material.py b/ietf/doc/views_material.py index f24228a06..2d0fada14 100644 --- a/ietf/doc/views_material.py +++ b/ietf/doc/views_material.py @@ -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 diff --git a/ietf/liaisons/models.py b/ietf/liaisons/models.py index 9abfe83f0..e501a9fea 100644 --- a/ietf/liaisons/models.py +++ b/ietf/liaisons/models.py @@ -40,7 +40,7 @@ class LiaisonStatement(models.Model): other_identifiers = models.TextField(blank=True, null=True) # Identifiers from other bodies body = models.TextField(blank=True) - tags = models.ManyToManyField(LiaisonStatementTagName, blank=True, null=True) + tags = models.ManyToManyField(LiaisonStatementTagName, blank=True) attachments = models.ManyToManyField(Document, through='LiaisonStatementAttachment', blank=True) state = models.ForeignKey(LiaisonStatementState, default='pending') @@ -212,7 +212,7 @@ class RelatedLiaisonStatement(models.Model): class LiaisonStatementGroupContacts(models.Model): - group = models.ForeignKey(Group, unique=True) + group = models.ForeignKey(Group, unique=True, null=True) contacts = models.CharField(max_length=255,blank=True) cc_contacts = models.CharField(max_length=255,blank=True) diff --git a/ietf/mailtrigger/models.py b/ietf/mailtrigger/models.py index 20343c148..526b5f5dd 100644 --- a/ietf/mailtrigger/models.py +++ b/ietf/mailtrigger/models.py @@ -22,8 +22,8 @@ def clean_duplicates(addrlist): class MailTrigger(models.Model): slug = models.CharField(max_length=32, primary_key=True) desc = models.TextField(blank=True) - to = models.ManyToManyField('Recipient', null=True, blank=True, related_name='used_in_to') - cc = models.ManyToManyField('Recipient', null=True, blank=True, related_name='used_in_cc') + to = models.ManyToManyField('Recipient', blank=True, related_name='used_in_to') + cc = models.ManyToManyField('Recipient', blank=True, related_name='used_in_cc') class Meta: ordering = ["slug"] diff --git a/ietf/meeting/fixtures/proceedings_templates.json b/ietf/meeting/fixtures/proceedings_templates.json new file mode 100644 index 000000000..1594debff --- /dev/null +++ b/ietf/meeting/fixtures/proceedings_templates.json @@ -0,0 +1,65 @@ +[ + { + "fields": { + "group": 1, + "title": "IETF 97 Proceedings Overview", + "variables": null, + "content": "The Internet Engineering Task Force (IETF) provides a forum for working groups to coordinate technical development of new protocols. Its most important function is the development and selection of standards within the Internet protocol suite.\n\nThe IETF began in January 1986 as a forum for technical coordination by contractors for the then US Defense Advanced Research Projects Agency (DARPA), working on the ARPANET, US Defense Data Network (DDN), and the Internet core gateway system. Since that time, the IETF has grown into a large open international community of network designers, operators, vendors, and researchers concerned with the evolution of the Internet architecture and the smooth operation of the Internet.\n\nThe IETF mission includes:\n\n* Identifying and proposing solutions to pressing operational and technical problems in the Internet\n* Specifying the development or usage of protocols and the near-term architecture, to solve technical problems for the Internet\n* Facilitating technology transfer from the Internet Research Task Force (IRTF) to the wider Internet community;and\n* Providing a forum for the exchange of relevant information within the Internet community between vendors, users, researchers, agency contractors, and network managers.\n\nTechnical activities in the IETF are addressed within working groups. All working groups are organized roughly by function into seven areas. Each area is led by one or more Area Directors who have primary responsibility for that one area of IETF activity. Together with the Chair of the IETF/IESG, these Area Directors comprise the Internet Engineering Steering Group (IESG).\n\n=================== =================================== ========================\nName Area Email\n=================== =================================== ========================\nJari Arkko IETF Chair chair@ietf.org\nJari Arkko General Area jari.arkko@piuha.net\nAlia Atlas Routing Area akatlas@gmail.com\nDeborah Brungard Routing Areas db3546@att.com\nBen Campbell Applications and Real-Time Area ben@nostrum.com\nBenoit Claise Operations and Management Area bclaise@cisco.com\nAlissa Cooper Applications and Real-Time Area alissa@cooperw.in\nSpencer Dawkins Transport Area spencerdawkins.ietf@gmail.com\nStephen Farrell Security Area stephen.farrell@cs.tcd.ie\nJoel Jaeggli Operations and Management Area joelja@bogus.com\nSuresh Krishnan Internet Area suresh.krishnan@ericsson.com\nMirja Kühlewind Transport Area ietf@kuehlewind.net\nTerry Manderson Internet Area terry.manderson@icann.org\nAlexey Melnikov Applications and Real-Time Area aamelnikov@fastmail.fm\nKathleen Moriarty Security Area Kathleen.Moriarty.ietf@gmail.com\nAlvaro Retana Routing Area aretana@cisco.com\n=================== =================================== ========================\n\n\nLiaison and ex-officio members include:\n\n=================== =================================== ========================\nOlaf Kolkman IAB Chair iab-chair@iab.org\nDanny McPherson IAB Liaison danny@tcb.net\nMichelle Cotton IANA Liaison iana@iana.org\nSandy Ginoza RFC Editor Liaison rfc-editor@rfc-editor.org\nAlexa Morris IETF Secretariat Liaison exec-director@ietf.org\n=================== =================================== ========================\n\n\nThe IETF has a Secretariat, which is managed by Association Management Solutions, LLC (AMS) in Fremont, California.The IETF Executive Director is Alexa Morris (exec-director@ietf.org).\n\n\nOther personnel that provide full-time support to the Secretariat include:\n\n========================= ===================================\nSenior Meeting Planner Marcia Beaulieu\nProject Manager Stephanie McCammon\nMeeting Regsitrar Maddy Conner\nProject Manager Cindy Morgan\nProject Manager Amy Vezza\n========================= ===================================\n\nTo contact the Secretariat, please refer to the addresses and URLs provided on the IETF Secretariat Web page.\n\nThe IETF also has a general Administrative Support Activity headed by the IETF Administrative Director, Ray Pelletier iad@ietf.org\n\nThe working groups conduct their business during the tri-annual IETF meetings, at interim working group meetings, and via electronic mail on mailing lists established for each group. The tri-annual IETF meetings are 4.5 days in duration, and consist of working group sessions, training sessions, and plenary sessions. The plenary sessions include technical presentations, status reports, and an open IESG meeting.\n\nFollowing each meeting, the IETF Secretariat publishes meeting proceedings, which contain reports from all of the groups that met, as well as presentation slides, where available. The proceedings also include a summary of the standards-related activities that took place since the previous IETF meeting.\n\nMeeting minutes, working group charters (including information about the working group mailing lists), and general information on current IETF activities are available on the IETF Web site at https://www.ietf.org.\n", + "path": "/meeting/proceedings/defaults/overview.rst", + "type": "rst" + }, + "model": "dbtemplate.dbtemplate", + "pk": 179 + }, + { + "fields": { + "order": 0, + "used": true, + "name": "reStructuredText", + "desc": "" + }, + "model": "name.dbtemplatetypename", + "pk": "rst" + }, + { + "fields": { + "charter": null, + "unused_states": [], + "description": "", + "parent": null, + "list_email": "", + "acronym": "ietf", + "comments": "", + "list_subscribe": "", + "state": "active", + "time": "2012-02-26T00:21:36", + "unused_tags": [], + "list_archive": "", + "type": "ietf", + "name": "IETF" + }, + "model": "group.group", + "pk": 1 + }, + { + "fields": { + "order": 0, + "used": true, + "name": "Active", + "desc": "" + }, + "model": "name.groupstatename", + "pk": "active" + }, + { + "fields": { + "order": 0, + "used": true, + "verbose_name": "Internet Engineering Task Force", + "name": "IETF", + "desc": "" + }, + "model": "name.grouptypename", + "pk": "ietf" + } +] diff --git a/ietf/meeting/fixtures/proceedings_templates.xml b/ietf/meeting/fixtures/proceedings_templates.xml deleted file mode 100644 index 035a6125c..000000000 --- a/ietf/meeting/fixtures/proceedings_templates.xml +++ /dev/null @@ -1,93 +0,0 @@ - -/meeting/proceedings/defaults/overview.rstProceedings Overview TemplaterstThe Internet Engineering Task Force (IETF) provides a forum for working groups to coordinate technical development of new protocols. Its most important function is the development and selection of standards within the Internet protocol suite. - - - -The IETF began in January 1986 as a forum for technical coordination by contractors for the then US Defense Advanced Research Projects Agency (DARPA), working on the ARPANET, US Defense Data Network (DDN), and the Internet core gateway system. Since that time, the IETF has grown into a large open international community of network designers, operators, vendors, and researchers concerned with the evolution of the Internet architecture and the smooth operation of the Internet. - - - -The IETF mission includes: - - - -* Identifying and proposing solutions to pressing operational and technical problems in the Internet - -* Specifying the development or usage of protocols and the near-term architecture, to solve technical problems for the Internet - -* Facilitating technology transfer from the Internet Research Task Force (IRTF) to the wider Internet community;and - -* Providing a forum for the exchange of relevant information within the Internet community between vendors, users, researchers, agency contractors, and network managers. - - - -Technical activities in the IETF are addressed within working groups. All working groups are organized roughly by function into seven areas. Each area is led by one or more Area Directors who have primary responsibility for that one area of IETF activity. Together with the Chair of the IETF/IESG, these Area Directors comprise the Internet Engineering Steering Group (IESG). - - - -=================== =================================== ======================== -Name Area Email -=================== =================================== ======================== -Jari Arkko IETF Chair chair@ietf.org -Jari Arkko General Area jari.arkko@piuha.net -Alia Atlas Routing Area akatlas@gmail.com -Deborah Brungard Routing Areas db3546@att.com -Ben Campbell Applications and Real-Time Area ben@nostrum.com -Benoit Claise Operations and Management Area bclaise@cisco.com -Alissa Cooper Applications and Real-Time Area alissa@cooperw.in -Spencer Dawkins Transport Area spencerdawkins.ietf@gmail.com -Stephen Farrell Security Area stephen.farrell@cs.tcd.ie -Brian Haberman Internet Area brian@innovationslab.net -Joel Jaeggli Operations and Management Area joelja@bogus.com -Barry Leiba Applications and Real-Time Area barryleiba@computer.org -Terry Manderson Internet Area terry.manderson@icann.org -Kathleen Moriarty Security Area Kathleen.Moriarty.ietf@gmail.com -Alvaro Retana Routing Area aretana@cisco.com -Martin Stiemerling Transport Area mls.ietf@gmail.com -=================== =================================== ======================== - - -Liaison and ex-officio members include: - - -=================== =================================== ======================== -Olaf Kolkman IAB Chair iab-chair@iab.org -Danny McPherson IAB Liaison danny@tcb.net -Michelle Cotton IANA Liaison iana@iana.org -Sandy Ginoza RFC Editor Liaison rfc-editor@rfc-editor.org -Alexa Morris IETF Secretariat Liaison exec-director@ietf.org -=================== =================================== ======================== - - -The IETF has a Secretariat, which is managed by Association Management Solutions, LLC (AMS) in Fremont, California.The IETF Executive Director is Alexa Morris (exec-director@ietf.org). - - -Other personnel that provide full-time support to the Secretariat include: - - -========================= =================================== -Senior Meeting Planner Marcia Beaulieu -Project Manager Stephanie McCammon -Meeting Regsitrar Maddy Conner -Project Manager Cindy Morgan -Project Manager Amy Vezza -========================= =================================== - - -To contact the Secretariat, please refer to the addresses and URLs provided on the IETF Secretariat Web page. - - - -The IETF also has a general Administrative Support Activity headed by the IETF Administrative Director, Ray Pelletier iad@ietf.org - - - -The working groups conduct their business during the tri-annual IETF meetings, at interim working group meetings, and via electronic mail on mailing lists established for each group. The tri-annual IETF meetings are 4.5 days in duration, and consist of working group sessions, training sessions, and plenary sessions. The plenary sessions include technical presentations, status reports, and an open IESG meeting. - - - -Following each meeting, the IETF Secretariat publishes meeting proceedings, which contain reports from all of the groups that met, as well as presentation slides, where available. The proceedings also include a summary of the standards-related activities that took place since the previous IETF meeting. - - - -Meeting minutes, working group charters (including information about the working group mailing lists), and general information on current IETF activities are available on the IETF Web site at https://www.ietf.org.1 \ No newline at end of file diff --git a/ietf/meeting/models.py b/ietf/meeting/models.py index 26a3da48d..620c52fed 100644 --- a/ietf/meeting/models.py +++ b/ietf/meeting/models.py @@ -418,7 +418,7 @@ class TimeSlot(models.Model): duration = TimedeltaField() location = models.ForeignKey(Room, blank=True, null=True) show_location = models.BooleanField(default=True, help_text="Show location in agenda.") - sessions = models.ManyToManyField('Session', related_name='slots', through='SchedTimeSessAssignment', null=True, blank=True, help_text=u"Scheduled session, if any.") + sessions = models.ManyToManyField('Session', related_name='slots', through='SchedTimeSessAssignment', blank=True, help_text=u"Scheduled session, if any.") modified = models.DateTimeField(auto_now=True) # diff --git a/ietf/nomcom/forms.py b/ietf/nomcom/forms.py index ab797e3e5..95a52e01f 100644 --- a/ietf/nomcom/forms.py +++ b/ietf/nomcom/forms.py @@ -1,6 +1,6 @@ from django.conf import settings from django import forms -from django.contrib.formtools.preview import FormPreview, AUTO_ID +from formtools.preview import FormPreview, AUTO_ID from django.shortcuts import get_object_or_404, redirect from django.utils.decorators import method_decorator from django.shortcuts import render_to_response diff --git a/ietf/nomcom/models.py b/ietf/nomcom/models.py index 8e1afc691..6c975164d 100644 --- a/ietf/nomcom/models.py +++ b/ietf/nomcom/models.py @@ -205,8 +205,8 @@ class Position(models.Model): class Feedback(models.Model): nomcom = models.ForeignKey('NomCom') author = models.EmailField(verbose_name='Author', blank=True) - positions = models.ManyToManyField('Position', blank=True, null=True) - nominees = models.ManyToManyField('Nominee', blank=True, null=True) + positions = models.ManyToManyField('Position', blank=True) + nominees = models.ManyToManyField('Nominee', blank=True) subject = models.TextField(verbose_name='Subject', blank=True) comments = EncryptedTextField(verbose_name='Comments') type = models.ForeignKey(FeedbackTypeName, blank=True, null=True) diff --git a/ietf/person/utils.py b/ietf/person/utils.py index 2229cf962..55e7a6929 100755 --- a/ietf/person/utils.py +++ b/ietf/person/utils.py @@ -74,9 +74,9 @@ def merge_persons(source,target,stream): user = User.objects.filter(is_superuser=True).first() admin_site = admin.site using = 'default' - - deletable_objects, perms_needed, protected = admin.utils.get_deleted_objects( - objs, opts, user, admin_site, using) + + deletable_objects, model_count, perms_needed, protected = ( + admin.utils.get_deleted_objects(objs, opts, user, admin_site, using) ) if len(deletable_objects) > 1: print >>stream, "Not Deleting Person: {}({})".format(source.ascii,source.pk) diff --git a/ietf/settings.py b/ietf/settings.py index 6c121ef42..524e25d5e 100644 --- a/ietf/settings.py +++ b/ietf/settings.py @@ -21,7 +21,6 @@ from ietf import __version__ import debug DEBUG = True -TEMPLATE_DEBUG = DEBUG debug.debug = DEBUG # Valid values: @@ -216,13 +215,38 @@ SESSION_SAVE_EVERY_REQUEST = True PREFERENCES_COOKIE_AGE = 60 * 60 * 24 * 365 * 50 # Age of cookie, in seconds: 50 years -TEMPLATE_LOADERS = ( - ('django.template.loaders.cached.Loader', ( - 'django.template.loaders.filesystem.Loader', - 'django.template.loaders.app_directories.Loader', - )), - 'ietf.dbtemplate.template.Loader', -) +TEMPLATES = [ + { + 'BACKEND': 'django.template.backends.django.DjangoTemplates', + 'DIRS': [ + BASE_DIR + "/templates", + BASE_DIR + "/secr/templates", + ], + 'OPTIONS': { + 'context_processors': [ + 'django.contrib.auth.context_processors.auth', + 'django.template.context_processors.debug', + 'django.template.context_processors.i18n', + 'django.template.context_processors.request', + 'django.template.context_processors.media', + #'django.template.context_processors.tz', + 'django.contrib.messages.context_processors.messages', + 'ietf.context_processors.server_mode', + 'ietf.context_processors.debug_mark_queries_from_view', + 'ietf.context_processors.revision_info', + 'ietf.secr.context_processors.secr_revision_info', + 'ietf.context_processors.rfcdiff_base_url', + ], + 'loaders': [ + ('django.template.loaders.cached.Loader', ( + 'django.template.loaders.filesystem.Loader', + 'django.template.loaders.app_directories.Loader', + )), + 'ietf.dbtemplate.template.Loader', + ] + }, + }, +] MIDDLEWARE_CLASSES = ( 'django.middleware.csrf.CsrfViewMiddleware', @@ -240,25 +264,6 @@ MIDDLEWARE_CLASSES = ( ROOT_URLCONF = 'ietf.urls' -TEMPLATE_DIRS = ( - BASE_DIR + "/templates", - BASE_DIR + "/secr/templates", -) - -TEMPLATE_CONTEXT_PROCESSORS = ( - 'django.contrib.auth.context_processors.auth', - 'django.core.context_processors.debug', - 'django.core.context_processors.i18n', - 'django.core.context_processors.request', - 'django.core.context_processors.media', - 'django.contrib.messages.context_processors.messages', - 'ietf.context_processors.server_mode', - 'ietf.context_processors.debug_mark_queries_from_view', - 'ietf.context_processors.revision_info', - 'ietf.secr.context_processors.secr_revision_info', - 'ietf.context_processors.rfcdiff_base_url', -) - # Additional locations of static files (in addition to each app's static/ dir) STATICFILES_DIRS = ( os.path.join(BASE_DIR, 'static'), @@ -754,6 +759,10 @@ LIST_ACCOUNT_DELAY = 60*60*25 # 25 hours ACCOUNT_REQUEST_EMAIL = 'account-request@ietf.org' +SILENCED_SYSTEM_CHECKS = [ + "fields.W342", # Setting unique=True on a ForeignKey has the same effect as using a OneToOneField. +] + # Put the production SECRET_KEY in settings_local.py, and also any other # sensitive or site-specific changes. DO NOT commit settings_local.py to svn. @@ -768,7 +777,7 @@ for app in INSTALLED_APPS: # Add DEV_APPS to INSTALLED_APPS INSTALLED_APPS += DEV_APPS MIDDLEWARE_CLASSES += DEV_MIDDLEWARE_CLASSES -TEMPLATE_CONTEXT_PROCESSORS += DEV_TEMPLATE_CONTEXT_PROCESSORS +TEMPLATES[0]['OPTIONS']['context_processors'] += DEV_TEMPLATE_CONTEXT_PROCESSORS # We provide a secret key only for test and development modes. It's @@ -777,7 +786,9 @@ TEMPLATE_CONTEXT_PROCESSORS += DEV_TEMPLATE_CONTEXT_PROCESSORS # publicly available, for instance from the source repository. if SERVER_MODE != 'production': # stomp out the cached template loader, it's annoying - TEMPLATE_LOADERS = tuple(l for e in TEMPLATE_LOADERS for l in (e[1] if isinstance(e, tuple) and "cached.Loader" in e[0] else (e,))) + loaders = TEMPLATES[0]['OPTIONS']['loaders'] + loaders = tuple(l for e in loaders for l in (e[1] if isinstance(e, tuple) and "cached.Loader" in e[0] else (e,))) + TEMPLATES[0]['OPTIONS']['loaders'] = loaders CACHES = { 'default': { diff --git a/ietf/submit/models.py b/ietf/submit/models.py index 9bb3fed18..6e710cc6b 100644 --- a/ietf/submit/models.py +++ b/ietf/submit/models.py @@ -77,7 +77,7 @@ class Submission(models.Model): return Document.objects.filter(name=self.name).first() class SubmissionCheck(models.Model): - time = models.DateTimeField(auto_now=True, default=None) # The default is to make makemigrations happy + time = models.DateTimeField(auto_now=True) submission = models.ForeignKey(Submission, related_name='checks') checker = models.CharField(max_length=256, blank=True) passed = models.NullBooleanField(default=False) diff --git a/ietf/utils/test_data.py b/ietf/utils/test_data.py index 33c3a6c86..fc7031150 100644 --- a/ietf/utils/test_data.py +++ b/ietf/utils/test_data.py @@ -37,7 +37,8 @@ def create_person(group, role_name, name=None, username=None, email_address=None return person def create_group(**kwargs): - return Group.objects.create(state_id="active", **kwargs) + group, created = Group.objects.get_or_create(state_id="active", **kwargs) + return group def make_immutable_base_data(): """Some base data (groups, etc.) that doesn't need to be modified by diff --git a/ietf/utils/test_runner.py b/ietf/utils/test_runner.py index 3c823a583..272d0c9bc 100644 --- a/ietf/utils/test_runner.py +++ b/ietf/utils/test_runner.py @@ -51,10 +51,10 @@ from fnmatch import fnmatch from coverage.report import Reporter from coverage.results import Numbers from coverage.misc import NotPython -from optparse import make_option from django.conf import settings from django.template import TemplateDoesNotExist +from django.template.loaders.base import Loader as BaseLoader from django.test.runner import DiscoverRunner from django.core.management import call_command from django.core.urlresolvers import RegexURLResolver @@ -86,7 +86,7 @@ def safe_create_1(self, verbosity, *args, **kwargs): if settings.GLOBAL_TEST_FIXTURES: print " Loading global test fixtures: %s" % ", ".join(settings.GLOBAL_TEST_FIXTURES) loadable = [f for f in settings.GLOBAL_TEST_FIXTURES if "." not in f] - call_command('loaddata', *loadable, verbosity=0, commit=False, database="default") + call_command('loaddata', *loadable, verbosity=verbosity, commit=False, database="default") for f in settings.GLOBAL_TEST_FIXTURES: if f not in loadable: @@ -108,11 +108,14 @@ def safe_destroy_0_1(*args, **kwargs): settings.DATABASES["default"]["NAME"] = test_database_name return old_destroy(*args, **kwargs) -def template_coverage_loader(template_name, dirs): - if template_coverage_collection == True: - loaded_templates.add(str(template_name)) - raise TemplateDoesNotExist -template_coverage_loader.is_usable = True +class TemplateCoverageLoader(BaseLoader): + is_usable = True + + def load_template_source(self, template_name, dirs): + if template_coverage_collection == True: + loaded_templates.add(str(template_name)) + raise TemplateDoesNotExist + load_template_source.is_usable = True class RecordUrlsMiddleware(object): def process_request(self, request): @@ -333,19 +336,18 @@ class CoverageTest(TestCase): self.skipTest("Coverage switched off with --skip-coverage") class IetfTestRunner(DiscoverRunner): - option_list = ( - make_option('--skip-coverage', - action='store_true', dest='skip_coverage', default=False, - help='Skip test coverage measurements for code, templates, and URLs. ' - ), - make_option('--save-version-coverage', - action='store', dest='save_version_coverage', default=False, - help='Save test coverage data under the given version label'), - make_option('--save-testresult', + @classmethod + def add_arguments(cls, parser): + parser.add_argument('--skip-coverage', + action='store_true', dest='skip_coverage', default=False, + help='Skip test coverage measurements for code, templates, and URLs. ' ) + parser.add_argument('--save-version-coverage', + action='store', dest='save_version_coverage', default=False, + help='Save test coverage data under the given version label') + parser.add_argument('--save-testresult', action='store_true', dest='save_testresult', default=False, help='Save short test result data in %s/.testresult' % os.path.dirname(os.path.dirname(settings.BASE_DIR))), - ) def __init__(self, skip_coverage=False, save_version_coverage=None, **kwargs): # @@ -393,7 +395,7 @@ class IetfTestRunner(DiscoverRunner): }, } - settings.TEMPLATE_LOADERS = ('ietf.utils.test_runner.template_coverage_loader',) + settings.TEMPLATE_LOADERS + settings.TEMPLATE_LOADERS = ('ietf.utils.test_runner.TemplateCoverageLoader',) + settings.TEMPLATE_LOADERS template_coverage_collection = True settings.MIDDLEWARE_CLASSES = ('ietf.utils.test_runner.RecordUrlsMiddleware',) + settings.MIDDLEWARE_CLASSES diff --git a/ietf/utils/tests.py b/ietf/utils/tests.py index 79f119caf..33a3a040a 100644 --- a/ietf/utils/tests.py +++ b/ietf/utils/tests.py @@ -16,8 +16,8 @@ from django.conf import settings from django.core.management import call_command from django.template import Context from django.template.defaulttags import URLNode +from django.template.loader import get_template from django.templatetags.static import StaticNode -from django.template.loaders.filesystem import Loader from django.test import TestCase import debug # pyflakes:ignore @@ -111,12 +111,11 @@ class TemplateChecksTestCase(TestCase): templates = {} def setUp(self): - self.loader = Loader() self.paths = list(get_template_paths()) self.paths.sort() for path in self.paths: try: - self.templates[path], _ = self.loader.load_template(path) + self.templates[path] = get_template(path).template except Exception: pass @@ -132,7 +131,7 @@ class TemplateChecksTestCase(TestCase): if not path in self.templates: try: - self.loader.load_template(path) + get_template(path) except Exception as e: errors.append((path, e)) if errors: diff --git a/requirements.txt b/requirements.txt index 3ac966cf7..a4cb302fd 100644 --- a/requirements.txt +++ b/requirements.txt @@ -6,8 +6,9 @@ coverage>=4.0.1,!=4.0.2 #cssselect>=0.6.1 # for PyQuery decorator>=3.4.0 defusedxml>=0.4.1 # for TastyPie when ussing xml; not a declared dependency -Django>=1.7.10,<1.8 +Django>=1.8.16,<1.9 django-bootstrap3>=5.1.1,<7.0.0 # django-bootstrap 7.0 requires django 1.8 +django-formtools>=1.0 # instead of django.contrib.formtools in 1.8 django-markup>=1.1 django-tastypie>=0.13.1 django-widget-tweaks>=1.3