diff --git a/gestion/forms.py b/gestion/forms.py
index 0c560a8..325f1b2 100644
--- a/gestion/forms.py
+++ b/gestion/forms.py
@@ -62,7 +62,7 @@ class SelectPositiveKegForm(forms.Form):
class SelectActiveKegForm(forms.Form):
keg = forms.ModelChoiceField(queryset=Keg.objects.filter(is_active = True), required=True, label="Fût", widget=autocomplete.ModelSelect2(url='gestion:kegs-active-autocomplete'))
-class CreatePinteForm(forms.Form):
+class PinteForm(forms.Form):
ids = forms.CharField(widget=forms.Textarea, label="Numéros", help_text="Numéros séparés par un espace. Laissez vide pour utiliser le range.", required=False)
begin = forms.IntegerField(label="Début", help_text="Début du range", required=False)
end = forms.IntegerField(label="Fin", help_text="Fin du range", required=False)
\ No newline at end of file
diff --git a/gestion/templates/gestion/products_index.html b/gestion/templates/gestion/products_index.html
index 21b8393..5b5543a 100644
--- a/gestion/templates/gestion/products_index.html
+++ b/gestion/templates/gestion/products_index.html
@@ -69,7 +69,7 @@
Créer une ou plusieurs pintes
{% endif %}
{% if perms.gestion.change_pinte %}
- Libérer des pintes
+ Libérer des pintes
{% endif %}
{% if perms.gestion.view_pinte %}
Lister les pintes
diff --git a/gestion/urls.py b/gestion/urls.py
index 3fb9e41..e2bc803 100644
--- a/gestion/urls.py
+++ b/gestion/urls.py
@@ -34,6 +34,7 @@ urlpatterns = [
path('cancelMenu/', views.cancel_menu, name="cancelMenu"),
path('productProfile/', views.productProfile, name="productProfile"),
path('createPintes', views.create_pintes, name="createPintes"),
+ path('releasePintes', views.release_pintes, name="releasePintes"),
path('products-autocomplete', views.ProductsAutocomplete.as_view(), name="products-autocomplete"),
path('kegs-positive-autocomplete', views.KegPositiveAutocomplete.as_view(), name="kegs-positive-autocomplete"),
path('kegs-active-autocomplete', views.KegActiveAutocomplete.as_view(), name="kegs-active-autocomplete"),
diff --git a/gestion/views.py b/gestion/views.py
index f87f020..0e70809 100644
--- a/gestion/views.py
+++ b/gestion/views.py
@@ -13,7 +13,7 @@ import simplejson as json
from dal import autocomplete
from decimal import *
-from .forms import ReloadForm, RefundForm, ProductForm, KegForm, MenuForm, GestionForm, SearchMenuForm, SearchProductForm, SelectPositiveKegForm, SelectActiveKegForm, CreatePinteForm
+from .forms import ReloadForm, RefundForm, ProductForm, KegForm, MenuForm, GestionForm, SearchMenuForm, SearchProductForm, SelectPositiveKegForm, SelectActiveKegForm, PinteForm
from .models import Product, Menu, Keg, ConsumptionHistory, KegHistory, Consumption, MenuHistory, Pinte
from preferences.models import PaymentMethod
@@ -918,7 +918,7 @@ def allocate(pinte_pk, user):
@login_required
@permission_required('gestion.add_pinte')
def create_pintes(request):
- form = CreatePinteForm(request.POST or None)
+ form = PinteForm(request.POST or None)
if form.is_valid():
ids = form.cleaned_data['ids']
if ids != "":
@@ -933,4 +933,23 @@ def create_pintes(request):
i += 1
messages.success(request, str(i) + " pinte(s) a(ont) été ajoutée(s)")
return redirect(reverse('gestion:productsIndex'))
- return render(request, "form.html", {"form": form, "form_title": "Ajouter des pintes", "form_button": "Ajouter"})
\ No newline at end of file
+ return render(request, "form.html", {"form": form, "form_title": "Ajouter des pintes", "form_button": "Ajouter"})
+
+@active_required
+@login_required
+@permission_required('gestion.change_pinte')
+def release_pintes(request):
+ form = PinteForm(request.POST or None)
+ if form.is_valid():
+ ids = form.cleaned_data['ids']
+ if ids != "":
+ ids = ids.split(" ")
+ else:
+ ids = range(form.cleaned_data['begin'], form.cleaned_data['end'] + 1)
+ i = 0
+ for id in ids:
+ if allocate(id, None):
+ i += 1
+ messages.success(request, str(i) + " pinte(s) a(ont) été libérée(s)")
+ return redirect(reverse('gestion:productsIndex'))
+ return render(request, "form.html", {"form": form, "form_title": "Libérer des pintes", "form_button": "Libérer"})
\ No newline at end of file