src/ldt/ldt/auth/__init__.py
author cavaliet
Fri, 03 Oct 2014 11:14:32 +0200
changeset 1324 0a425187f686
parent 1191 b6e0b1811723
child 1360 f69b5d8ba4b9
permissions -rw-r--r--
v1.53.12 : md5 for tag id in cinelab export
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1191
b6e0b1811723 Migrate to django 1.5 :
ymh <ymh.work@gmail.com>
parents: 167
diff changeset
     1
from django.conf import settings
b6e0b1811723 Migrate to django 1.5 :
ymh <ymh.work@gmail.com>
parents: 167
diff changeset
     2
from social_auth.backends import get_backends
b6e0b1811723 Migrate to django 1.5 :
ymh <ymh.work@gmail.com>
parents: 167
diff changeset
     3
0
bdf22b140727 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
     4
167
fe00e7302efe Change class and functions names to follow PEP8 formatting standards
verrierj
parents: 13
diff changeset
     5
def check_access(user, obj):
fe00e7302efe Change class and functions names to follow PEP8 formatting standards
verrierj
parents: 13
diff changeset
     6
    check_meth = getattr(obj, 'check_access', False)
0
bdf22b140727 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
     7
    if check_meth:
bdf22b140727 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
     8
        return check_meth(user)
bdf22b140727 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
     9
    else:
13
97ab7b3191cf add api to update project, uses psiton
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    10
        return user.is_staff
1191
b6e0b1811723 Migrate to django 1.5 :
ymh <ymh.work@gmail.com>
parents: 167
diff changeset
    11
b6e0b1811723 Migrate to django 1.5 :
ymh <ymh.work@gmail.com>
parents: 167
diff changeset
    12
def social_list():
b6e0b1811723 Migrate to django 1.5 :
ymh <ymh.work@gmail.com>
parents: 167
diff changeset
    13
    """Start list process"""
b6e0b1811723 Migrate to django 1.5 :
ymh <ymh.work@gmail.com>
parents: 167
diff changeset
    14
    l = []
b6e0b1811723 Migrate to django 1.5 :
ymh <ymh.work@gmail.com>
parents: 167
diff changeset
    15
    # We list all wanted backends among all availables 
b6e0b1811723 Migrate to django 1.5 :
ymh <ymh.work@gmail.com>
parents: 167
diff changeset
    16
    for backend in get_backends():
b6e0b1811723 Migrate to django 1.5 :
ymh <ymh.work@gmail.com>
parents: 167
diff changeset
    17
        for backend_str in settings.AUTHENTICATION_BACKENDS:
b6e0b1811723 Migrate to django 1.5 :
ymh <ymh.work@gmail.com>
parents: 167
diff changeset
    18
            if backend in backend_str:
b6e0b1811723 Migrate to django 1.5 :
ymh <ymh.work@gmail.com>
parents: 167
diff changeset
    19
                l.append(backend)
b6e0b1811723 Migrate to django 1.5 :
ymh <ymh.work@gmail.com>
parents: 167
diff changeset
    20
    return l