experiENS/avisstage/utils.py

16 lines
471 B
Python
Raw Normal View History

2017-04-04 00:28:25 +02:00
# coding: utf-8
2018-12-28 23:46:24 +01:00
from allauth.socialaccount.models import SocialAccount
2018-12-26 22:00:36 +01:00
from functools import reduce
2017-04-04 00:28:25 +02:00
def choices_length (choices):
return reduce (lambda m, choice: max (m, len (choice[0])), choices, 0)
2018-12-28 23:46:24 +01:00
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()