Update ConditionsWidget to support Django 1.6 and higher.

Review Request #8681 — Created Jan. 30, 2017 and submitted

Information

Djblets
release-0.10.x
c427899...

Reviewers

ConditionsWidget was previously passing in choices to the render method
for the choice widgets, which is no longer supported on modern versions
of Django. To provide the same behavior, we need to temporarily update
the widget's list of choices to be those that we want to render on the
page.

This introduces a new internal context manager and some small logic
changes to temporarily append new choices to the widgets for rendering
purposes, reverting them after render is complete. This should be safe,
as we should be working off of a local copy of the widget and its state
and not the global version.

Unit tests pass on Django 1.6, 1.7, 1.8, 1.9, and 1.10.

Tested manually against 1.6 that the widgets were still rendering and
performing validation correctly.

reviewbot
  1. Tool: Pyflakes
    Processed Files:
        djblets/forms/widgets.py
    
    
    
    Tool: PEP8 Style Checker
    Processed Files:
        djblets/forms/widgets.py
    
    
  2. 
      
david
  1. Ship It!
  2. 
      
chipx86
Review request changed
Status:
Completed
Change Summary:
Pushed to release-0.10.x (e8df6fc)