minor adjustements
This commit is contained in:
parent
777bd930c6
commit
7b19a581cf
2 changed files with 15 additions and 14 deletions
|
@ -13,16 +13,16 @@
|
|||
<div class="row">
|
||||
|
||||
<div class="7u 12u$(small)">
|
||||
<p>{% trans "Propriétaire : "%} {{instru.owner}} <br>
|
||||
<p>{% trans "Propriétaire : "%} {% if instru.owner %}{{instru.owner}} {% else %}-{% endif %}<br>
|
||||
{% trans "Statut : "%} {{instru.statut}} <br>
|
||||
{% ifequal instru.statut 'Prêté' %}
|
||||
{% trans "Utilisateur : "%} {{instru.user}} <br>
|
||||
{% trans "Utilisateur : "%} {% if instru.user %}{{instru.user}} {% else %}-{% endif %}<br>
|
||||
{% endifequal %}
|
||||
{% trans "Marque : "%} {{instru.marque}} <br>
|
||||
{% trans "Modele : "%} {{instru.model}} <br>
|
||||
{% trans "Numéro de série : "%} {{instru.serial}} <br>
|
||||
{% trans "Prix : "%} {{instru.prix}} <br>
|
||||
{% blocktrans with annee=instru.annee %} Acheté·e en {{annee}} {% endblocktrans%}
|
||||
{% trans "Marque : "%} {% if instru.marque %}{{instru.marque}} {% else %}-{% endif %} <br>
|
||||
{% trans "Modele : "%} {% if instru.model %}{{instru.model}} {% else %}-{% endif %}<br>
|
||||
{% trans "Numéro de série : "%} {% if instru.serial %}{{instru.serial}}{% else %}-{% endif %} <br>
|
||||
{% trans "Prix : "%} {% if instru.prix %}{{instru.prix}} {% else %}-{% endif %}<br>
|
||||
{% trans "Acheté·e en" %}{% if instru.annee %}{{annee}}{% else %}-{% endif %}
|
||||
</p>
|
||||
{% if infos or infos_en %}
|
||||
|
||||
|
|
|
@ -119,30 +119,29 @@ class Morceau(LoginRequiredMixin, TemplateView):
|
|||
|
||||
class Upload(ChefRequiredMixin, TemplateView):
|
||||
form_class = UploadFileForm
|
||||
sauvegarde = False
|
||||
error = False
|
||||
template_name = "partitions/upload.html"
|
||||
|
||||
def get_context_data(self, **kwargs):
|
||||
context = super(Upload, self).get_context_data(**kwargs)
|
||||
form = self.form_class()
|
||||
|
||||
context["sauvegarde"] = self.sauvegarde
|
||||
context["nom"] = self.kwargs["nom"]
|
||||
context["auteur"] = self.kwargs["auteur"]
|
||||
context["form"] = form
|
||||
context["error"] = self.error
|
||||
return context
|
||||
|
||||
def post(self, request, *args, **kwargs):
|
||||
form = UploadFileForm(request.POST, request.FILES)
|
||||
error = False
|
||||
sauvegarde = False
|
||||
if form.is_valid():
|
||||
partition = Partition()
|
||||
partition.part = form.cleaned_data["file"]
|
||||
partition.nom = form.cleaned_data["title"]
|
||||
if "/" in partition.nom:
|
||||
self.error = _("Le caractère / n'est pas autorisé dans le nom")
|
||||
error = _("Le caractère / n'est pas autorisé dans le nom")
|
||||
context = self.get_context_data()
|
||||
context["error"] = error
|
||||
return render(request, self.template_name, context)
|
||||
mor = get_object_or_404(
|
||||
PartitionSet, nom=self.kwargs["nom"], auteur=self.kwargs["auteur"]
|
||||
|
@ -150,13 +149,15 @@ class Upload(ChefRequiredMixin, TemplateView):
|
|||
partition.morceau = mor
|
||||
try:
|
||||
mor.partition_set.get(nom=partition.nom)
|
||||
self.error = _("Un morceau du même nom existe déjà")
|
||||
error = _("Un morceau du même nom existe déjà")
|
||||
except Partition.DoesNotExist:
|
||||
partition.save()
|
||||
self.sauvegarde = True
|
||||
sauvegarde = True
|
||||
|
||||
context = self.get_context_data()
|
||||
context["form"] = form
|
||||
context["error"] = error
|
||||
context["sauvegarde"] = sauvegarde
|
||||
return render(request, self.template_name, context)
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue