Verified Commit 97c316b6 authored by Sli's avatar Sli
Browse files

django2.2: replace removed is_anonymous() and is_authenticated to their now used counterparts

parent 90921fd4
......@@ -37,7 +37,7 @@ AnonymousUser = getattr(importlib.import_module(module), klass)
def get_cached_user(request):
if not hasattr(request, "_cached_user"):
user = get_user(request)
if user.is_anonymous():
if user.is_anonymous:
user = AnonymousUser(request)
request._cached_user = user
......
......@@ -39,7 +39,7 @@
</div>
<header>
{% if not user.is_authenticated() %}
{% if not user.is_authenticated %}
<div id="header_logo" style="background-image: url('{{ static('core/img/logo.png') }}'); width: 185px; height: 100px;">
<a href="{{ url('core:index') }}"></a>
</div>
......
......@@ -11,7 +11,7 @@
{% endif %}
{% if next %}
{% if user.is_authenticated() %}
{% if user.is_authenticated %}
<p>{% trans %}Your account doesn't have access to this page. To proceed,
please login with an account that has access.{% endtrans %}</p>
{% else %}
......
......@@ -150,7 +150,7 @@ class CanCreateMixin(View):
def dispatch(self, request, *arg, **kwargs):
res = super(CanCreateMixin, self).dispatch(request, *arg, **kwargs)
if not request.user.is_authenticated():
if not request.user.is_authenticated:
raise PermissionDenied
return res
......
......@@ -289,7 +289,7 @@ class FileView(CanViewMixin, DetailView, FormMixin):
self.form = self.get_form() # The form handle only the file upload
files = request.FILES.getlist("file_field")
if (
request.user.is_authenticated()
request.user.is_authenticated
and request.user.can_edit(self.object)
and self.form.is_valid()
):
......
......@@ -689,7 +689,7 @@ class UserUpdateProfileView(UserTabsMixin, CanEditMixin, UpdateView):
files = request.FILES.items()
self.form.process(files)
if (
request.user.is_authenticated()
request.user.is_authenticated
and request.user.can_edit(self.object)
and self.form.is_valid()
):
......
......@@ -323,7 +323,7 @@ class CounterMain(
)
if self.object.type == "BAR":
kwargs["barmen"] = self.object.get_barmen_list()
elif self.request.user.is_authenticated():
elif self.request.user.is_authenticated:
kwargs["barmen"] = [self.request.user]
if "last_basket" in self.request.session.keys():
kwargs["last_basket"] = self.request.session.pop("last_basket")
......@@ -372,7 +372,7 @@ class CounterClick(CounterTabsMixin, CanViewMixin, DetailView):
):
raise PermissionDenied
else:
if not request.user.is_authenticated():
if not request.user.is_authenticated:
raise PermissionDenied
return super(CounterClick, self).dispatch(request, *args, **kwargs)
......@@ -387,7 +387,7 @@ class CounterClick(CounterTabsMixin, CanViewMixin, DetailView):
request.session["no_age"] = False
self.refill_form = None
ret = super(CounterClick, self).get(request, *args, **kwargs)
if (self.object.type != "BAR" and not request.user.is_authenticated()) or (
if (self.object.type != "BAR" and not request.user.is_authenticated) or (
self.object.type == "BAR" and len(self.object.get_barmen_list()) < 1
): # Check that at least one barman is logged in
ret = self.cancel(request) # Otherwise, go to main view
......@@ -397,7 +397,7 @@ class CounterClick(CounterTabsMixin, CanViewMixin, DetailView):
""" Handle the many possibilities of the post request """
self.object = self.get_object()
self.refill_form = None
if (self.object.type != "BAR" and not request.user.is_authenticated()) or (
if (self.object.type != "BAR" and not request.user.is_authenticated) or (
self.object.type == "BAR" and len(self.object.get_barmen_list()) < 1
): # Check that at least one barman is logged in
return self.cancel(request)
......
......@@ -56,7 +56,7 @@ class EbouticMain(TemplateView):
request.session.modified = True
def get(self, request, *args, **kwargs):
if not request.user.is_authenticated():
if not request.user.is_authenticated:
return HttpResponseRedirect(
reverse_lazy("core:login", args=self.args, kwargs=kwargs)
+ "?next="
......@@ -67,7 +67,7 @@ class EbouticMain(TemplateView):
return super(EbouticMain, self).get(request, *args, **kwargs)
def post(self, request, *args, **kwargs):
if not request.user.is_authenticated():
if not request.user.is_authenticated:
return HttpResponseRedirect(
reverse_lazy("core:login", args=self.args, kwargs=kwargs)
+ "?next="
......@@ -118,7 +118,7 @@ class EbouticCommand(TemplateView):
template_name = "eboutic/eboutic_makecommand.jinja"
def get(self, request, *args, **kwargs):
if not request.user.is_authenticated():
if not request.user.is_authenticated:
return HttpResponseRedirect(
reverse_lazy("core:login", args=self.args, kwargs=kwargs)
+ "?next="
......@@ -129,7 +129,7 @@ class EbouticCommand(TemplateView):
)
def post(self, request, *args, **kwargs):
if not request.user.is_authenticated():
if not request.user.is_authenticated:
return HttpResponseRedirect(
reverse_lazy("core:login", args=self.args, kwargs=kwargs)
+ "?next="
......@@ -192,7 +192,7 @@ class EbouticPayWithSith(TemplateView):
with transaction.atomic():
if (
"basket_id" not in request.session.keys()
or not request.user.is_authenticated()
or not request.user.is_authenticated
):
return HttpResponseRedirect(
reverse_lazy("eboutic:main", args=self.args, kwargs=kwargs)
......
......@@ -553,7 +553,7 @@ class CandidatureUpdateView(CanEditMixin, UpdateView):
self.form = self.get_form()
self.remove_fields()
if (
request.user.is_authenticated()
request.user.is_authenticated
and request.user.can_edit(self.object)
and self.form.is_valid()
):
......@@ -597,7 +597,7 @@ class RoleUpdateView(CanEditMixin, UpdateView):
self.form = self.get_form()
self.remove_fields()
if (
request.user.is_authenticated()
request.user.is_authenticated
and request.user.can_edit(self.object)
and self.form.is_valid()
):
......
......@@ -84,7 +84,7 @@ class LaunderetteBookView(CanViewMixin, DetailView):
self.object = self.get_object()
if "slot_type" in request.POST.keys():
self.slot_type = request.POST["slot_type"]
if "slot" in request.POST.keys() and request.user.is_authenticated():
if "slot" in request.POST.keys() and request.user.is_authenticated:
self.subscriber = request.user
if self.subscriber.is_subscribed:
self.date = dateparse.parse_datetime(request.POST["slot"]).replace(
......
......@@ -117,7 +117,7 @@ class SASMainView(FormView):
parent = SithFile.objects.filter(id=settings.SITH_SAS_ROOT_DIR_ID).first()
files = request.FILES.getlist("images")
root = User.objects.filter(username="root").first()
if request.user.is_authenticated() and request.user.is_in_group(
if request.user.is_authenticated and request.user.is_in_group(
settings.SITH_GROUP_SAS_ADMIN_ID
):
if self.form.is_valid():
......@@ -176,7 +176,7 @@ class PictureView(CanViewMixin, DetailView, FormMixin):
def post(self, request, *args, **kwargs):
self.object = self.get_object()
self.form = self.get_form()
if request.user.is_authenticated() and request.user.was_subscribed:
if request.user.is_authenticated and request.user.was_subscribed:
if self.form.is_valid():
for uid in self.form.cleaned_data["users"]:
u = User.objects.filter(id=uid).first()
......@@ -233,7 +233,7 @@ class AlbumUploadView(CanViewMixin, DetailView, FormMixin):
self.form = self.get_form()
parent = SithFile.objects.filter(id=self.object.id).first()
files = request.FILES.getlist("images")
if request.user.is_authenticated() and request.user.is_subscribed:
if request.user.is_authenticated and request.user.is_subscribed:
if self.form.is_valid():
self.form.process(
parent=parent,
......@@ -279,7 +279,7 @@ class AlbumView(CanViewMixin, DetailView, FormMixin):
FileView.handle_clipboard(request, self.object)
parent = SithFile.objects.filter(id=self.object.id).first()
files = request.FILES.getlist("images")
if request.user.is_authenticated() and request.user.is_subscribed:
if request.user.is_authenticated and request.user.is_subscribed:
if self.form.is_valid():
self.form.process(
parent=parent,
......
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