3
0
Fork 0
mirror of https://github.com/nanoy42/coope synced 2024-11-22 11:23:11 +00:00

Proprification de order et easy_cotis

This commit is contained in:
Yoann Pétri 2019-01-22 20:27:18 +01:00
parent cf038ae493
commit 424da8261c
8 changed files with 221 additions and 100 deletions

View file

@ -115,6 +115,19 @@
<div class="boutonProduit"> <div class="boutonProduit">
<table> <table>
<tbody class="actions" id="bouton Produit"> <tbody class="actions" id="bouton Produit">
<tr class="cotisation-hidden" style="text-align:center; font-weight:bold;"><td colspan="4">Cotisations</td></tr>
{% for cotisation in cotisations %}
{% if forloop.counter0|divisibleby:4 %}
<tr class="cotisation-hidden" style="text-align:center">
{% endif %}
<td class="cotisation-hidden"><button class="cotisation" target="{{cotisation.pk}}">Cotisation {{cotisation.duration}} jours ({{cotisation.amount}} €)</button></td>
{% if forloop.counter|divisibleby:4 %}
</tr>
{% endif %}
{% endfor %}
{% if not bieresPression|divisibleby:4 %}
</tr>
{% endif %}
<tr style="text-align:center; font-weight:bold;"><td colspan="4">Bières pression</td></tr> <tr style="text-align:center; font-weight:bold;"><td colspan="4">Bières pression</td></tr>
{% for product in bieresPression %} {% for product in bieresPression %}
{% if forloop.counter0|divisibleby:4 %} {% if forloop.counter0|divisibleby:4 %}

View file

@ -7,19 +7,20 @@ from django.views.decorators.csrf import csrf_exempt
from django.contrib.auth.decorators import login_required, permission_required from django.contrib.auth.decorators import login_required, permission_required
from django.utils import timezone from django.utils import timezone
from django.http import HttpResponseRedirect from django.http import HttpResponseRedirect
from django.db import transaction
from datetime import datetime, timedelta
from django_tex.views import render_to_pdf from django_tex.views import render_to_pdf
from coopeV3.acl import active_required, acl_or, admin_required from coopeV3.acl import active_required, acl_or, admin_required
import simplejson as json import simplejson as json
from dal import autocomplete from dal import autocomplete
from decimal import * from decimal import *
import datetime
from .forms import ReloadForm, RefundForm, ProductForm, KegForm, MenuForm, GestionForm, SearchMenuForm, SearchProductForm, SelectPositiveKegForm, SelectActiveKegForm, PinteForm, GenerateReleveForm from .forms import ReloadForm, RefundForm, ProductForm, KegForm, MenuForm, GestionForm, SearchMenuForm, SearchProductForm, SelectPositiveKegForm, SelectActiveKegForm, PinteForm, GenerateReleveForm
from .models import Product, Menu, Keg, ConsumptionHistory, KegHistory, Consumption, MenuHistory, Pinte, Reload, Refund from .models import Product, Menu, Keg, ConsumptionHistory, KegHistory, Consumption, MenuHistory, Pinte, Reload, Refund
from preferences.models import PaymentMethod, GeneralPreferences from preferences.models import PaymentMethod, GeneralPreferences, Cotisation
from users.models import CotisationHistory from users.models import CotisationHistory
@active_required @active_required
@ -77,6 +78,7 @@ def manage(request):
menus = Menu.objects.filter(is_active=True) menus = Menu.objects.filter(is_active=True)
kegs = Keg.objects.filter(is_active=True) kegs = Keg.objects.filter(is_active=True)
gp, _ = GeneralPreferences.objects.get_or_create(pk=1) gp, _ = GeneralPreferences.objects.get_or_create(pk=1)
cotisations = Cotisation.objects.all()
floating_buttons = gp.floating_buttons floating_buttons = gp.floating_buttons
for keg in kegs: for keg in kegs:
if(keg.pinte): if(keg.pinte):
@ -97,6 +99,7 @@ def manage(request):
"menus": menus, "menus": menus,
"pay_buttons": pay_buttons, "pay_buttons": pay_buttons,
"floating_buttons": floating_buttons, "floating_buttons": floating_buttons,
"cotisations": cotisations
}) })
@csrf_exempt @csrf_exempt
@ -107,8 +110,11 @@ def order(request):
""" """
Process the given order. Called by a js/JQuery script. Process the given order. Called by a js/JQuery script.
""" """
error_message = "Impossible d'effectuer la transaction. Toute opération abandonnée. Veuillez contacter le président ou le trésorier"
try:
with transaction.atomic():
if("user" not in request.POST or "paymentMethod" not in request.POST or "amount" not in request.POST or "order" not in request.POST): if("user" not in request.POST or "paymentMethod" not in request.POST or "amount" not in request.POST or "order" not in request.POST):
return HttpResponse("Erreur du POST") raise Exception("Erreur du post")
else: else:
user = get_object_or_404(User, pk=request.POST['user']) user = get_object_or_404(User, pk=request.POST['user'])
paymentMethod = get_object_or_404(PaymentMethod, pk=request.POST['paymentMethod']) paymentMethod = get_object_or_404(PaymentMethod, pk=request.POST['paymentMethod'])
@ -116,9 +122,34 @@ def order(request):
order = json.loads(request.POST["order"]) order = json.loads(request.POST["order"])
menus = json.loads(request.POST["menus"]) menus = json.loads(request.POST["menus"])
listPintes = json.loads(request.POST["listPintes"]) listPintes = json.loads(request.POST["listPintes"])
cotisations = json.loads(request.POST['cotisations'])
gp,_ = GeneralPreferences.objects.get_or_create(pk=1) gp,_ = GeneralPreferences.objects.get_or_create(pk=1)
if (not order) and (not menus): if (not order) and (not menus) and (not cotisations):
return HttpResponse("Pas de commande") error_message = "Pas de commande"
raise Exception(error_message)
if(cotisations):
for co in cotisations:
cotisation = Cotisation.objects.get(pk=co['pk'])
for i in range(co['quantity']):
cotisation_history = CotisationHistory(cotisation=cotisation)
if(paymentMethod.affect_balance):
if(user.profile.balance >= cotisation_history.cotisation.amount):
user.profile.debit += cotisation_history.cotisation.amount
else:
error_message = "Solde insuffisant"
raise Exception(error_message)
cotisation_history.user = user
cotisation_history.coopeman = request.user
cotisation_history.amount = cotisation.amount
cotisation_history.duration = cotisation.duration
cotisation_history.paymentMethod = paymentMethod
if(user.profile.cotisationEnd and user.profile.cotisationEnd > timezone.now()):
cotisation_history.endDate = user.profile.cotisationEnd + timedelta(days=cotisation.duration)
else:
cotisation_history.endDate = timezone.now() + timedelta(days=cotisation.duration)
user.profile.cotisationEnd = cotisation_history.endDate
user.save()
cotisation_history.save()
adherentRequired = False adherentRequired = False
for o in order: for o in order:
product = get_object_or_404(Product, pk=o["pk"]) product = get_object_or_404(Product, pk=o["pk"])
@ -127,18 +158,21 @@ def order(request):
menu = get_object_or_404(Menu, pk=m["pk"]) menu = get_object_or_404(Menu, pk=m["pk"])
adherentRequired = adherentRequired or menu.adherent_required adherentRequired = adherentRequired or menu.adherent_required
if(adherentRequired and not user.profile.is_adherent): if(adherentRequired and not user.profile.is_adherent):
return HttpResponse("N'est pas adhérent et devrait l'être") error_message = "N'est pas adhérent et devrait l'être."
raise Exception(error_message)
# Partie un peu complexe : je libère toutes les pintes de la commande, puis je test # Partie un peu complexe : je libère toutes les pintes de la commande, puis je test
# s'il a trop de pintes non rendues, puis je réalloue les pintes # s'il a trop de pintes non rendues, puis je réalloue les pintes
for pinte in listPintes: for pinte in listPintes:
allocate(pinte, None) allocate(pinte, None)
if(gp.lost_pintes_allowed and user.profile.nb_pintes >= gp.lost_pintes_allowed): if(gp.use_pinte_monitoring and gp.lost_pintes_allowed and user.profile.nb_pintes >= gp.lost_pintes_allowed):
return HttpResponse("Impossible de réaliser la commande : l'utilisateur a perdu trop de pintes.") error_message = "Impossible de réaliser la commande : l'utilisateur a perdu trop de pintes."
raise Exception(error_message)
for pinte in listPintes: for pinte in listPintes:
allocate(pinte, user) allocate(pinte, user)
if(paymentMethod.affect_balance): if(paymentMethod.affect_balance):
if(user.profile.balance < amount): if(user.profile.balance < amount):
return HttpResponse("Solde inférieur au prix de la commande") error_message = "Solde inférieur au prix de la commande"
raise Exception(error_message)
else: else:
user.profile.debit += amount user.profile.debit += amount
user.save() user.save()
@ -148,7 +182,7 @@ def order(request):
if(product.category == Product.P_PRESSION): if(product.category == Product.P_PRESSION):
keg = get_object_or_404(Keg, pinte=product) keg = get_object_or_404(Keg, pinte=product)
if(not keg.is_active): if(not keg.is_active):
return HttpResponse("Une erreur inconnue s'est produite. Veuillez contacter le trésorier ou le président") raise Exception("Fût non actif")
kegHistory = get_object_or_404(KegHistory, keg=keg, isCurrentKegHistory=True) kegHistory = get_object_or_404(KegHistory, keg=keg, isCurrentKegHistory=True)
kegHistory.quantitySold += Decimal(quantity * 0.5) kegHistory.quantitySold += Decimal(quantity * 0.5)
kegHistory.amountSold += Decimal(quantity * product.amount) kegHistory.amountSold += Decimal(quantity * product.amount)
@ -156,7 +190,7 @@ def order(request):
elif(product.category == Product.D_PRESSION): elif(product.category == Product.D_PRESSION):
keg = get_object_or_404(Keg, demi=product) keg = get_object_or_404(Keg, demi=product)
if(not keg.is_active): if(not keg.is_active):
return HttpResponse("Une erreur inconnue s'est produite. Veuillez contacter le trésorier ou le président") raise Exception("Fût non actif")
kegHistory = get_object_or_404(KegHistory, keg=keg, isCurrentKegHistory=True) kegHistory = get_object_or_404(KegHistory, keg=keg, isCurrentKegHistory=True)
kegHistory.quantitySold += Decimal(quantity * 0.25) kegHistory.quantitySold += Decimal(quantity * 0.25)
kegHistory.amountSold += Decimal(quantity * product.amount) kegHistory.amountSold += Decimal(quantity * product.amount)
@ -164,7 +198,7 @@ def order(request):
elif(product.category == Product.G_PRESSION): elif(product.category == Product.G_PRESSION):
keg = get_object_or_404(Keg, galopin=product) keg = get_object_or_404(Keg, galopin=product)
if(not keg.is_active): if(not keg.is_active):
return HttpResponse("Une erreur inconnue s'est produite. Veuillez contacter le trésorier ou le président") raise Exception("Fût non actif")
kegHistory = get_object_or_404(KegHistory, keg=keg, isCurrentKegHistory=True) kegHistory = get_object_or_404(KegHistory, keg=keg, isCurrentKegHistory=True)
kegHistory.quantitySold += Decimal(quantity * 0.125) kegHistory.quantitySold += Decimal(quantity * 0.125)
kegHistory.amountSold += Decimal(quantity * product.amount) kegHistory.amountSold += Decimal(quantity * product.amount)
@ -178,11 +212,21 @@ def order(request):
consumption.save() consumption.save()
ch = ConsumptionHistory(customer=user, quantity=quantity, paymentMethod=paymentMethod, product=product, amount=Decimal(quantity*product.amount), coopeman=request.user) ch = ConsumptionHistory(customer=user, quantity=quantity, paymentMethod=paymentMethod, product=product, amount=Decimal(quantity*product.amount), coopeman=request.user)
ch.save() ch.save()
if(user.profile.balance > Decimal(product.amount * quantity)):
user.profile.debit += Decimal(product.amount*quantity)
else:
error_message = "Solde insuffisant"
raise Exception(error_message)
for m in menus: for m in menus:
menu = get_object_or_404(Menu, pk=m["pk"]) menu = get_object_or_404(Menu, pk=m["pk"])
quantity = int(m["quantity"]) quantity = int(m["quantity"])
mh = MenuHistory(customer=user, quantity=quantity, paymentMethod=paymentMethod, menu=menu, amount=int(quantity*menu.amount), coopeman=request.user) mh = MenuHistory(customer=user, quantity=quantity, paymentMethod=paymentMethod, menu=menu, amount=int(quantity*menu.amount), coopeman=request.user)
mh.save() mh.save()
if(user.profile.balance > Decimal(menu.amount * quantity)):
user.profile.debit += Decimal(menu.amount*quantity)
else:
error_message = "Solde insuffisant"
raise Exception(error_message)
for article in menu.articles.all(): for article in menu.articles.all():
consumption, _ = Consumption.objects.get_or_create(customer=user, product=article) consumption, _ = Consumption.objects.get_or_create(customer=user, product=article)
consumption.quantity += quantity consumption.quantity += quantity
@ -191,6 +235,10 @@ def order(request):
article.stockHold -= 1 article.stockHold -= 1
article.save() article.save()
return HttpResponse("La commande a bien été effectuée") return HttpResponse("La commande a bien été effectuée")
except Exception as e:
print(e)
print("test")
return HttpResponse(error_message)
@active_required @active_required
@login_required @login_required
@ -899,7 +947,7 @@ def get_menu(request, pk):
for article in menu.articles: for article in menu.articles:
if article.category == Product.P_PRESSION: if article.category == Product.P_PRESSION:
nb_pintes +=1 nb_pintes +=1
data = json.dumps({"pk": menu.pk, "barcode" : menu.barcode, "name": menu.name, "amount" : menu.amount, needQuantityButton: False, "nb_pintes": nb_pintes}) data = json.dumps({"pk": menu.pk, "barcode" : menu.barcode, "name": menu.name, "amount" : menu.amount, "needQuantityButton": False, "nb_pintes": nb_pintes})
return HttpResponse(data, content_type='application/json') return HttpResponse(data, content_type='application/json')
class MenusAutocomplete(autocomplete.Select2QuerySetView): class MenusAutocomplete(autocomplete.Select2QuerySetView):
@ -1074,7 +1122,7 @@ def gen_releve(request):
value_lydia += cot.amount value_lydia += cot.amount
elif pm == cheque: elif pm == cheque:
value_cheque += cot.amount value_cheque += cot.amount
now = datetime.datetime.now() now = datetime.now()
return render_to_pdf(request, 'gestion/releve.tex', {"consumptions": consumptions, "reloads": reloads, "refunds": refunds, "cotisations": cotisations, "begin": begin, "end": end, "now": now, "value_especes": value_especes, "value_lydia": value_lydia, "value_cheque": value_cheque}, filename="releve.pdf") return render_to_pdf(request, 'gestion/releve.tex', {"consumptions": consumptions, "reloads": reloads, "refunds": refunds, "cotisations": cotisations, "begin": begin, "end": end, "now": now, "value_especes": value_especes, "value_lydia": value_lydia, "value_cheque": value_cheque}, filename="releve.pdf")
else: else:
return render(request, "form.html", {"form": form, "form_title": "Génération d'un relevé", "form_button": "Générer", "form_button_icon": "file-pdf"}) return render(request, "form.html", {"form": form, "form_title": "Génération d'un relevé", "form_button": "Générer", "form_button_icon": "file-pdf"})

