mirror of
https://github.com/nanoy42/coope
synced 2024-12-25 00:13:46 +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 :
|
||||
<ul>
|
||||
{% 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 %}
|
||||
{% if perms.gestion.change_pinte %}
|
||||
<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>
|
||||
<li><a href="{% url 'gestion:pintesList' %}">Lister les pintes</a></li>
|
||||
{% endif %}
|
||||
</ul>
|
||||
</section>
|
||||
|
|
|
@ -33,8 +33,10 @@ urlpatterns = [
|
|||
path('cancelConsumption/<int:pk>', views.cancel_consumption, name="cancelConsumption"),
|
||||
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('addPintes', views.add_pintes, name="addPintes"),
|
||||
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('kegs-positive-autocomplete', views.KegPositiveAutocomplete.as_view(), name="kegs-positive-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:
|
||||
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
|
||||
@login_required
|
||||
@permission_required('gestion.add_pinte')
|
||||
def create_pintes(request):
|
||||
def add_pintes(request):
|
||||
form = PinteForm(request.POST or None)
|
||||
if form.is_valid():
|
||||
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)")
|
||||
return redirect(reverse('gestion:productsIndex'))
|
||||
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