Commit 8c92ff4c authored by Daniel Stan's avatar Daniel Stan

range la racine dans un sous-dossier intranet

parent a97c7b37
......@@ -21,12 +21,7 @@
#
from django.shortcuts import render
from django.template import RequestContext
import settings
from django.contrib.auth.decorators import login_required
from django.utils.importlib import import_module
conn_pool = import_module('conn_pool', 'intranet')
@login_required
def view(request):
......
......@@ -2,10 +2,9 @@
import django.shortcuts
from django.contrib.auth.decorators import login_required
from django.utils.importlib import import_module
from django.template import RequestContext
conn_pool = import_module('conn_pool', 'intranet')
from intranet import conn_pool
def mozilla(request):
emailaddress = request.GET.get("emailaddress", '%EMAILLOCALPART%')
......
# -*- coding: utf-8 -*-
from django.utils.importlib import import_module
conn_pool = import_module('conn_pool', 'intranet')
from intranet import conn_pool
def get_clubs_for_user(user):
'''Renvoie la liste des noms des clubs de l'utilisateur et leur objet ldap associé'''
......
# -*- coding: utf-8 -*-
from django.contrib.auth.decorators import login_required
from django.utils.decorators import method_decorator
from django.utils.importlib import import_module
from django.views.generic import TemplateView
from django.views.generic.edit import FormView
from django.core.urlresolvers import reverse_lazy
......@@ -12,8 +11,7 @@ from django.contrib import messages
from forms import ImprimeurAddForm, ImprimeurDelForm
from tools import get_clubs_for_user, get_imprimeurs_for_club
conn_pool = import_module('conn_pool', 'intranet')
from intranet import conn_pool
class IndexView(TemplateView):
template_name = 'club/index.html'
......
......@@ -11,8 +11,7 @@ import subprocess
from django.http import HttpResponseRedirect
from django.template import RequestContext
from django.utils.importlib import import_module
conn_pool = import_module('conn_pool', 'intranet')
from intranet import conn_pool
from django.contrib import messages
......
......@@ -7,7 +7,6 @@ from django.views.decorators.debug import sensitive_post_parameters
from models import Code
from django.http import HttpResponse
from django.contrib.auth.models import User
from django.utils.importlib import import_module
import datetime
import os
......@@ -17,7 +16,7 @@ else:
from gestion import secrets_new as secrets
digicode_pass = secrets.get('digicode_pass')
conn_pool = import_module('conn_pool', 'intranet')
from intranet import conn_pool
@login_required
def view_code(request):
......
......@@ -11,14 +11,11 @@ from django.template import RequestContext
from django.http import HttpResponse
from django.utils.importlib import import_module
conn_pool = import_module('conn_pool', 'intranet')
from tex import render_tex
import models
import hashlib
import time
import settings
from intranet import settings, conn_pool
@login_required
def index(request):
......
# -*- coding: utf-8 -*-
from django import forms
import settings
from intranet import settings
import models
class UploadForm(forms.Form):
......
......@@ -8,7 +8,7 @@ import re, os
import time
import datetime
import urllib2
import settings
from intranet import settings
from django.db import models
from django import forms
......
......@@ -2,7 +2,7 @@
# Vincent Legallic, Gabriel Détraz, Charlie Jacomme
import settings
from intranet import settings, conn_pool
import time
import django.shortcuts
......@@ -11,8 +11,6 @@ from django.template import RequestContext
from django.contrib.auth.decorators import login_required
from django.shortcuts import render_to_response, render
from django.utils.importlib import import_module
conn_pool = import_module('conn_pool', 'intranet')
# Pour stocker des messages dans la session courante
from django.contrib import messages
......
......@@ -3,11 +3,8 @@
from django.db import models
import lc_ldap.crans_utils
from django.utils.importlib import import_module
from django.db.models import Q
conn_pool = import_module('conn_pool', 'intranet')
import settings
from intranet import conn_pool, settings
import datetime
import netaddr
......
......@@ -10,13 +10,11 @@ from django.contrib import messages
from lc_ldap.ldap_locks import LockError
from django.contrib import messages
from django.utils.importlib import import_module
conn_pool = import_module('conn_pool', 'intranet')
from intranet import conn_pool, settings
import models
import hashlib
import time
import settings
from forms import MachineForm
......
......@@ -7,7 +7,6 @@ from django.shortcuts import render
from django.contrib.auth.decorators import login_required
from models import PagePerso
from django.template import RequestContext
from django.utils.importlib import import_module
from forms import PagePersoForm
......
......@@ -22,7 +22,7 @@ from django.db import models
from django.core.mail import EmailMessage
from django.core.urlresolvers import reverse
from django.contrib.auth.models import User
import settings
from intranet import settings
import reversion
MAIL_SRC = settings.CABLAGE_MAIL_FROM
......
......@@ -24,7 +24,6 @@
import django.shortcuts
from django.template import RequestContext
from django.utils.importlib import import_module
from django.contrib.auth.decorators import login_required, permission_required
from django.db.utils import ConnectionDoesNotExist
......@@ -34,7 +33,7 @@ from django.shortcuts import redirect
from models import Prise, PriseAutorise
from forms import ModifPriseFormSet, ValidPriseFormSet, AutoriseForm
conn_pool = import_module('conn_pool', 'intranet')
from intranet import conn_pool
PAGES = [
('prise_autorise', 'Mes prises'),
......
......@@ -15,8 +15,7 @@ import utils.quota as quota
from gestion.config.upload import soft, hard
from django.template import RequestContext
from django.utils.importlib import import_module
conn_pool = import_module('conn_pool', 'intranet')
from intranet import conn_pool
from passlib.apps import ldap_context
# On associe une couleur quand on est en dessous du pourcentage qui va bien
......
......@@ -15,12 +15,12 @@ from django.contrib.auth.decorators import login_required, permission_required
from django.views.decorators.csrf import csrf_exempt
from django.views.decorators.debug import sensitive_variables
from django.views.decorators.http import require_POST
from django.utils.importlib import import_module
from django.utils.datastructures import MultiValueDictKeyError
import gestion.secrets_new as secrets
from settings import ROOT_URL
from intranet.settings import ROOT_URL
from intranet import conn_pool
from models import Transaction
import re
......@@ -39,7 +39,6 @@ else:
comnpay_tpe = secrets.get('comnpay_tpe')
comnpay_url = 'https://secure.comnpay.com'
conn_pool = import_module('conn_pool','intranet')
@login_required
def accueil(request):
......
......@@ -10,7 +10,7 @@ from django.http import HttpResponse, HttpResponseForbidden
from django.template.loader import render_to_string
from django.core.exceptions import PermissionDenied
from settings import BASE_LDAP_TEST
from intranet.settings import BASE_LDAP_TEST
from django.contrib import messages
from models import ConfirmAction
......
......@@ -2,7 +2,7 @@
from django.contrib import messages
import settings
from intranet import settings, conn_pool
class asterisk_reload_conf_debug:
@classmethod
def reload_config(self, fname):
......@@ -21,9 +21,6 @@ from django.contrib.auth.models import User
import hashlib
import os
from django.utils.importlib import import_module
conn_pool = import_module('conn_pool', 'intranet')
# Description de la configuration générée pour asterisk
# TODO eurk
asterisk_conf = {
......
......@@ -16,8 +16,6 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
import settings
from wifi_new import parse_xml
import django.shortcuts
......@@ -33,8 +31,7 @@ from forms import Wifi_Action
from forms import Bornes_Cibles
from forms import Wifi_Info
from django.utils.importlib import import_module
conn_pool = import_module('conn_pool', 'intranet')
from intranet import conn_pool, settings
from lc_ldap.crans_utils import escape as ldap_escape
from gestion.config.config import liste_bats
from wifi_new.manage_borne_conf import exec_conn
......
......@@ -4,9 +4,8 @@ from django.forms import Form, PasswordInput, CharField, ValidationError
import urllib2
from django.utils.translation import ugettext as _
from django.utils.importlib import import_module
from lc_ldap.crans_utils import validate_name
conn_pool = import_module('conn_pool', 'intranet')
from intranet import conn_pool
class LinkAccount(Form):
......
......@@ -3,8 +3,7 @@
"""Ce fichier donne les primitives de modification du compte WiKi
associé à un utilisateur, via Binding. """
from django.utils.importlib import import_module
conn_pool = import_module('conn_pool', 'intranet')
from intranet import conn_pool
import wiki.creer_compte_wiki
......
......@@ -10,7 +10,7 @@ from django.views.generic import TemplateView
from django.views.generic.edit import FormView
from forms import LinkAccount, CreateAccount, Form
import settings
from intranet import settings
if settings.LOCATION != 'perso':
from models_ldap import WikiName
else:
......
......@@ -16,7 +16,7 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
import settings
from intranet import settings
from django.http import HttpResponse
......
# -*- encoding: utf-8 -*-
import settings
import functools
def protect(f):
""" Transforme une vue afin d'effacer la variable POST avant rapport
de bug en production.
Cette feature est supportée plus proprement par la dernière version
de django (pas encore dans squeeze) """
@functools.wraps(f)
def wrapper(request,*args,**kwargs):
try:
return f(request,*args,**kwargs)
except Exception as e:
if not settings.DEBUG:
request.POST = "Censuré (mettre settings.DEBUG=True si voulu)"
raise
return wrapper
# -*- coding: utf-8 -*-
#
# DATABASE.PY -- Gestion des bases de données multiples dans l'intranet
#
# Copyright (C) 2010 Nicolas Dandrimont
# Authors: Nicolas Dandrimont <olasd@crans.org>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
import settings
class Router(object):
"""Effectue le routage entre les différentes bases de données
Actuellement, redirige toutes les requetes de l'application
`prises' vers la base de données idoine"""
def db_for_read(self, model, **hints):
"""Base de données à utiliser pour la lecture"""
#if model._meta.app_label == "prises":
# return "switchs"
return None
def db_for_write(self, model, **hints):
"""Base de données à utiliser pour l'écriture"""
#if model._meta.app_label == "prises":
# return "switchs"
return None
def allow_syncdb(self, db, model):
"""Autoriser l'écriture du modèle donné dans la base de données ?"""
#if db == "switchs":
# if model._meta.app_label == "prises":
# return True
# return False
#else:
# if model._meta.app_label == "prises":
# return False
return None
......@@ -20,16 +20,14 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
import settings, ldap
import ldap
from django.contrib.auth.models import Group, User
from django.contrib.auth.backends import ModelBackend
from django.utils.importlib import import_module
# Pour se connecter à la base ldap
import lc_ldap.shortcuts
conn_pool = import_module('conn_pool', 'intranet')
from intranet import conn_pool, settings
def refresh_droits(user, cl_user):
"""Rafraîchit les droits de l'utilisateur django `user' depuis
......
../settings.py
\ No newline at end of file
This diff is collapsed.
# -*- encoding: utf-8 -*-
from django.conf.urls import include, patterns, url
import settings
from intranet import settings
import django.contrib.auth.views
from bw_comp.protectpost import protect
from django.contrib import admin
admin.autodiscover()
if settings.CAS_ENABLED:
from django_cas_ng.signals import cas_user_authenticated
from login import post_cas_login
from intranet.login import post_cas_login
cas_user_authenticated.connect(post_cas_login)
login_url = url(r'^login$', 'django_cas_ng.views.login', name="login")
logout_url = url(r'^logout$', 'django_cas_ng.views.logout', name="logout")
else:
login_url = url('^login', protect(django.contrib.auth.views.login), {'template_name': 'login.html'}, name="login")
login_url = url('^login', django.contrib.auth.views.login, {'template_name': 'login.html'}, name="login")
#login_url = url('^login', protect(django.contrib.auth.views.login), {'template_name': 'login.html'}, name="login")
logout_url = url('^logout', 'django.contrib.auth.views.logout_then_login', name ="logout")
urlpatterns = patterns('',
......
......@@ -26,9 +26,10 @@ here=os.path.dirname( os.path.realpath( __file__ ) )
import sys
sys.path.append(here)
# et a priori settings.py est dans le même dossier
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "settings")
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "intranet.settings")
# Bon, il semblerait qu'on a aussi besoin du répertoire parent
# TODO: virer ceci
uphere="/".join(here.split("/")[:-1])
sys.path.append(uphere)
......
#!/bin/bash /usr/scripts/python.sh
#!/usr/bin/env python
import os
import sys
if __name__ == "__main__":
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "settings")
import intranet.settings
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "intranet.settings")
from django.core.management import execute_from_command_line
......
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment