experiENS/avisstage/utils.py
2018-12-28 23:46:24 +01:00

15 lines
471 B
Python

# coding: utf-8
from allauth.socialaccount.models import SocialAccount
from functools import reduce
def choices_length (choices):
return reduce (lambda m, choice: max (m, len (choice[0])), choices, 0)
def en_scolarite(user_or_id):
if isinstance(user_or_id, int):
user_id = user_or_id
else:
user_id = user_or_id.id
return SocialAccount.objects.filter(user_id=user_id,
provider="clipper").exists()