Compare commits

...

2 commits

Author SHA1 Message Date
d1be126537 Correction forms ChantDoc 2025-11-07 17:32:27 +01:00
190e443f5c Icône son pour fichiers .m4a 2025-11-07 17:24:30 +01:00
3 changed files with 3 additions and 2 deletions

View file

@ -69,7 +69,7 @@ class ChantDocForm(BootstrapMixin, forms.ModelForm):
def clean(self):
data = super().clean()
if not data.get("fichier") and not data.get("lien"):
if not self.instance.pk and not data.get("fichier") and not data.get("lien"):
raise forms.ValidationError("Vous devez indiquer un fichier ou un lien")
elif data.get("fichier") and data.get("lien"):
raise forms.ValidationError("Vous ne pouvez pas indiquer à la fois un fichier et un lien")

View file

@ -16,7 +16,7 @@ def icon_url(file_name):
icon = "image"
elif ext == ".pdf":
icon = "pdf"
elif ext in [".mp3", ".wav"]:
elif ext in [".mp3", ".m4a", ".wav"]:
icon = "mp3"
elif ext in (".xls", ".xlsx", ".ods", ".csv"):
icon = "tsv"

View file

@ -11,6 +11,7 @@
{% for subform in form.formset %}
<div class="card text-bg-secondary mt-2">
<div class="card-body">
{% for fld in subform.hidden_fields %}{{ fld }}{% endfor %}
{% if subform.fichier %}{{ subform.fichier.as_field_group }}
{% elif subform.instance.fichier %}
<div>Fichier: <a href="{{ subform.instance.fichier.url }}">{{ subform.instance.fichier }}</a></div>