Fix RuleWidget
This commit is contained in:
parent
2d638cd977
commit
c732fdc96e
3 changed files with 16 additions and 9 deletions
|
|
@ -1,10 +1,10 @@
|
||||||
<input class="input category-form__input" type="checkbox"
|
<input class="input category-form__input" type="{{ option.type }}"
|
||||||
name="rules" value="{{ rule.pk }}" checked{% endif %} />
|
name="{{ option.name }}" value="{{ option.value|stringformat:'s' }}"{% if option.selected %} checked{% endif %} />
|
||||||
|
|
||||||
{% if rule.favicon %}
|
{% if option.instance.favicon %}
|
||||||
<img class="favicon" src="{{ rule.favicon }}" />
|
<img class="favicon" src="{{ option.instance.favicon }}" />
|
||||||
{% else %}
|
{% else %}
|
||||||
<i class="gg-image"></i>
|
<i class="gg-image"></i>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
<span>{{ rule.name }}</span>
|
<span>{{ option.label }}</span>
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,9 @@
|
||||||
<ul class="list checkbox-list">
|
<ul class="list checkbox-list">
|
||||||
{% for rule in rules %}
|
{% for group, options, index in widget.optgroups %}
|
||||||
|
{% for option in options %}
|
||||||
<li class="list__item checkbox-list__item">
|
<li class="list__item checkbox-list__item">
|
||||||
{% include "news/core/widgets/rule.html" %}
|
{% include "news/core/widgets/rule.html" with option=option only %}
|
||||||
</li>
|
</li>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
{% endfor %}
|
||||||
</ul>
|
</ul>
|
||||||
|
|
|
||||||
|
|
@ -4,3 +4,8 @@ from django.forms.widgets import CheckboxSelectMultiple
|
||||||
class RulesWidget(CheckboxSelectMultiple):
|
class RulesWidget(CheckboxSelectMultiple):
|
||||||
template_name = "news/core/widgets/rules.html"
|
template_name = "news/core/widgets/rules.html"
|
||||||
option_template_name = "news/core/widgets/rule.html"
|
option_template_name = "news/core/widgets/rule.html"
|
||||||
|
|
||||||
|
def create_option(self, *args, **kwargs):
|
||||||
|
option = super().create_option(*args, **kwargs)
|
||||||
|
instance = self.choices.queryset.get(pk=option["value"])
|
||||||
|
return {**option, "instance": instance}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue