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"
|
||||
name="rules" value="{{ rule.pk }}" checked{% endif %} />
|
||||
<input class="input category-form__input" type="{{ option.type }}"
|
||||
name="{{ option.name }}" value="{{ option.value|stringformat:'s' }}"{% if option.selected %} checked{% endif %} />
|
||||
|
||||
{% if rule.favicon %}
|
||||
<img class="favicon" src="{{ rule.favicon }}" />
|
||||
{% if option.instance.favicon %}
|
||||
<img class="favicon" src="{{ option.instance.favicon }}" />
|
||||
{% else %}
|
||||
<i class="gg-image"></i>
|
||||
{% endif %}
|
||||
|
||||
<span>{{ rule.name }}</span>
|
||||
<span>{{ option.label }}</span>
|
||||
|
|
|
|||
|
|
@ -1,7 +1,9 @@
|
|||
<ul class="list checkbox-list">
|
||||
{% for rule in rules %}
|
||||
<li class="list__item checkbox-list__item">
|
||||
{% include "news/core/widgets/rule.html" %}
|
||||
</li>
|
||||
{% for group, options, index in widget.optgroups %}
|
||||
{% for option in options %}
|
||||
<li class="list__item checkbox-list__item">
|
||||
{% include "news/core/widgets/rule.html" with option=option only %}
|
||||
</li>
|
||||
{% endfor %}
|
||||
{% endfor %}
|
||||
</ul>
|
||||
|
|
|
|||
|
|
@ -4,3 +4,8 @@ from django.forms.widgets import CheckboxSelectMultiple
|
|||
class RulesWidget(CheckboxSelectMultiple):
|
||||
template_name = "news/core/widgets/rules.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