Compare commits
2 commits
cc97a195a0
...
d1be126537
| Author | SHA1 | Date | |
|---|---|---|---|
| d1be126537 | |||
| 190e443f5c |
3 changed files with 3 additions and 2 deletions
|
|
@ -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")
|
||||
|
|
|
|||
|
|
@ -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"
|
||||
|
|
|
|||
|
|
@ -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>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue