2018-12-26 22:00:36 +01:00
|
|
|
from functools import reduce
|
2018-12-30 20:33:44 +01:00
|
|
|
from math import cos, radians, sqrt
|
2018-12-26 22:00:36 +01:00
|
|
|
|
2021-02-07 23:15:47 +01: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
|
|
|
|
2018-12-29 16:23:57 +01:00
|
|
|
def en_scolarite(user):
|
|
|
|
return user.profil.en_scolarite
|
2018-12-30 20:33:44 +01:00
|
|
|
|
2021-02-07 23:15:47 +01:00
|
|
|
|
2018-12-30 20:33:44 +01:00
|
|
|
def approximate_distance(a, b):
|
|
|
|
lat_a = radians(a.y)
|
|
|
|
lat_b = radians(b.y)
|
|
|
|
dlon = radians(b.x - a.x)
|
2021-02-07 23:15:47 +01:00
|
|
|
dlon = dlon * cos((lat_a + lat_b) / 2)
|
|
|
|
dlat = lat_a - lat_b
|
|
|
|
distance = 6371000 * sqrt(dlon * dlon + dlat * dlat)
|
2018-12-30 20:33:44 +01:00
|
|
|
return distance
|
2021-02-07 18:23:24 +01:00
|
|
|
|
2021-02-07 23:15:47 +01:00
|
|
|
|
2021-02-07 18:23:24 +01:00
|
|
|
def is_email_ens(mail, none=False):
|
|
|
|
if mail is None:
|
|
|
|
return none
|
|
|
|
return mail.endswith("ens.fr") or mail.endswith("ens.psl.eu")
|