From 1fd1483c27ea9fc91af05640f8872241e2846973 Mon Sep 17 00:00:00 2001 From: Felipe Vieira Date: Wed, 7 Dec 2011 14:50:56 +0000 Subject: [PATCH] de todas as maneiras, ao criar um user cria um servidor --- sigi/apps/servidores/models.py | 8 ++++++-- sigi/settings.py | 24 ++++++++++++------------ 2 files changed, 18 insertions(+), 14 deletions(-) diff --git a/sigi/apps/servidores/models.py b/sigi/apps/servidores/models.py index 8999206..30b2997 100644 --- a/sigi/apps/servidores/models.py +++ b/sigi/apps/servidores/models.py @@ -139,8 +139,12 @@ class Servidor(models.Model): return self.nome_completo # Soluçao alternativa para extender o usuário do django -# Acesso do servidor de um objeto user -User.servidor = property(lambda user: Servidor.objects.get(user=user)) +# Acessa do servidor de um objeto user criando um profile +# baseado nos dados do LDAP +User.servidor = property(lambda user: Servidor.objects.get_or_create( + user=user, + nome_completo= "%s %s" % (user.first_name, user.last_name) + )[0]) # Sinal para ao criar um usuário criar um servidor # baseado no nome contino no LDAP diff --git a/sigi/settings.py b/sigi/settings.py index e0aad03..23c464f 100644 --- a/sigi/settings.py +++ b/sigi/settings.py @@ -38,12 +38,12 @@ EMAIL_HOST_PASSWORD = '' #EMAIL_USE_TLS = True #DATABASE_ENGINE = 'postgresql_psycopg2' -DATABASE_ENGINE = 'sqlite3' -DATABASE_NAME = 'devel.db' -#DATABASE_USER = 'sigi' -#DATABASE_PASSWORD = '123456' -#DATABASE_HOST = 'localhost' -#DATABASE_PORT = '5432' +#DATABASE_ENGINE = 'sqlite3' +#DATABASE_NAME = 'sigi' +#DATABASE_USER = 'administrador' +#DATABASE_PASSWORD = 'interlegis' +#DATABASE_HOST = 'banco' +#DATABASE_PORT = '5432' TIME_ZONE = 'Brazil/East' LANGUAGE_CODE = 'pt-br' @@ -73,7 +73,7 @@ AUTH_LDAP_GROUP_TYPE = GroupOfNamesType(name_attr="cn") #AUTH_LDAP_REQUIRE_GROUP = u"cn=Acesso ao SIGI,ou=Grupos de Permissão,ou=Sede,dc=interlegis,dc=gov,dc=br" AUTH_LDAP_USER_FLAGS_BY_GROUP = { - "is_staff": u"cn=Acesso ao SIGI,ou=Grupos de Permissão,ou=Sede,dc=interlegis,dc=gov,dc=br" + "is_staff": u"cn=SINTER,ou=Grupos Organizacionais,ou=Sede,dc=interlegis,dc=gov,dc=br" } # Populate the Django user from the LDAP directory. @@ -100,7 +100,7 @@ AUTH_LDAP_MIRROR_GROUPS = True AUTH_LDAP_CACHE_GROUPS = True AUTH_LDAP_GROUP_CACHE_TIMEOUT = 3600 -AUTH_PROFILE_MODULE = 'sigi.Servidor' +AUTH_PROFILE_MODULE = 'servidores.Servidor' # Keep ModelBackend around for per-user permissions and maybe a local superuser. AUTHENTICATION_BACKENDS = ( @@ -108,10 +108,10 @@ AUTHENTICATION_BACKENDS = ( 'django.contrib.auth.backends.ModelBackend', ) -#CACHE_BACKEND = 'dummy:///' -#CACHE_MIDDLEWARE_SECONDS = 60 -#CACHE_MIDDLEWARE_KEY_PREFIX = 'sigi' -#CACHE_MIDDLEWARE_ANONYMOUS_ONLY = False +CACHE_BACKEND = 'dummy:///' +CACHE_MIDDLEWARE_SECONDS = 60 +CACHE_MIDDLEWARE_KEY_PREFIX = 'sigi' +CACHE_MIDDLEWARE_ANONYMOUS_ONLY = False # Used to provide a seed in secret-key hashing algorithms. Set this to # a random string in your local_settings.py - the longer, the better.