"source" overview, fix some edge case(s)

This commit is contained in:
KuhnChris 2023-02-18 14:03:32 +01:00
parent fbe9546a74
commit fe4c876fdc
3 changed files with 59 additions and 3 deletions

View File

@ -0,0 +1,14 @@
# Generated by Django 3.2.18 on 2023-02-18 10:49
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
('sync', '0015_auto_20230213_0603'),
('sync', '0015_auto_20230214_2052'),
]
operations = [
]

View File

@ -34,7 +34,7 @@ class CustomCheckboxSelectMultiple(CheckboxSelectMultiple):
ctx["multipleChoiceProperties"] = [] ctx["multipleChoiceProperties"] = []
for _group, options, _index in ctx["optgroups"]: for _group, options, _index in ctx["optgroups"]:
for option in options: for option in options:
if not isinstance(value,list) and ( option["value"] in value.selected_choices or ( value.allow_all and value.all_choice in value.selected_choices ) ): if not isinstance(value,str) and not isinstance(value,list) and ( option["value"] in value.selected_choices or ( value.allow_all and value.all_choice in value.selected_choices ) ):
checked = True checked = True
else: else:
checked = False checked = False
@ -114,10 +114,19 @@ class CommaSepChoiceField(models.Field):
if value is None: if value is None:
return "" return ""
if not isinstance(value,list): if not isinstance(value,list):
print("?! CommaSepChoiceField -> ",value)
return "" return ""
return ",".join(value) if self.all_choice not in value:
return ",".join(value)
else:
return self.all_choice
def get_text_for_value(self, val):
fval = [i for i in self.possible_choices if i[0] == val]
if len(fval) <= 0:
return []
else:
return fval[0][1]
class Source(models.Model): class Source(models.Model):
''' '''

View File

@ -130,6 +130,39 @@
<td class="hide-on-small-only">UUID</td> <td class="hide-on-small-only">UUID</td>
<td><span class="hide-on-med-and-up">UUID<br></span><strong>{{ source.uuid }}</strong></td> <td><span class="hide-on-med-and-up">UUID<br></span><strong>{{ source.uuid }}</strong></td>
</tr> </tr>
<tr title="{{ _('Embedding thumbnail?') }}">
<td class="hide-on-small-only">{{ _("Embed thumbnail?") }}:</td>
<td><span class="hide-on-med-and-up">{{ _("Embed thumbnail?") }}<br></span><strong><i class="fas {% if source.embed_thumbnail %}fa-check{% else %}fa-times{% endif %}"></i></strong></td>
</tr>
<tr title="{{ _('Embedding metadata?') }}">
<td class="hide-on-small-only">{{ _("Embed metadata?") }}:</td>
<td><span class="hide-on-med-and-up">{{ _("Embed metadata?") }}<br></span><strong><i class="fas {% if source.embed_metadata %}fa-check{% else %}fa-times{% endif %}"></i></strong></td>
</tr>
<tr title="{{ _('Is sponsorblock enabled?') }}">
<td class="hide-on-small-only">{{ _("SponsorBlock?") }}:</td>
<td><span class="hide-on-med-and-up">{{ _("Sponsorblock enabled?") }}<br></span><strong><i class="fas {% if source.enable_sponsorblock %}fa-check{% else %}fa-times{% endif %}"></i></strong></td>
</tr>
{% if source.enable_sponsorblock %}
<tr title="{{ _('SponsorBlock: What to block?') }}">
<td class="hide-on-small-only">{{ _("What blocked?") }}:</td>
<td><span class="hide-on-med-and-up">{{ _("What blocked?") }}<br></span><strong>
{% if source.sponsorblock_categories.all_choice in source.sponsorblock_categories.selected_choices %}
{% for k,v in source.sponsorblock_categories.possible_choices %}
{{ v }}: <i class="fas fa-check"></i><BR>
{% endfor %}
{% else %}
{% for c in source.sponsorblock_categories.selected_choices %}
{% for k,v in source.sponsorblock_categories.possible_choices %}
{% if k == c %} {{ v }}: <i class="fas fa-check"></i><BR>{% endif %}
{% endfor %}
{% endfor %}
{% endif %}
</strong></td>
</tr>
{% endif %}
</table> </table>
</div> </div>
</div> </div>