Commit 9ddda77d authored by Hamza Dely's avatar Hamza Dely

Commit initial : Schéma de l'app Comptes

parents
**/*.py[co]
from django.contrib import admin
# Register your models here.
from django.apps import AppConfig
class ActivitesConfig(AppConfig):
name = 'activites'
from django.db import models
# Create your models here.
from django.test import TestCase
# Create your tests here.
from django.shortcuts import render
# Create your views here.
from django.contrib import admin
# Register your models here.
from django.apps import AppConfig
class ComptesConfig(AppConfig):
name = 'comptes'
import uuid
from django.db import models
from django.contrib.auth.base_user import AbstractBaseUser, BaseUserManager
"""
Modèles de l'application «Comptes»
"""
class Section(models.Model):
"""
Une section regroupant plusieurs adhérents.
- sigle [varchar(255)] -> Sigle identifiant de manière unique une section
- nom [varchar] -> Nom de la section
- ferme [boolean] -> La section admet-elle de nouveau membres ?
"""
sigle = models.CharField(
"sigle",
max_length=255,
unique=True,
blank=False,
null=False,
)
nom = models.TextField(
"nom",
blank=False,
null=False,
)
ferme = models.BooleanField(
"fermé",
default=False,
)
class Meta:
default_permissions = []
class Alias(models.Model):
"""
Un alias désignant un adhérent.
- alias [varchar] -> Alias de l'adhérent
- proprietaire[0-1] [int*] -> Propriétaire de l'alias
"""
alias = models.TextField(
"alias",
unique=True,
blank=False,
null=False,
)
proprietaire = models.ForeignKey(
'comptes.Adherent',
models.CASCADE,
verbose_name="propriétaire",
blank=True,
null=True,
default=None,
)
class Meta:
default_permissions = []
class Historique(models.Model):
"""
Une entrée dans l'historique pour le suivi des pseudos.
- date [tstz] -> Date de la modification
- alias [int*] -> Alias suivi
- precedent[0-1] [int*] -> Ancien propriétaire
- suivant[0-1] [int*] -> Nouveau propriétaire
"""
date = models.DateTimeField(
auto_now_add=True,
null=False,
)
alias = models.ForeignKey(
'comptes.Alias',
models.CASCADE,
null=False,
)
precedent = models.ForeignKey(
'comptes.Adherent',
models.CASCADE,
null=True,
)
suivant = models.ForeignKey(
'comptes.Adherent',
models.CASCADE,
null=True,
)
class Meta:
default_permissions = []
class Dispose(models.Model):
"""
Association entre Adhérent et Permission pour la répartition des droits.
- meta [boolean] -> Est-ce un méta-droit ?
- accreditation [int] -> Niveau d'accréditation
- droit [int*] -> Une permission
- adherent [int*] -> Un adhérent
"""
meta = models.BooleanField(
"méta-droit",
default=False,
)
accreditation = models.IntegerField(
"accréditation",
blank=False,
null=False
default=0,
)
droit = models.ForeignKey(
'auth.Permission',
models.CASCADE,
blank=False,
null=False,
)
adherent = models.ForeignKey(
'comptes.Adherent',
models.CASCADE,
verbose_name="adhérent",
blank=False,
null=False,
)
class Meta:
proxy = True
unique_together = [
('droit', 'adherent'),
]
default_permissions = []
class Adhesion(models.Model):
"""
Une adhésion liée à un adhérent
- debut [tstz] -> Date de début de l'adhésion
- fin [tstz] -> Date de fin de l'adhésion
- section [int*] -> Section de l'adhérent au moment de l'adhésion
- adherent [int*] -> Adhérent concerné par l'adhésion
"""
debut = models.DateTimeField(
"début",
auto_now=False,
auto_now_add=True,
blank=True,
null=False,
)
fin = models.DateTimeField(
auto_now=False,
auto_now_add=False,
blank=True,
null=False,
)
section = models.ForeignKey(
'comptes.Section',
models.CASCADE,
blank=False,
null=False,
)
adherent = models.ForeignKey(
'comptes.Adherent',
models.CASCADE,
verbose_name="adhérent",
blank=False,
null=False,
)
class Meta:
verbose_name = "adhésion"
default_permissions = []
class Adherent(AbstractBaseUser):
"""
Un adhérent de l'association.
- pseudo [varchar(1024)] -> Pseudonyme de l'adhérent
- nom [varchar(255)] -> Nom de l'adhérent
- prenom [varchar(255)] -> Prénom de l'adhérent
- email [varchar(254)] -> Email de l'adhérent
- sexe[0-1] [varchar(1)] -> Sexe de l'adhérent
- type [varchar(255)] -> Type d'adhérent
- telephone [varchar(255)] -> Numéro de téléphone de l'adhérent
- adresse [varchar] -> Adresse postale de l'adhérent
- remunere [boolean] -> Indique si l'adhérent est rémunéré
- pbsante [varchar] -> Éventuel problème de santé
- remarque [varchar] -> Remarque sur l'adhérent
- uuid [uuid] -> Identifiant anonyme secondaire.
===== Couche de compatibilité Django =====
- is_staff [boolean] -> L'adhérent est MA.
- is_active [boolean] -> Le compte est actif
- is_superuser[boolean] -> Le compte est un super utilisateur
"""
USERNAME_FIELD = 'pseudo'
REQUIRED_FIELDS = [
'pseudo', 'nom', 'prenom', 'email',
]
pseudo = models.CharField(
max_length=1024,
unique=True,
blank=False,
null=False,
)
nom = models.CharField(
max_length=255,
blank=False,
null=False,
)
prenom = models.CharField(
"prénom",
max_length=255,
blank=False,
null=False,
)
email = models.EmailField(
blank=False,
null=False,
)
sexe = models.CharField(
max_length=1,
blank=True,
null=True,
)
type = models.CharField(
max_length=255,
default='personne',
blank=False,
null=False,
)
telephone = models.CharField(
verbose_name="téléphone",
max_length=50,
blank=False,
null=False,
)
adresse = models.TextField(
blank=True,
null=False,
)
remunere = models.BooleanField(
verbose_name="rémunéré",
default=False,
)
pbsante = models.TextField(
verbose_name="problème de santé",
blank=True,
null=False,
)
remarque = models.TextField(
blank=True,
null=False,
)
uuid = models.UUIDField(
unique=True,
null=False,
default=uuid.uuid4,
)
is_staff = models.BooleanField(
"membre actif",
default=False,
)
is_active = models.BooleanField(
"compte actif",
default=True,
)
is_superuser = models.BooleanField(
"compte superutilisateur",
default=False,
)
class Meta:
verbose_name = "adhérent"
default_permissions = []
from django.test import TestCase
# Create your tests here.
from django.shortcuts import render
# Create your views here.
from django.contrib import admin
# Register your models here.
from django.apps import AppConfig
class ConsosConfig(AppConfig):
name = 'consos'
from django.db import models
# Create your models here.
from django.test import TestCase
# Create your tests here.
from django.shortcuts import render
# Create your views here.
from django.contrib import admin
# Register your models here.
from django.apps import AppConfig
class DtConfig(AppConfig):
name = 'dt'
from django.db import models
# Create your models here.
from django.test import TestCase
# Create your tests here.
from django.shortcuts import render
# Create your views here.
#!/usr/bin/env python3
import os
import sys
if __name__ == "__main__":
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "note_kfet.settings")
try:
from django.core.management import execute_from_command_line
except ImportError:
# The above import may fail for some other reason. Ensure that the
# issue is really that Django is missing to avoid masking other
# exceptions on Python 2.
try:
import django
except ImportError:
raise ImportError(
"Couldn't import Django. Are you sure it's installed and "
"available on your PYTHONPATH environment variable? Did you "
"forget to activate a virtual environment?"
)
raise
execute_from_command_line(sys.argv)
"""
Django settings for note_kfet project.
Generated by 'django-admin startproject' using Django 1.10.6.
For more information on this file, see
https://docs.djangoproject.com/en/1.10/topics/settings/
For the full list of settings and their values, see
https://docs.djangoproject.com/en/1.10/ref/settings/
"""
import os
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/1.10/howto/deployment/checklist/
# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = '(-)(%mo8#1$bk@!45462ii3z@x1&-w(0r@c#bf4-jg5*m^i@bc'
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True
ALLOWED_HOSTS = []
# Application definition
INSTALLED_APPS = [
'comptes',
'consos',
'activites',
'dt',
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
]
MIDDLEWARE = [
'django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
]
ROOT_URLCONF = 'note_kfet.urls'
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [],
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
'django.template.context_processors.debug',
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
],
},
},
]
WSGI_APPLICATION = 'note_kfet.wsgi.application'
# Database
# https://docs.djangoproject.com/en/1.10/ref/settings/#databases
DATABASES = {
'default': {
'ENGINE' : 'django.db.backends.postgresql',
'NAME' : 'note_kfet',
'USER' : 'note',
}
}
# Password validation
# https://docs.djangoproject.com/en/1.10/ref/settings/#auth-password-validators
AUTH_USER_MODEL = 'comptes.Adherent'
AUTH_PASSWORD_VALIDATORS = [
{
'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
},
]
# Internationalization
# https://docs.djangoproject.com/en/1.10/topics/i18n/
LANGUAGE_CODE = 'fr-fr'
TIME_ZONE = 'Europe/Paris'
USE_I18N = True
USE_L10N = True
USE_TZ = True
# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/1.10/howto/static-files/
STATIC_URL = '/static/'
"""note_kfet URL Configuration
The `urlpatterns` list routes URLs to views. For more information please see:
https://docs.djangoproject.com/en/1.10/topics/http/urls/
Examples:
Function views
1. Add an import: from my_app import views
2. Add a URL to urlpatterns: url(r'^$', views.home, name='home')
Class-based views
1. Add an import: from other_app.views import Home
2. Add a URL to urlpatterns: url(r'^$', Home.as_view(), name='home')
Including another URLconf
1. Import the include() function: from django.conf.urls import url, include
2. Add a URL to urlpatterns: url(r'^blog/', include('blog.urls'))
"""
from django.conf.urls import url
from django.contrib import admin
urlpatterns = [
url(r'^admin/', admin.site.urls),
]
"""
WSGI config for note_kfet project.
It exposes the WSGI callable as a module-level variable named ``application``.
For more information on this file, see
https://docs.djangoproject.com/en/1.10/howto/deployment/wsgi/
"""
import os
from django.core.wsgi import get_wsgi_application
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "note_kfet.settings")
application = get_wsgi_application()
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