View file

@ -15,4 +15,5 @@ urlpatterns = [
path('deletePaymentMethod/<int:pk>', views.deletePaymentMethod, name="deletePaymentMethod"), path('deletePaymentMethod/<int:pk>', views.deletePaymentMethod, name="deletePaymentMethod"),
path('inactive', views.inactive, name="inactive"), path('inactive', views.inactive, name="inactive"),
path('getConfig', views.get_config, name="getConfig"), path('getConfig', views.get_config, name="getConfig"),
] path('getCotisation/<int:pk>', views.get_cotisation, name="getCotisation")
,]

View file

@ -1,4 +1,4 @@
import json import simplejson as json
from django.shortcuts import render, redirect, get_object_or_404 from django.shortcuts import render, redirect, get_object_or_404
from django.contrib import messages from django.contrib import messages
@ -135,6 +135,19 @@ def deleteCotisation(request,pk):
messages.success(request, message) messages.success(request, message)
return redirect(reverse('preferences:cotisationsIndex')) return redirect(reverse('preferences:cotisationsIndex'))
@active_required
@login_required
@permission_required('preferences.view_cotisation')
def get_cotisation(request, pk):
"""
Get a cotisation by pk
``pk``
The primary key of the cotisation
"""
cotisation = get_object_or_404(Cotisation, pk=pk)
data = json.dumps({"pk": cotisation.pk, "duration": cotisation.duration, "amount" : cotisation.amount, "needQuantityButton": False})
return HttpResponse(data, content_type='application/json')
########## Payment Methods ########## ########## Payment Methods ##########

View file

@ -1,10 +1,11 @@
total = 0 total = 0
products = [] products = []
menus = [] menus = []
cotisations = []
paymentMethod = null paymentMethod = null
balance = 0 balance = 0
username = "" username = ""
id = 0 id_user = 0
listPintes = [] listPintes = []
nbPintes = 0; nbPintes = 0;
use_pinte_monitoring = false; use_pinte_monitoring = false;
@ -29,9 +30,15 @@ function get_menu(id){
}); });
} }
function get_cotisation(id){
res = $.get("../preferences/getCotisation/" + id, function(data){
add_cotisation(data.pk, "", data.duration, data.amount, data.needQuantityButton);
});
}
function add_product(pk, barcode, name, amount, needQuantityButton){ function add_product(pk, barcode, name, amount, needQuantityButton){
exist = false exist = false
index = -1 index = -1;
for(k=0;k < products.length; k++){ for(k=0;k < products.length; k++){
if(products[k].pk == pk){ if(products[k].pk == pk){
exist = true exist = true
@ -71,15 +78,36 @@ function add_menu(pk, barcode, name, amount){
generate_html(); generate_html();
} }
function add_cotisation(pk, barcode, duration, amount){
exist = false;
index = -1;
for(k=0; k < cotisations.length; k++){
if(cotisations[k].pk == pk){
exist = true;
index = k;
}
}
if(exist){
cotisations[index].quantity += 1;
}else{
cotisations.push({"pk": pk, "barcode": barcode, "duration": duration, "amount": amount, "quantity":1});
}
generate_html();
}
function generate_html(){ function generate_html(){
html = ""; html = "";
for(k=0;k<cotisations.length;k++){
cotisation = cotisations[k];
html += '<tr><td></td><td>Cotisation ' + String(cotisation.duration) + ' jours</td><td>' + String(cotisation.amount) + ' €</td><td><input type="number" data-target="' + String(k) + '" onChange="updateCotisationInput(this)" value="' + String(cotisation.quantity) + '"/></td><td>' + String(Number((cotisation.quantity * cotisation.amount).toFixed(2))) + ' €</td></tr>';
}
for(k=0;k<products.length;k++){ for(k=0;k<products.length;k++){
product = products[k] product = products[k]
html += '<tr><td>' + product.barcode + '</td><td>' + product.name + '</td><td>' + String(product.amount) + '</td><td><input type="number" data-target="' + String(k) + '" onChange="updateInput(this)" value="' + String(product.quantity) + '"/></td><td>' + String(Number((product.quantity * product.amount).toFixed(2))) + '</td></tr>'; html += '<tr><td>' + product.barcode + '</td><td>' + product.name + '</td><td>' + String(product.amount) + '</td><td><input type="number" data-target="' + String(k) + '" onChange="updateInput(this)" value="' + String(product.quantity) + '"/></td><td>' + String(Number((product.quantity * product.amount).toFixed(2))) + '</td></tr>';
} }
for(k=0; k<menus.length;k++){ for(k=0; k<menus.length;k++){
menu = menus[k] menu = menus[k]
html += '<tr><td>' + menu.barcode + '</td><td>' + menu.name + '</td><td>' + String(menu.amount) + '</td><td><input type="number" data-target="' + String(k) + '" onChange="updateMenuInput(this)" value="' + String(menu.quantity) + '"/></td><td>' + String(Number((menu.quantity * menu.amount).toFixed(2))) + '</td></tr>'; html += '<tr><td>' + menu.barcode + '</td><td>' + menu.name + '</td><td>' + String(menu.amount) + '</td><td><input type="number" data-target="' + String(k) + '" onChange="updateMenuInput(this)" value="' + String(menu.quantity) + '"/></td><td>' + String(Number((menu.quantity * menu.amount).toFixed(2))) + '</td></tr>';
} }
$("#items").html(html) $("#items").html(html)
updateTotal(); updateTotal();
@ -93,6 +121,9 @@ function updateTotal(){
for(k=0; k<menus.length;k++){ for(k=0; k<menus.length;k++){
total += menus[k].quantity * menus[k].amount; total += menus[k].quantity * menus[k].amount;
} }
for(k=0; k<cotisations.length;k++){
total += cotisations[k].quantity * cotisations[k].amount;
}
$("#totalAmount").text(String(Number(total.toFixed(2))) + "€") $("#totalAmount").text(String(Number(total.toFixed(2))) + "€")
totalAfter = balance - total totalAfter = balance - total
$("#totalAfter").text(String(Number(totalAfter.toFixed(2))) + "€") $("#totalAfter").text(String(Number(totalAfter.toFixed(2))) + "€")
@ -112,7 +143,15 @@ function updateMenuInput(a){
generate_html(); generate_html();
} }
function updateCotisationInput(a){
quantity = parseInt(a.value);
k = parseInt(a.getAttribute("data-target"));
cotisations[k].quantity = quantity;
generate_html();
}
$(document).ready(function(){ $(document).ready(function(){
$(".cotisation-hidden").hide();
get_config(); get_config();
$(".product").click(function(){ $(".product").click(function(){
@ -123,12 +162,20 @@ $(document).ready(function(){
menu = get_menu($(this).attr('target')); menu = get_menu($(this).attr('target'));
}); });
$(".cotisation").click(function(){
cotisation = get_cotisation($(this).attr('target'));
});
$("#id_client").on('change', function(){ $("#id_client").on('change', function(){
id = $("#id_client").val(); id_user = $("#id_client").val();
$.get("/users/getUser/" + id, function(data){ $.get("/users/getUser/" + id_user, function(data){
balance = data.balance; balance = data.balance;
username = data.username; username = data.username;
is_adherent = data.is_adherent;
$("#balance").html(balance + "€"); $("#balance").html(balance + "€");
if(!is_adherent){
$(".cotisation-hidden").show();
}
updateTotal(); updateTotal();
}).fail(function(){ }).fail(function(){
alert("Une erreur inconnue est survenue"); alert("Une erreur inconnue est survenue");
@ -159,7 +206,7 @@ $(document).ready(function(){
} }
} }
} }
$.post("order", {"user":id, "paymentMethod": $(this).attr('data-payment'), "order_length": products.length + menus.length, "order": JSON.stringify(products), "amount": total, "menus": JSON.stringify(menus), "listPintes": JSON.stringify(listPintes)}, function(data){ $.post("order", {"user":id_user, "paymentMethod": $(this).attr('data-payment'), "order_length": products.length + menus.length + cotisations.length, "order": JSON.stringify(products), "amount": total, "menus": JSON.stringify(menus), "listPintes": JSON.stringify(listPintes), "cotisations": JSON.stringify(cotisations)}, function(data){
alert(data); alert(data);
location.reload(); location.reload();
}).fail(function(data){ }).fail(function(data){

View file

@ -9,7 +9,6 @@
<link rel="icon" sizes="32x32" href="{% static 'favicon32.ico' %}" type="image/x-icon"> <link rel="icon" sizes="32x32" href="{% static 'favicon32.ico' %}" type="image/x-icon">
<link rel="icon" sizes="96x96" href="{% static 'favicon96.ico' %}" type="image/x-icon"> <link rel="icon" sizes="96x96" href="{% static 'favicon96.ico' %}" type="image/x-icon">
<link rel="stylesheet" href="{% static 'css/main.css' %}" /> <link rel="stylesheet" href="{% static 'css/main.css' %}" />
<script src="{% static 'jquery.js' %}"></script>
{% block extra_css %}{% endblock %} {% block extra_css %}{% endblock %}
{% block extra_script %}{% endblock %} {% block extra_script %}{% endblock %}
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.6.3/css/all.css" integrity="sha384-UHRtZLI+pbxtHCWp1t77Bi1L4ZtiqrqD80Kn4Z8NTSRyMA2Fd33n5dQ8lWUE00s/" crossorigin="anonymous"> <link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.6.3/css/all.css" integrity="sha384-UHRtZLI+pbxtHCWp1t77Bi1L4ZtiqrqD80Kn4Z8NTSRyMA2Fd33n5dQ8lWUE00s/" crossorigin="anonymous">

View file

@ -2,7 +2,7 @@
{% load static %} {% load static %}
{% load users_extra %} {% load users_extra %}
{% block entete %}{% if self %}Mon Profil{% else %}Profil de {{user}}{% endif %}{%endblock%} {% block entete %}{% if self %}Mon Profil{% else %}Profil de {{user}}{% endif %}{%endblock%}
{% block extra_script %}<script src="{% static 'jquery.js' %}"></script>{% endblock %}
{% block navbar %} {% block navbar %}
<ul> <ul>
<li><a href="#first">{% if self %}Mes informations {% else %} Informations {% endif %}</a> <li><a href="#first">{% if self %}Mes informations {% else %} Informations {% endif %}</a>

View file

@ -413,7 +413,7 @@ def getUser(request, pk):
The pk of the user The pk of the user
""" """
user = get_object_or_404(User, pk=pk) user = get_object_or_404(User, pk=pk)
data = json.dumps({"username": user.username, "balance": user.profile.balance}) data = json.dumps({"username": user.username, "balance": user.profile.balance, "is_adherent": user.profile.is_adherent})
return HttpResponse(data, content_type='application/json') return HttpResponse(data, content_type='application/json')
@active_required @active_required