mirror of
https://github.com/nanoy42/coope
synced 2024-11-22 11:23:11 +00:00
Libérer des pintes
This commit is contained in:
parent
1a1b5cf60b
commit
bba6e3300d
4 changed files with 25 additions and 5 deletions
|
@ -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)
|
|
@ -69,7 +69,7 @@
|
|||
<li><a href="{% url 'gestion:createPintes' %}">Créer une ou plusieurs pintes</a></li>
|
||||
{% endif %}
|
||||
{% if perms.gestion.change_pinte %}
|
||||
<li><a href="">Libérer des pintes</a></li>
|
||||
<li><a href="{% url 'gestion:releasePintes' %}">Libérer des pintes</a></li>
|
||||
{% endif %}
|
||||
{% if perms.gestion.view_pinte %}
|
||||
<li><a href="{% url 'gestion:menusList' %}">Lister les pintes</a></li>
|
||||
|
|
|
@ -34,6 +34,7 @@ urlpatterns = [
|
|||
path('cancelMenu/<int:pk>', views.cancel_menu, name="cancelMenu"),
|
||||
path('productProfile/<int:pk>', 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"),
|
||||
|
|
|
@ -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 != "":
|
||||
|
@ -934,3 +934,22 @@ def create_pintes(request):
|
|||
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"})
|
||||
|
||||
@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"})
|
Loading…
Reference in a new issue