mirror of
https://github.com/nanoy42/coope
synced 2024-08-19 08:23:39 +00:00
Ajout du champ produit
This commit is contained in:
parent
efb9d3be23
commit
16622c4ba7
5 changed files with 41 additions and 22 deletions
|
@ -55,6 +55,7 @@ class SearchMenuForm(forms.Form):
|
||||||
|
|
||||||
class GestionForm(forms.Form):
|
class GestionForm(forms.Form):
|
||||||
client = forms.ModelChoiceField(queryset=User.objects.filter(is_active=True), required=True, label="Client", widget=autocomplete.ModelSelect2(url='users:active-users-autocomplete', attrs={'data-minimum-input-length':2}))
|
client = forms.ModelChoiceField(queryset=User.objects.filter(is_active=True), required=True, label="Client", widget=autocomplete.ModelSelect2(url='users:active-users-autocomplete', attrs={'data-minimum-input-length':2}))
|
||||||
|
product = forms.ModelChoiceField(queryset=Product.objects.filter(is_active=True), required=True, label="Produit", widget=autocomplete.ModelSelect2(url='gestion:active-products-autocomplete', attrs={'data-minimum-input-length':2}))
|
||||||
|
|
||||||
class SelectPositiveKegForm(forms.Form):
|
class SelectPositiveKegForm(forms.Form):
|
||||||
keg = forms.ModelChoiceField(queryset=Keg.objects.filter(stockHold__gt = 0), required=True, label="Fût", widget=autocomplete.ModelSelect2(url='gestion:kegs-positive-autocomplete'))
|
keg = forms.ModelChoiceField(queryset=Keg.objects.filter(stockHold__gt = 0), required=True, label="Fût", widget=autocomplete.ModelSelect2(url='gestion:kegs-positive-autocomplete'))
|
||||||
|
|
|
@ -99,7 +99,7 @@
|
||||||
{% if forloop.counter0|divisibleby:4 %}
|
{% if forloop.counter0|divisibleby:4 %}
|
||||||
<tr style="text-align:center">
|
<tr style="text-align:center">
|
||||||
{% endif %}
|
{% endif %}
|
||||||
<td><button class="product {% if product.adherentRequired %}special{% endif%}" target="{{product.barcode}}">{{product.name}}</button></td>
|
<td><button class="product {% if product.adherentRequired %}special{% endif%}" target="{{product.pk}}">{{product.name}}</button></td>
|
||||||
{% if forloop.counter|divisibleby:4 %}
|
{% if forloop.counter|divisibleby:4 %}
|
||||||
</tr>
|
</tr>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
@ -112,7 +112,7 @@
|
||||||
{% if forloop.counter0|divisibleby:4 %}
|
{% if forloop.counter0|divisibleby:4 %}
|
||||||
<tr style="text-align:center">
|
<tr style="text-align:center">
|
||||||
{% endif %}
|
{% endif %}
|
||||||
<td><button class="product {% if product.adherentRequired %}special{% endif%}" target="{{product.barcode}}">{{product.name}}</button></td>
|
<td><button class="product {% if product.adherentRequired %}special{% endif%}" target="{{product.pk}}">{{product.name}}</button></td>
|
||||||
{% if forloop.counter|divisibleby:4 %}
|
{% if forloop.counter|divisibleby:4 %}
|
||||||
</tr>
|
</tr>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
@ -125,7 +125,7 @@
|
||||||
{% if forloop.counter0|divisibleby:4 %}
|
{% if forloop.counter0|divisibleby:4 %}
|
||||||
<tr style="text-align:center">
|
<tr style="text-align:center">
|
||||||
{% endif %}
|
{% endif %}
|
||||||
<td><button class="product {% if product.adherentRequired %}special{% endif%}" target="{{product.barcode}}">{{product.name}}</button></td>
|
<td><button class="product {% if product.adherentRequired %}special{% endif%}" target="{{product.pk}}">{{product.name}}</button></td>
|
||||||
{% if forloop.counter|divisibleby:4 %}
|
{% if forloop.counter|divisibleby:4 %}
|
||||||
</tr>
|
</tr>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
@ -138,7 +138,7 @@
|
||||||
{% if forloop.counter0|divisibleby:4 %}
|
{% if forloop.counter0|divisibleby:4 %}
|
||||||
<tr style="text-align:center">
|
<tr style="text-align:center">
|
||||||
{% endif %}
|
{% endif %}
|
||||||
<td><button class="product {% if product.adherentRequired %}special{% endif%}" target="{{product.barcode}}">{{product.name}}</button></td>
|
<td><button class="product {% if product.adherentRequired %}special{% endif%}" target="{{product.pk}}">{{product.name}}</button></td>
|
||||||
{% if forloop.counter|divisibleby:4 %}
|
{% if forloop.counter|divisibleby:4 %}
|
||||||
</tr>
|
</tr>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
@ -152,7 +152,7 @@
|
||||||
{% if forloop.counter0|divisibleby:4 %}
|
{% if forloop.counter0|divisibleby:4 %}
|
||||||
<tr style="text-align:center">
|
<tr style="text-align:center">
|
||||||
{% endif %}
|
{% endif %}
|
||||||
<td><button class="product {% if product.adherentRequired %}special{% endif%}" target="{{product.barcode}}">{{product.name}}</button></td>
|
<td><button class="product {% if product.adherentRequired %}special{% endif%}" target="{{product.pk}}">{{product.name}}</button></td>
|
||||||
{% if forloop.counter|divisibleby:4 %}
|
{% if forloop.counter|divisibleby:4 %}
|
||||||
</tr>
|
</tr>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
@ -166,7 +166,7 @@
|
||||||
{% if forloop.counter0|divisibleby:4 %}
|
{% if forloop.counter0|divisibleby:4 %}
|
||||||
<tr style="text-align:center">
|
<tr style="text-align:center">
|
||||||
{% endif %}
|
{% endif %}
|
||||||
<td><button class="menu {% if product.adherent_required %}special{% endif%}" target="{{product.barcode}}">{{product.name}}</button></td>
|
<td><button class="menu {% if product.adherent_required %}special{% endif%}" target="{{product.pk}}">{{product.name}}</button></td>
|
||||||
{% if forloop.counter|divisibleby:4 %}
|
{% if forloop.counter|divisibleby:4 %}
|
||||||
</tr>
|
</tr>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
|
@ -24,9 +24,9 @@ urlpatterns = [
|
||||||
path('searchMenu', views.searchMenu, name="searchMenu"),
|
path('searchMenu', views.searchMenu, name="searchMenu"),
|
||||||
path('editMenu/<int:pk>', views.edit_menu, name="editMenu"),
|
path('editMenu/<int:pk>', views.edit_menu, name="editMenu"),
|
||||||
path('menusList', views.menus_list, name="menusList"),
|
path('menusList', views.menus_list, name="menusList"),
|
||||||
path('getMenu/<str:barcode>', views.get_menu, name="getMenu"),
|
path('getMenu/<int:pk>', views.get_menu, name="getMenu"),
|
||||||
path('swicthActivateMenu/<int:pk>', views.switch_activate_menu, name="switchActivateMenu"),
|
path('swicthActivateMenu/<int:pk>', views.switch_activate_menu, name="switchActivateMenu"),
|
||||||
path('getProduct/<str:barcode>', views.getProduct, name="getProduct"),
|
path('getProduct/<int:pk>', views.getProduct, name="getProduct"),
|
||||||
path('order', views.order, name="order"),
|
path('order', views.order, name="order"),
|
||||||
path('ranking', views.ranking, name="ranking"),
|
path('ranking', views.ranking, name="ranking"),
|
||||||
path('searchProduct', views.searchProduct, name="searchProduct"),
|
path('searchProduct', views.searchProduct, name="searchProduct"),
|
||||||
|
@ -39,6 +39,7 @@ urlpatterns = [
|
||||||
path('release/<int:pinte_pk>', views.release, name="release"),
|
path('release/<int:pinte_pk>', views.release, name="release"),
|
||||||
path('pintesUserList', views.pintes_user_list, name="pintesUserList"),
|
path('pintesUserList', views.pintes_user_list, name="pintesUserList"),
|
||||||
path('products-autocomplete', views.ProductsAutocomplete.as_view(), name="products-autocomplete"),
|
path('products-autocomplete', views.ProductsAutocomplete.as_view(), name="products-autocomplete"),
|
||||||
|
path('active-products-autocomplete', views.ActiveProductsAutocomplete.as_view(), name="active-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"),
|
||||||
path('menus-autcomplete', views.MenusAutocomplete.as_view(), name="menus-autocomplete"),
|
path('menus-autcomplete', views.MenusAutocomplete.as_view(), name="menus-autocomplete"),
|
||||||
|
|
|
@ -420,14 +420,14 @@ def productProfile(request, pk):
|
||||||
|
|
||||||
@active_required
|
@active_required
|
||||||
@login_required
|
@login_required
|
||||||
def getProduct(request, barcode):
|
def getProduct(request, pk):
|
||||||
"""
|
"""
|
||||||
Get :model:`gestion.Product` by barcode. Called by a js/JQuery script
|
Get :model:`gestion.Product` by barcode. Called by a js/JQuery script
|
||||||
|
|
||||||
``barcode``
|
``pk``
|
||||||
The requested barcode
|
The requested pk
|
||||||
"""
|
"""
|
||||||
product = Product.objects.get(barcode=barcode)
|
product = Product.objects.get(pk=pk)
|
||||||
if product.category == Product.P_PRESSION:
|
if product.category == Product.P_PRESSION:
|
||||||
nb_pintes = 1
|
nb_pintes = 1
|
||||||
else:
|
else:
|
||||||
|
@ -461,6 +461,16 @@ class ProductsAutocomplete(autocomplete.Select2QuerySetView):
|
||||||
qs = qs.filter(name__istartswith=self.q)
|
qs = qs.filter(name__istartswith=self.q)
|
||||||
return qs
|
return qs
|
||||||
|
|
||||||
|
class ActiveProductsAutocomplete(autocomplete.Select2QuerySetView):
|
||||||
|
"""
|
||||||
|
Autocomplete view for active :model:`gestion.Product`
|
||||||
|
"""
|
||||||
|
def get_queryset(self):
|
||||||
|
qs = Product.objects.filter(is_active=True)
|
||||||
|
if self.q:
|
||||||
|
qs = qs.filter(name__istartswith=self.q)
|
||||||
|
return qs
|
||||||
|
|
||||||
########## Kegs ##########
|
########## Kegs ##########
|
||||||
|
|
||||||
@active_required
|
@active_required
|
||||||
|
@ -851,14 +861,14 @@ def switch_activate_menu(request, pk):
|
||||||
@active_required
|
@active_required
|
||||||
@login_required
|
@login_required
|
||||||
@permission_required('gestion.view_menu')
|
@permission_required('gestion.view_menu')
|
||||||
def get_menu(request, barcode):
|
def get_menu(request, pk):
|
||||||
"""
|
"""
|
||||||
Search :model:`gestion.Menu` by barcode
|
Search :model:`gestion.Menu` by barcode
|
||||||
|
|
||||||
``barcode``
|
``pk``
|
||||||
The requested barcode
|
The requested pk
|
||||||
"""
|
"""
|
||||||
menu = get_object_or_404(Menu, barcode=barcode)
|
menu = get_object_or_404(Menu, pk=pk)
|
||||||
nb_pintes = 0
|
nb_pintes = 0
|
||||||
for article in menu.articles:
|
for article in menu.articles:
|
||||||
if article.category == Product.P_PRESSION:
|
if article.category == Product.P_PRESSION:
|
||||||
|
|
|
@ -11,20 +11,19 @@ use_pinte_monitoring = false;
|
||||||
|
|
||||||
function get_config(){
|
function get_config(){
|
||||||
res = $.get("../preferences/getConfig", function(data){
|
res = $.get("../preferences/getConfig", function(data){
|
||||||
console.log(data.use_pinte_monitoring)
|
|
||||||
use_pinte_monitoring = data.use_pinte_monitoring;
|
use_pinte_monitoring = data.use_pinte_monitoring;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function get_product(barcode){
|
function get_product(id){
|
||||||
res = $.get("getProduct/" + barcode, function(data){
|
res = $.get("getProduct/" + id, function(data){
|
||||||
nbPintes += data.nb_pintes;
|
nbPintes += data.nb_pintes;
|
||||||
add_product(data.pk, data.barcode, data.name, data.amount, data.needQuantityButton);
|
add_product(data.pk, data.barcode, data.name, data.amount, data.needQuantityButton);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function get_menu(barcode){
|
function get_menu(id){
|
||||||
res = $.get("getMenu/" + barcode, function(data){
|
res = $.get("getMenu/" + id, function(data){
|
||||||
nbPintes += data.nb_pintes;
|
nbPintes += data.nb_pintes;
|
||||||
add_menu(data.pk, data.barcode, data.name, data.amount, data.needQuantityButton);
|
add_menu(data.pk, data.barcode, data.name, data.amount, data.needQuantityButton);
|
||||||
});
|
});
|
||||||
|
@ -115,12 +114,15 @@ function updateMenuInput(a){
|
||||||
|
|
||||||
$(document).ready(function(){
|
$(document).ready(function(){
|
||||||
get_config();
|
get_config();
|
||||||
|
|
||||||
$(".product").click(function(){
|
$(".product").click(function(){
|
||||||
product = get_product($(this).attr('target'));
|
product = get_product($(this).attr('target'));
|
||||||
});
|
});
|
||||||
|
|
||||||
$(".menu").click(function(){
|
$(".menu").click(function(){
|
||||||
menu = get_menu($(this).attr('target'));
|
menu = get_menu($(this).attr('target'));
|
||||||
})
|
});
|
||||||
|
|
||||||
$("#id_client").on('change', function(){
|
$("#id_client").on('change', function(){
|
||||||
id = $("#id_client").val();
|
id = $("#id_client").val();
|
||||||
$.get("/users/getUser/" + id, function(data){
|
$.get("/users/getUser/" + id, function(data){
|
||||||
|
@ -133,6 +135,11 @@ $(document).ready(function(){
|
||||||
window.location.reload()
|
window.location.reload()
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
$("#id_product").on('change', function(){
|
||||||
|
product = get_product(parseInt($("#id_product").val()));
|
||||||
|
});
|
||||||
|
|
||||||
$(".pay_button").click(function(){
|
$(".pay_button").click(function(){
|
||||||
if(use_pinte_monitoring){
|
if(use_pinte_monitoring){
|
||||||
message = "Il reste " + nbPintes.toString() + " pintes à renseigner. Numéro de la pinte ?"
|
message = "Il reste " + nbPintes.toString() + " pintes à renseigner. Numéro de la pinte ?"
|
||||||
|
|
Loading…
Reference in a new issue