Skip to content

Commit

Permalink
is_authenticated/is_anonymous are now properties and not methods in D…
Browse files Browse the repository at this point in the history
…jango 1.10
  • Loading branch information
JoshData committed Aug 2, 2017
1 parent 5fb163f commit ef340e7
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 13 deletions.
2 changes: 1 addition & 1 deletion events/middleware.py
Expand Up @@ -3,7 +3,7 @@
def template_context_processor(request):
context = { "subscription_feeds": None }

if hasattr(request, 'user') and request.user.is_authenticated():
if hasattr(request, 'user') and request.user.is_authenticated:
subfeeds = set()
for x in SubscriptionList.objects.filter(user=request.user):
subfeeds |= set(x.trackers.all())
Expand Down
2 changes: 1 addition & 1 deletion events/views.py
Expand Up @@ -77,7 +77,7 @@ def edit_subscription_lists(request):
@login_required
@json_response
def edit_subscription_list(request):
if not request.user.is_authenticated():
if not request.user.is_authenticated:
return { "error": "not logged in" }

if "email_freq" in request.POST:
Expand Down
2 changes: 1 addition & 1 deletion ext/django-registration-pv
Submodule django-registration-pv updated from 889ccf to 7a3a00
2 changes: 1 addition & 1 deletion twostream/views.py
Expand Up @@ -19,7 +19,7 @@ def user_head(request):
m = resolve(request.GET.get("path", request.GET.get("view", "")))

user_data = None
if request.user.is_authenticated():
if request.user.is_authenticated:
user_data = { "email": request.user.email }
if hasattr(request.user, 'twostream_data'):
user_data.update(request.user.twostream_data)
Expand Down
2 changes: 1 addition & 1 deletion website/middleware.py
Expand Up @@ -118,7 +118,7 @@ def process_response(self, request, response):
from website.models import Sousveillance
Sousveillance.objects.create(
subject=uid,
user=request.user if request.user.is_authenticated() else None,
user=request.user if request.user.is_authenticated else None,
req={
"path": request.path,
"query": { k: request.GET[k] for k in request.GET if k in ("q",) }, # whitelist qsargs
Expand Down
2 changes: 1 addition & 1 deletion website/models.py
Expand Up @@ -311,7 +311,7 @@ def get_session_key(request):

@staticmethod
def get_for_user(request):
if request.user.is_authenticated():
if request.user.is_authenticated:
return Reaction.objects.filter(user=request.user)
elif "reactions-key" in request.session:
return Reaction.objects.filter(anon_session_key=Reaction.get_session_key(request))
Expand Down
14 changes: 7 additions & 7 deletions website/views.py
Expand Up @@ -257,7 +257,7 @@ def your_docket(request):
# Pre-load the user's subscription lists and for each list
# pre-load the list of bills entered into the list.
lists = []
if request.user.is_authenticated():
if request.user.is_authenticated:
lists = request.user.subscription_lists.all()
for lst in lists:
lst.bills = []
Expand Down Expand Up @@ -395,7 +395,7 @@ def go_ad_free_start(request):

# does the user have an ad-free payment already?
msi = { }
if not request.user.is_anonymous():
if not request.user.is_anonymous:
msi = request.user.userprofile().get_membership_subscription_info()

# or did the user make an anonymous payment?
Expand All @@ -422,7 +422,7 @@ def go_ad_free_redirect(request):
sandbox = "-sandbox"

# slightly different SKU if the user is/isn't logged in
if request.user.is_anonymous():
if request.user.is_anonymous:
item = {
"name": "Support GovTrack.us (%.02d)" % amount,
"sku": "govtrack-tip" + sandbox,
Expand Down Expand Up @@ -467,7 +467,7 @@ def go_ad_free_redirect(request):
from website.models import PayPalPayment
rec = PayPalPayment(
paypal_id=payment.id,
user=request.user if not request.user.is_anonymous() else None,
user=request.user if not request.user.is_anonymous else None,
response_data=payment.to_dict(),
notes=item["name"])
rec.save()
Expand Down Expand Up @@ -523,7 +523,7 @@ def set_district(request):
json.dumps({ "status": "ok", "mocs": mocs }),
content_type="application/json")

if request.user.is_authenticated():
if request.user.is_authenticated:
# Save to database.
prof = request.user.userprofile()
prof.congressionaldistrict = "%s%02d" % (state, district)
Expand Down Expand Up @@ -562,8 +562,8 @@ def add_remove_reaction(request):

r, isnew = Reaction.objects.get_or_create(
subject=request.POST["subject"],
user=request.user if request.user.is_authenticated() else None,
anon_session_key=Reaction.get_session_key(request) if not request.user.is_authenticated() else None,
user=request.user if request.user.is_authenticated else None,
anon_session_key=Reaction.get_session_key(request) if not request.user.is_authenticated else None,
)

if isnew:
Expand Down

0 comments on commit ef340e7

Please sign in to comment.