Oublis
[auf_references_client.git] / auf_references_client / decorators.py
index d3ef466..038c86f 100644 (file)
@@ -5,18 +5,30 @@ from django.http import HttpResponseForbidden
 from django.contrib.auth import logout
 from django.template.loader import get_template
 from django.template import Context
+from django.conf import settings
+
+from auf_references_modeles import Utilisateur, GroupesPersonne
+
+import sys, traceback
 
 def has_group(group = ""):
     def _dec(view_func):
         def _view(request, *args, **kwargs):
             allowed = False
+            print getattr(settings, 'ROA_MODELS', False)
             if request.user.is_authenticated():
                 try:
-                    p = personne(request.user)
-                    g = Groupe.objects.get(nom = group)
-                    if g in p.groupes:
-                        allowed = True
-                except: pass
+                    p = Utilisateur.objects.get(courriel = request.user.email)
+                    #g = Groupe.objects.get(nom = group)
+                    for g in GroupesPersonne.objects.filter(personne__pk = p.pk):
+                        if g.groupe.nom == group:
+                            allowed = True
+                            break
+                except:
+                    print "Exception in user code:"
+                    print '-'*60
+                    traceback.print_exc(file=sys.stdout)
+                    print '-'*60
             else:
                 allowed = True