mirror of
https://github.com/nanoy42/coope
synced 2024-11-22 19:33:11 +00:00
Liste des pintes
This commit is contained in:
parent
bba6e3300d
commit
8d26381f6d
3 changed files with 28 additions and 5 deletions
|
@ -66,13 +66,13 @@
|
||||||
Actions possibles :
|
Actions possibles :
|
||||||
<ul>
|
<ul>
|
||||||
{% if perms.gestion.add_pinte %}
|
{% if perms.gestion.add_pinte %}
|
||||||
<li><a href="{% url 'gestion:createPintes' %}">Créer une ou plusieurs pintes</a></li>
|
<li><a href="{% url 'gestion:addPintes' %}">Créer une ou plusieurs pintes</a></li>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% if perms.gestion.change_pinte %}
|
{% if perms.gestion.change_pinte %}
|
||||||
<li><a href="{% url 'gestion:releasePintes' %}">Libérer des pintes</a></li>
|
<li><a href="{% url 'gestion:releasePintes' %}">Libérer des pintes</a></li>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% if perms.gestion.view_pinte %}
|
{% if perms.gestion.view_pinte %}
|
||||||
<li><a href="{% url 'gestion:menusList' %}">Lister les pintes</a></li>
|
<li><a href="{% url 'gestion:pintesList' %}">Lister les pintes</a></li>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</ul>
|
</ul>
|
||||||
</section>
|
</section>
|
||||||
|
|
|
@ -33,8 +33,10 @@ urlpatterns = [
|
||||||
path('cancelConsumption/<int:pk>', views.cancel_consumption, name="cancelConsumption"),
|
path('cancelConsumption/<int:pk>', views.cancel_consumption, name="cancelConsumption"),
|
||||||
path('cancelMenu/<int:pk>', views.cancel_menu, name="cancelMenu"),
|
path('cancelMenu/<int:pk>', views.cancel_menu, name="cancelMenu"),
|
||||||
path('productProfile/<int:pk>', views.productProfile, name="productProfile"),
|
path('productProfile/<int:pk>', views.productProfile, name="productProfile"),
|
||||||
path('createPintes', views.create_pintes, name="createPintes"),
|
path('addPintes', views.add_pintes, name="addPintes"),
|
||||||
path('releasePintes', views.release_pintes, name="releasePintes"),
|
path('releasePintes', views.release_pintes, name="releasePintes"),
|
||||||
|
path('pintesList', views.pintes_list, name="pintesList"),
|
||||||
|
path('release/<int:pinte_pk>', views.release, name="release"),
|
||||||
path('products-autocomplete', views.ProductsAutocomplete.as_view(), name="products-autocomplete"),
|
path('products-autocomplete', views.ProductsAutocomplete.as_view(), name="products-autocomplete"),
|
||||||
path('kegs-positive-autocomplete', views.KegPositiveAutocomplete.as_view(), name="kegs-positive-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"),
|
path('kegs-active-autocomplete', views.KegActiveAutocomplete.as_view(), name="kegs-active-autocomplete"),
|
||||||
|
|
|
@ -914,10 +914,23 @@ def allocate(pinte_pk, user):
|
||||||
except Pinte.DoesNotExist:
|
except Pinte.DoesNotExist:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
@active_required
|
||||||
|
@login_required
|
||||||
|
@permission_required('gestion.change_pinte')
|
||||||
|
def release(request, pinte_pk):
|
||||||
|
"""
|
||||||
|
View to release a pinte
|
||||||
|
"""
|
||||||
|
if allocate(pinte_pk, None):
|
||||||
|
messages.success(request, "La pinte a bien été libérée")
|
||||||
|
else:
|
||||||
|
messages.error(request, "Impossible de libérer la pinte")
|
||||||
|
return redirect(reverse('gestion:pintesList'))
|
||||||
|
|
||||||
@active_required
|
@active_required
|
||||||
@login_required
|
@login_required
|
||||||
@permission_required('gestion.add_pinte')
|
@permission_required('gestion.add_pinte')
|
||||||
def create_pintes(request):
|
def add_pintes(request):
|
||||||
form = PinteForm(request.POST or None)
|
form = PinteForm(request.POST or None)
|
||||||
if form.is_valid():
|
if form.is_valid():
|
||||||
ids = form.cleaned_data['ids']
|
ids = form.cleaned_data['ids']
|
||||||
|
@ -953,3 +966,11 @@ def release_pintes(request):
|
||||||
messages.success(request, str(i) + " pinte(s) a(ont) été libérée(s)")
|
messages.success(request, str(i) + " pinte(s) a(ont) été libérée(s)")
|
||||||
return redirect(reverse('gestion:productsIndex'))
|
return redirect(reverse('gestion:productsIndex'))
|
||||||
return render(request, "form.html", {"form": form, "form_title": "Libérer des pintes", "form_button": "Libérer"})
|
return render(request, "form.html", {"form": form, "form_title": "Libérer des pintes", "form_button": "Libérer"})
|
||||||
|
|
||||||
|
@active_required
|
||||||
|
@login_required
|
||||||
|
@permission_required('gestion.view_pinte')
|
||||||
|
def pintes_list(request):
|
||||||
|
free_pintes = Pinte.objects.filter(current_owner=None)
|
||||||
|
taken_pintes = Pinte.objects.exclude(current_owner=None)
|
||||||
|
return render(request, "gestion/pintes_list.html", {"free_pintes": free_pintes, "taken_pintes": taken_pintes})
|
Loading…
Reference in a new issue