Commit 9a5a440a authored by John Kirkwood's avatar John Kirkwood

Resolve QA warnings

parent 3ca93630
import chp.mdc.components as mdc
# import chp.mdc.components as mdc
......@@ -165,7 +165,7 @@ def test_render_foreignkey(postform):
</div>
""" # noqa
test_str = re.sub(r"\n\s*", "", test_str)
assert html == test_str
assert html == test_str
def test_render_form_errors():
......@@ -202,4 +202,3 @@ class FormTest(TestCase):
def test_uses_post_form_template(self):
response = self.client.get("/blog/post/create")
self.assertTemplateUsed(response, "blog/post_form.html")
......@@ -17,7 +17,7 @@ INSTALLED_APPS = [
'chp.django.example.todos',
'crudlfap',
]
ALLOWED_HOSTS = ['localhost', 'vm-mdc']
ALLOWED_HOSTS = ['*']
STATIC_URL = '/static/'
BASE_DIR = os.path.dirname(__file__)
STATICFILES_DIRS = [
......
......@@ -101,7 +101,7 @@ class ThreadLocalMiddleware(MiddlewareMixin):
if hasattr(_thread_locals, 'request'):
del _thread_locals.request
return response
def process_exception(self, request, exception):
if hasattr(_thread_locals, 'request'):
del _thread_locals.request
from .. import components as chp
from ..pyreact import (ce, cp, get_prop)
from ..pyreact import (cp, get_prop)
MDC_TYPE_MAP = {
"checkbox": {
......@@ -313,13 +313,14 @@ def HelperText(props=[], children=[], context={}):
)
children_line = [chp.Div(props, children)]
props_line = [cp("class", "mdc-text-field-helper-line"),]
props_line = [cp("class", "mdc-text-field-helper-line"), ]
return chp.Div(props_line, children_line)
def ValidationText(props=[], children=[], context={}):
"""Add MDC classes to validation text for an input field.
Use 'name' from 'context' to link to an input field and display 'errors'."""
Use 'name' from 'context' to link to input field and display 'errors'."""
props = [
cp("class", "mdc-text-field-helper-text--validation-msg"),
]
......
# import django.forms.widgets as Widgets
from django.forms.boundfield import BoundField
from django.forms.fields import Field
# from django.forms.fields import Field
from django.utils.functional import Promise
from django.utils.html import conditional_escape, format_html
from django.utils.translation import gettext_lazy as _
import django.forms.widgets as Widgets
from ... import components as chp
from .. import components as mdc
......@@ -85,7 +85,7 @@ class Factory:
cp("class", "errorlist nonfield"),
])
return mdc.ValidationText(props, [],
{"errors": errs,})
{"errors": errs, })
# error_msg = "<br />".join(errs)
# return chp.Para(props, error_msg)
......@@ -98,7 +98,7 @@ class Factory:
return {}
return mdc.ValidationText([], [],
{"name": field.name,
"errors": errs,})
"errors": errs, })
@staticmethod
def help_text(field):
......@@ -121,7 +121,7 @@ class Factory:
@staticmethod
def mdc_checkboxinput(context):
"""Render a BooleanField/CheckBoxInput field/widget."""
mdc_type = "checkbox"
# mdc_type = "checkbox"
props, children = [], []
props.append(
......@@ -137,7 +137,7 @@ class Factory:
@staticmethod
def mdc_textinput(context):
"""Render a CharField/TextInput field/widget."""
mdc_type = "text"
# mdc_type = "text"
props, children = [], []
props.append(
......@@ -154,7 +154,7 @@ class Factory:
@staticmethod
def mdc_dateinput(context):
"""Render a DateField/DateInput field/widget."""
mdc_type = "date"
# mdc_type = "date"
props, children = [], []
props.append(
......@@ -172,7 +172,7 @@ class Factory:
def mdc_select(context):
"""Render a CharField/choices or ForeignKey/Select field/widget.
"""
mdc_type = "select"
# mdc_type = "select"
props, children = [], []
props.append(
cp("name", context['widget']['name']))
......@@ -182,7 +182,7 @@ class Factory:
# Implementation of
# django/forms/templates/django/forms/widgets/select.html
for group_name, group_choices, group_index in \
for group_name, group_choices, _ in \
context["widget"]["optgroups"]:
props_group, children_group = [], []
if group_name:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment