mirror of
https://github.com/ansible/awx.git
synced 2026-05-11 11:27:36 -02:30
Avoid using SmartFilter during migrations (#14786)
Our migrations that touch roles tend to bring in our real models via migration_utils.set_current_apps_for_migrations, and that can have some undesirable side-effects.
This commit is contained in:
@@ -5,6 +5,7 @@
|
|||||||
import copy
|
import copy
|
||||||
import json
|
import json
|
||||||
import re
|
import re
|
||||||
|
import sys
|
||||||
import urllib.parse
|
import urllib.parse
|
||||||
|
|
||||||
from jinja2 import sandbox, StrictUndefined
|
from jinja2 import sandbox, StrictUndefined
|
||||||
@@ -406,11 +407,13 @@ class SmartFilterField(models.TextField):
|
|||||||
# https://docs.python.org/2/library/stdtypes.html#truth-value-testing
|
# https://docs.python.org/2/library/stdtypes.html#truth-value-testing
|
||||||
if not value:
|
if not value:
|
||||||
return None
|
return None
|
||||||
value = urllib.parse.unquote(value)
|
# avoid doing too much during migrations
|
||||||
try:
|
if 'migrate' not in sys.argv:
|
||||||
SmartFilter().query_from_string(value)
|
value = urllib.parse.unquote(value)
|
||||||
except RuntimeError as e:
|
try:
|
||||||
raise models.base.ValidationError(e)
|
SmartFilter().query_from_string(value)
|
||||||
|
except RuntimeError as e:
|
||||||
|
raise models.base.ValidationError(e)
|
||||||
return super(SmartFilterField, self).get_prep_value(value)
|
return super(SmartFilterField, self).get_prep_value(value)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user