mirror of
https://github.com/zulip/zulip.git
synced 2025-11-17 20:41:46 +00:00
django: Use request.user.is_authenticated consistently.
In Django 2.0, request.user.is_authenticated stops supporting `.is_authenticated()` and becomes just a property. In 1.11, it's a CallableProperty (i.e. can be used either way), and we already use it as a property in several other places, so we should just switch to using it consistently now to get it off of our Django 2.x migration checklist.
This commit is contained in:
@@ -88,7 +88,7 @@ def zulip_default_context(request: HttpRequest) -> Dict[str, Any]:
|
|||||||
|
|
||||||
user_is_authenticated = False
|
user_is_authenticated = False
|
||||||
if hasattr(request, 'user') and hasattr(request.user, 'is_authenticated'):
|
if hasattr(request, 'user') and hasattr(request.user, 'is_authenticated'):
|
||||||
user_is_authenticated = request.user.is_authenticated.value
|
user_is_authenticated = request.user.is_authenticated
|
||||||
|
|
||||||
if settings.DEVELOPMENT:
|
if settings.DEVELOPMENT:
|
||||||
secrets_path = "zproject/dev-secrets.conf"
|
secrets_path = "zproject/dev-secrets.conf"
|
||||||
|
|||||||
@@ -311,6 +311,6 @@ def plans_view(request: HttpRequest) -> HttpResponse:
|
|||||||
realm_plan_type = realm.plan_type
|
realm_plan_type = realm.plan_type
|
||||||
if realm.plan_type == Realm.SELF_HOSTED and settings.PRODUCTION:
|
if realm.plan_type == Realm.SELF_HOSTED and settings.PRODUCTION:
|
||||||
return HttpResponseRedirect('https://zulipchat.com/plans')
|
return HttpResponseRedirect('https://zulipchat.com/plans')
|
||||||
if not request.user.is_authenticated():
|
if not request.user.is_authenticated:
|
||||||
return redirect_to_login(next="plans")
|
return redirect_to_login(next="plans")
|
||||||
return render(request, "zerver/plans.html", context={"realm_plan_type": realm_plan_type})
|
return render(request, "zerver/plans.html", context={"realm_plan_type": realm_plan_type})
|
||||||
|
|||||||
Reference in New Issue
Block a user