Commit 6f622fdc authored by Patrick's avatar Patrick

Using user.is_authenticated() and user.is_anonymous() as a method is...

Using user.is_authenticated() and user.is_anonymous() as a method is deprecated. Remove the parentheses to use it as an attribute.
parent 95e4c9f6
......@@ -18,7 +18,7 @@ class PermanenceMenu(Menu):
def get_nodes(self, request):
from apps import REPANIER_SETTINGS_PERMANENCES_NAME, REPANIER_SETTINGS_INVOICE
user = request.user
if user.is_anonymous() or user.is_staff:
if user.is_anonymous or user.is_staff:
is_anonymous = True
else:
is_anonymous = False
......
......@@ -20,7 +20,7 @@ from repanier.tools import on_hold_movement_message
def basket_message_form_ajax(request, customer_id):
if request.is_ajax():
user = request.user
if user.is_anonymous():
if user.is_anonymous:
return HttpResponse(EMPTY_STRING)
to_json = []
if request.user.is_staff:
......
......@@ -26,7 +26,7 @@ def btn_confirm_order_ajax(request):
raise Http404
permanence_id = sint(request.GET.get('permanence', 0))
user = request.user
if not user.is_authenticated():
if not user.is_authenticated:
raise Http404
customer = Customer.objects.filter(
user_id=user.id, is_active=True, may_order=True).order_by('?').first()
......
......@@ -13,7 +13,7 @@ from django.views.decorators.http import require_GET
def customer_name_ajax(request):
if request.is_ajax():
user = request.user
if user.is_anonymous():
if user.is_anonymous:
result = _('Anonymous')
else:
result = user.username
......
......@@ -20,7 +20,7 @@ from repanier.tools import sint, sboolean, calc_basket_message, my_order_confirm
def delivery_ajax(request):
if request.is_ajax():
user = request.user
if user.is_authenticated():
if user.is_authenticated:
permanence_id = sint(request.GET.get('permanence', 0))
basket = sboolean(request.GET.get('basket', False))
permanence = Permanence.objects.filter(id=permanence_id) \
......
......@@ -26,7 +26,7 @@ def delivery_select_ajax(request):
# construct a list which will contain all of the data for the response
user = request.user
to_json = []
if user.is_authenticated():
if user.is_authenticated:
customer = Customer.objects.filter(
user_id=user.id, is_active=True, may_order=True) \
.only("id", "language", "delivery_point").order_by('?').first()
......
......@@ -19,7 +19,7 @@ from repanier.tools import sint
def like_ajax(request):
if request.is_ajax():
user = request.user
if user.is_authenticated():
if user.is_authenticated:
offer_item_id = sint(request.GET.get('offer_item', 0))
offer_item = OfferItem.objects.filter(id=offer_item_id).order_by('?').select_related("product").first()
if offer_item is not None:
......
......@@ -17,7 +17,7 @@ from repanier.models import CustomerInvoice
def my_balance_ajax(request):
if request.is_ajax():
user = request.user
if user.is_anonymous() or user.is_staff or user.is_superuser:
if user.is_anonymous or user.is_staff or user.is_superuser:
return HttpResponse(EMPTY_STRING)
last_customer_invoice = CustomerInvoice.objects.filter(
customer__user_id=request.user.id,
......
......@@ -20,7 +20,7 @@ def order_ajax(request):
if not request.is_ajax():
raise Http404
user = request.user
if not user.is_authenticated():
if not user.is_authenticated:
raise Http404
customer = Customer.objects.filter(
user_id=user.id, is_active=True, may_order=True
......
......@@ -49,7 +49,7 @@ class OrderView(ListView):
self.like = False
if self.permanence.with_delivery_point:
self.delivery_id = sint(kwargs.get('delivery_id', 0))
if self.user.is_anonymous() or self.user.is_staff:
if self.user.is_anonymous or self.user.is_staff:
self.is_anonymous = True
self.may_order = False
self.q = None
......
......@@ -35,7 +35,7 @@ def order_init_ajax(request):
raise Http404
user = request.user
to_json = []
if user.is_authenticated():
if user.is_authenticated:
permanence = permanence_qs.prefetch_related("producers").first()
customer = Customer.objects.filter(
user_id=user.id, is_active=True
......@@ -169,7 +169,7 @@ def order_init_ajax(request):
request_offer_items = request.GET.getlist('oi')
for request_offer_item in request_offer_items:
offer_item_id = sint(request_offer_item)
if user.is_authenticated() and customer is not None:
if user.is_authenticated and customer is not None:
# No need to check customer.may_order.
# Select one purchase
purchase = Purchase.objects.filter(
......
......@@ -25,7 +25,7 @@ def order_select_ajax(request):
# construct a list which will contain all of the data for the response
user = request.user
to_json = []
if user.is_authenticated():
if user.is_authenticated:
customer = Customer.objects.filter(
user_id=user.id, is_active=True, may_order=True) \
.only("id", "vat_id", "language").order_by('?').first()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment