Fix checkboxes
This commit is contained in:
parent
e930096249
commit
89556e225c
16 changed files with 59 additions and 13 deletions
|
|
@ -31,6 +31,7 @@ INSTALLED_APPS = [
|
||||||
"axes",
|
"axes",
|
||||||
# app modules
|
# app modules
|
||||||
"newsreader.accounts",
|
"newsreader.accounts",
|
||||||
|
"newsreader.utils",
|
||||||
"newsreader.news",
|
"newsreader.news",
|
||||||
"newsreader.news.core",
|
"newsreader.news.core",
|
||||||
"newsreader.news.collection",
|
"newsreader.news.collection",
|
||||||
|
|
@ -70,6 +71,8 @@ TEMPLATES = [
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
||||||
|
FORM_RENDERER = "newsreader.utils.form.FormRenderer"
|
||||||
|
|
||||||
WSGI_APPLICATION = "newsreader.wsgi.application"
|
WSGI_APPLICATION = "newsreader.wsgi.application"
|
||||||
|
|
||||||
# Database
|
# Database
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
{% extends "base.html" %}
|
{% extends "base.html" %}
|
||||||
{% load i18n static %}
|
{% load i18n static filters %}
|
||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
<main id="rules--page" class="main">
|
<main id="rules--page" class="main">
|
||||||
|
|
@ -37,7 +37,7 @@
|
||||||
{% for rule in rules %}
|
{% for rule in rules %}
|
||||||
<tr class="table__row rules-table__row">
|
<tr class="table__row rules-table__row">
|
||||||
<td class="table__item rules-table__item">
|
<td class="table__item rules-table__item">
|
||||||
{% with "rules_"|add:rule.pk as id_for_label %}
|
{% with rule|id_for_label:"rules" as id_for_label %}
|
||||||
{% include "components/form/checkbox.html" with name="rules" value=rule.pk id=id_for_label id_for_label=id_for_label %}
|
{% include "components/form/checkbox.html" with name="rules" value=rule.pk id=id_for_label id_for_label=id_for_label %}
|
||||||
{% endwith %}
|
{% endwith %}
|
||||||
</td>
|
</td>
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,8 @@
|
||||||
<input class="input category-form__input" type="{{ option.type }}"
|
{% load filters %}
|
||||||
name="{{ option.name }}" value="{{ option.value|stringformat:'s' }}"{% if option.selected %} checked{% endif %} />
|
|
||||||
|
{% with option.instance|id_for_label:"category" as id_for_label %}
|
||||||
|
{% include "components/form/checkbox.html" with name=option.name value=option.value|stringformat:'s' id=id_for_label id_for_label=id_for_label checked=option.selected only %}
|
||||||
|
{% endwith %}
|
||||||
|
|
||||||
{% if option.instance.favicon %}
|
{% if option.instance.favicon %}
|
||||||
<img class="favicon" src="{{ option.instance.favicon }}" />
|
<img class="favicon" src="{{ option.instance.favicon }}" />
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@
|
||||||
|
|
||||||
&:checked + .checkbox__label {
|
&:checked + .checkbox__label {
|
||||||
.checkbox__box {
|
.checkbox__box {
|
||||||
background-color: $focus-blue;
|
background-color: $checkbox-blue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -32,6 +32,7 @@ $border-gray: rgba(227, 227, 227, 1);
|
||||||
|
|
||||||
$button-blue: rgba(111, 164, 196, 1);
|
$button-blue: rgba(111, 164, 196, 1);
|
||||||
$focus-blue: darken($azureish-white, +10%);
|
$focus-blue: darken($azureish-white, +10%);
|
||||||
|
$checkbox-blue: rgba(34, 170, 253, 1);
|
||||||
$font-color: rgba(48, 51, 53, 1);
|
$font-color: rgba(48, 51, 53, 1);
|
||||||
$header-color: rgba(100, 101, 102, 1);
|
$header-color: rgba(100, 101, 102, 1);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,9 @@
|
||||||
{% if field %}
|
{% if field %}
|
||||||
{{ field }}
|
{{ field }}
|
||||||
{% else %}
|
{% else %}
|
||||||
<input id="{{ id }}" name="{{ name }}" type="checkbox" value="{{ value }}" data-input="{{ data_input }}" />
|
<input id="{{ id }}" name="{{ name }}" type="checkbox" value="{{ value }}"
|
||||||
|
{% if data_input %}data-input="{{ data_input }}"{% endif %}
|
||||||
|
{% if checked %}checked{% endif %} />
|
||||||
{% endif %}
|
{% endif %}
|
||||||
<label class="checkbox__label" for="{% if field %}{{ field.id_for_label }}{% else %}{{ id_for_label }}{% endif %}">
|
<label class="checkbox__label" for="{% if field %}{{ field.id_for_label }}{% else %}{{ id_for_label }}{% endif %}">
|
||||||
<span class="checkbox__box"/>
|
<span class="checkbox__box"/>
|
||||||
|
|
|
||||||
|
|
@ -23,14 +23,9 @@
|
||||||
{% for field in form.visible_fields %}
|
{% for field in form.visible_fields %}
|
||||||
<fieldset class="fieldset form__fieldset">
|
<fieldset class="fieldset form__fieldset">
|
||||||
{% include "components/form/label.html" %}
|
{% include "components/form/label.html" %}
|
||||||
|
|
||||||
{{ field.errors }}
|
{{ field.errors }}
|
||||||
|
|
||||||
{% if field.field.widget.input_type == "checkbox" %}
|
|
||||||
{% include "components/form/checkbox.html" with field=field %}
|
|
||||||
{% else %}
|
|
||||||
{{ field }}
|
{{ field }}
|
||||||
{% endif %}
|
|
||||||
|
|
||||||
{% include "components/form/help-text.html" %}
|
{% include "components/form/help-text.html" %}
|
||||||
</fieldset>
|
</fieldset>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
|
|
||||||
0
src/newsreader/utils/__init__.py
Normal file
0
src/newsreader/utils/__init__.py
Normal file
3
src/newsreader/utils/admin.py
Normal file
3
src/newsreader/utils/admin.py
Normal file
|
|
@ -0,0 +1,3 @@
|
||||||
|
|
||||||
|
|
||||||
|
# Register your models here.
|
||||||
5
src/newsreader/utils/apps.py
Normal file
5
src/newsreader/utils/apps.py
Normal file
|
|
@ -0,0 +1,5 @@
|
||||||
|
from django.apps import AppConfig
|
||||||
|
|
||||||
|
|
||||||
|
class UtilsConfig(AppConfig):
|
||||||
|
name = "utils"
|
||||||
16
src/newsreader/utils/form.py
Normal file
16
src/newsreader/utils/form.py
Normal file
|
|
@ -0,0 +1,16 @@
|
||||||
|
from django.forms.renderers import DjangoTemplates
|
||||||
|
from django.template.exceptions import TemplateDoesNotExist
|
||||||
|
from django.template.loader import get_template
|
||||||
|
|
||||||
|
|
||||||
|
class FormRenderer(DjangoTemplates):
|
||||||
|
"""
|
||||||
|
Prioritizes templates from TEMPLATES setting and fall's back to django's
|
||||||
|
default FormRenderer behaviour
|
||||||
|
"""
|
||||||
|
|
||||||
|
def get_template(self, template_name):
|
||||||
|
try:
|
||||||
|
return get_template(template_name)
|
||||||
|
except TemplateDoesNotExist:
|
||||||
|
return super().get_template(template_name)
|
||||||
0
src/newsreader/utils/migrations/__init__.py
Normal file
0
src/newsreader/utils/migrations/__init__.py
Normal file
3
src/newsreader/utils/models.py
Normal file
3
src/newsreader/utils/models.py
Normal file
|
|
@ -0,0 +1,3 @@
|
||||||
|
|
||||||
|
|
||||||
|
# Create your models here.
|
||||||
9
src/newsreader/utils/templatetags/filters.py
Normal file
9
src/newsreader/utils/templatetags/filters.py
Normal file
|
|
@ -0,0 +1,9 @@
|
||||||
|
from django import template
|
||||||
|
|
||||||
|
|
||||||
|
register = template.Library()
|
||||||
|
|
||||||
|
|
||||||
|
@register.filter
|
||||||
|
def id_for_label(instance, arg):
|
||||||
|
return f"{arg}_{instance.pk}"
|
||||||
3
src/newsreader/utils/tests.py
Normal file
3
src/newsreader/utils/tests.py
Normal file
|
|
@ -0,0 +1,3 @@
|
||||||
|
|
||||||
|
|
||||||
|
# Create your tests here.
|
||||||
3
src/newsreader/utils/views.py
Normal file
3
src/newsreader/utils/views.py
Normal file
|
|
@ -0,0 +1,3 @@
|
||||||
|
|
||||||
|
|
||||||
|
# Create your views here.
|
||||||
Loading…
Add table
Add a link
Reference in a new issue