Compare commits

...
Sign in to create a new pull request.

1 commit

Author SHA1 Message Date
b0fe08d5ee Dont't overwrite default checkbox
This caused issues in the admin
2020-07-26 13:19:50 +02:00
7 changed files with 18 additions and 11 deletions

View file

@ -0,0 +1,9 @@
from django import forms
class CheckboxInput(forms.CheckboxInput):
template_name = "components/form/checkbox.html"
def get_context(self, name, value, attrs):
context = super().get_context(name, value, attrs)
return {**context, **attrs}

View file

@ -5,6 +5,7 @@ from django.utils.translation import gettext_lazy as _
import pytz import pytz
from newsreader.core.forms import CheckboxInput
from newsreader.news.collection.choices import RuleTypeChoices from newsreader.news.collection.choices import RuleTypeChoices
from newsreader.news.collection.models import CollectionRule from newsreader.news.collection.models import CollectionRule
from newsreader.news.collection.reddit import REDDIT_API_URL from newsreader.news.collection.reddit import REDDIT_API_URL
@ -95,4 +96,6 @@ class SubRedditRuleForm(CollectionRuleForm):
class OPMLImportForm(forms.Form): class OPMLImportForm(forms.Form):
file = forms.FileField(allow_empty_file=False) file = forms.FileField(allow_empty_file=False)
skip_existing = forms.BooleanField(initial=False, required=False) skip_existing = forms.BooleanField(
initial=False, required=False, widget=CheckboxInput
)

View file

@ -1,7 +1,7 @@
{% load filters %} {% load filters %}
{% with option.instance|id_for_label:"category" as id_for_label %} {% with option.instance|id_for_label:"category" as id_for_label %}
{% include "components/form/checkbox.html" with widget=option checked=option.selected id_for_label=id_for_label only %} {% include "components/form/checkbox.html" with name=option.name value=option.value checked=option.selected id=id_for_label only %}
{% endwith %} {% endwith %}
{% if option.instance.favicon %} {% if option.instance.favicon %}

View file

@ -1,10 +1,7 @@
<div class="checkbox"> <div class="checkbox">
{% if widget %} {% include "components/form/input.html" with id=id name=name type="checkbox" value=value checked=checked widget=widget %}
{% include "components/form/input.html" with widget=widget %}
{% else %} <label class="checkbox__label" for="{{ id }}">
{% include "components/form/input.html" with id=id name=name type="checkbox" value=value data_input=data_input checked=checked %}
{% endif %}
<label class="checkbox__label" for="{% if widget %}{{ widget.attrs.id }}{% else %}{{ id_for_label }}{% endif %}">
<span class="checkbox__box"/> <span class="checkbox__box"/>
</label> </label>
</div> </div>

View file

@ -3,5 +3,5 @@
type="{{ widget.type }}" name="{{ widget.name }}" type="{{ widget.type }}" name="{{ widget.name }}"
{% if widget.value != None %} value="{{ widget.value|stringformat:'s' }}"{% endif %} {% if widget.value != None %} value="{{ widget.value|stringformat:'s' }}"{% endif %}
{% endif %} {% endif %}
{% include "django/forms/widgets/attrs.html" %}> {% include "components/form/attrs.html" %}>
{% endspaceless %} {% endspaceless %}

View file

@ -1 +0,0 @@
../../../components/form/attrs.html

View file

@ -1 +0,0 @@
../../../components/form/checkbox.html