Commit 29ddbfb2 authored by sbonnegent's avatar sbonnegent
Browse files

version initiale

parent 893d9376
*.pyc
conf/settings.py
venv/
doc/_build/
*/__pycache__
db.sqlite3*
Site de gestion simplifiée des tournois et pouvant fonctionner hors ligne.
Fonctionnalités
===============
* enregistrement grâce à un identifiant / mot de passe
* plusieurs tournois en même temps
* les administrateurs contrôlent le déroulement des tournois
"""
Django settings for conf project.
Generated by 'django-admin startproject' using Django 1.11.4.
For more information on this file, see
https://docs.djangoproject.com/en/1.11/topics/settings/
For the full list of settings and their values, see
https://docs.djangoproject.com/en/1.11/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.11/howto/deployment/checklist/
# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = '^u92ac!p_)6f=$c#&4xy!8(%uk5$rlgs(p^ibkkd4(qq4+p638'
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True
ALLOWED_HOSTS = []
# Application definition
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'hijack',
'compat',
'tournois',
'hijack_admin',
]
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 = 'conf.urls'
# hijack
HIJACK_LOGIN_REDIRECT_URL = "/"
HIJACK_LOGOUT_REDIRECT_URL = "/admin/auth/user/"
HIJACK_AUTHORIZE_STAFF = True
HIJACK_USE_BOOTSTRAP = True
HIJACK_ALLOW_GET_REQUESTS = True
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 = 'conf.wsgi.application'
# Database
# https://docs.djangoproject.com/en/1.11/ref/settings/#databases
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
}
}
# Password validation
# https://docs.djangoproject.com/en/1.11/ref/settings/#auth-password-validators
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.11/topics/i18n/
LANGUAGE_CODE = 'en-us'
TIME_ZONE = 'UTC'
USE_I18N = True
USE_L10N = True
USE_TZ = True
# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/1.11/howto/static-files/
STATIC_URL = '/static/'
STATIC_ROOT = os.path.join(BASE_DIR, 'static')
from .settings_common import *
DEBUG = True
ALLOWED_HOSTS = ['*']
SECRET_KEY = 'Une_clef_secrete!'
"""conf URL Configuration
The `urlpatterns` list routes URLs to views. For more information please see:
https://docs.djangoproject.com/en/1.11/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
from tournois import views
urlpatterns = [
url(r'^$', views.home, name='home'),
url(r'^admin/', admin.site.urls),
]
"""
WSGI config for conf 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/2.0/howto/deployment/wsgi/
"""
import os
from django.core.wsgi import get_wsgi_application
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "conf.settings")
application = get_wsgi_application()
# Minimal makefile for Sphinx documentation
#
# You can set these variables from the command line.
SPHINXOPTS =
SPHINXBUILD = sphinx-build
SPHINXPROJ = tournois
SOURCEDIR = .
BUILDDIR = _build
# Put it first so that "make" without argument is like "make help".
help:
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
.PHONY: help Makefile
# Catch-all target: route all unknown targets to Sphinx using the new
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
%: Makefile
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
\ No newline at end of file
==================
Cahier des charges
==================
Sujet
=====
Descriptions
============
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
#
# tournois documentation build configuration file, created by
# sphinx-quickstart on Sun Jan 14 13:38:54 2018.
#
# This file is execfile()d with the current directory set to its
# containing dir.
#
# Note that not all possible configuration values are present in this
# autogenerated file.
#
# All configuration values have a default; values that are commented out
# serve to show the default.
# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
# documentation root, use os.path.abspath to make it absolute, like shown here.
#
# import os
# import sys
# sys.path.insert(0, os.path.abspath('.'))
# -- General configuration ------------------------------------------------
# If your documentation needs a minimal Sphinx version, state it here.
#
# needs_sphinx = '1.0'
# Add any Sphinx extension module names here, as strings. They can be
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.
extensions = ['sphinx.ext.autodoc',
'sphinx.ext.todo',
'sphinx.ext.coverage']
# Add any paths that contain templates here, relative to this directory.
templates_path = ['_templates']
# The suffix(es) of source filenames.
# You can specify multiple suffix as a list of string:
#
# source_suffix = ['.rst', '.md']
source_suffix = '.rst'
# The master toctree document.
master_doc = 'index'
# General information about the project.
project = 'tournois'
copyright = '2018, S.Bonnegent'
author = 'S.Bonnegent'
# The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the
# built documents.
#
# The short X.Y version.
version = '0.0.1'
# The full version, including alpha/beta/rc tags.
release = '0.0.1'
# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
#
# This is also used if you do content translation via gettext catalogs.
# Usually you set "language" from the command line for these cases.
language = 'fr'
# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
# This patterns also effect to html_static_path and html_extra_path
exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store']
# The name of the Pygments (syntax highlighting) style to use.
pygments_style = 'sphinx'
# If true, `todo` and `todoList` produce output, else they produce nothing.
todo_include_todos = True
# -- Options for HTML output ----------------------------------------------
# The theme to use for HTML and HTML Help pages. See the documentation for
# a list of builtin themes.
#
html_theme = 'alabaster'
# Theme options are theme-specific and customize the look and feel of a theme
# further. For a list of options available for each theme, see the
# documentation.
#
# html_theme_options = {}
# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css".
html_static_path = ['_static']
# Custom sidebar templates, must be a dictionary that maps document names
# to template names.
#
# This is required for the alabaster theme
# refs: http://alabaster.readthedocs.io/en/latest/installation.html#sidebars
html_sidebars = {
'**': [
'relations.html', # needs 'show_related': True theme option to display
'searchbox.html',
]
}
# -- Options for HTMLHelp output ------------------------------------------
# Output file base name for HTML help builder.
htmlhelp_basename = 'tournoisdoc'
# -- Options for LaTeX output ---------------------------------------------
latex_elements = {
# The paper size ('letterpaper' or 'a4paper').
#
# 'papersize': 'letterpaper',
# The font size ('10pt', '11pt' or '12pt').
#
# 'pointsize': '10pt',
# Additional stuff for the LaTeX preamble.
#
# 'preamble': '',
# Latex figure (float) alignment
#
# 'figure_align': 'htbp',
}
# Grouping the document tree into LaTeX files. List of tuples
# (source start file, target name, title,
# author, documentclass [howto, manual, or own class]).
latex_documents = [
(master_doc, 'tournois.tex', 'tournois Documentation',
'S.Bonnegent', 'manual'),
]
# -- Options for manual page output ---------------------------------------
# One entry per manual page. List of tuples
# (source start file, name, description, authors, manual section).
man_pages = [
(master_doc, 'tournois', 'tournois Documentation',
[author], 1)
]
# -- Options for Texinfo output -------------------------------------------
# Grouping the document tree into Texinfo files. List of tuples
# (source start file, target name, title, author,
# dir menu entry, description, category)
texinfo_documents = [
(master_doc, 'tournois', 'tournois Documentation',
author, 'tournois', 'One line description of project.',
'Miscellaneous'),
]
# -- Options for Epub output ----------------------------------------------
# Bibliographic Dublin Core info.
epub_title = project
epub_author = author
epub_publisher = author
epub_copyright = copyright
# The unique identifier of the text. This can be a ISBN number
# or the project homepage.
#
# epub_identifier = ''
# A unique identification for the text.
#
# epub_uid = ''
# A list of files that should not be packed into the epub file.
epub_exclude_files = ['search.html']
Documentation
=============
.. toctree::
:maxdepth: 2
:caption: Contents:
cdc
suivi
==================
Suivi des réunions
==================
#!/bin/bash
# Makefile général, on considére que la doc se trouve dans 'doc/' et config de
# django se trouve dans 'config/'
# le fichier make vient de: https://framagit.org/bonnegent/make
if [ -e make.conf ]
then
source ./make.conf
else
echo "[ERROR] make.conf manquant"
fi
VERSION="170904"
STATIC="${PROJET}/static/${PROJET}/"
PY="python3"
function my_help {
cat << 'EOF'
Usage: ./make [a_command]
Pour tout le monde:
-------------------
doc : fabrique la doc en html
help : cette aide
Pour l'administrateur:
----------------------
centos7 : installation via ansible sur Centos 7
dump : exporte les donnees de la base dans data.json
load : charge les données de data.json
sh : run ./manage.py shell dans le virtualenv
update : install/mets à jour le virtualenv et applique si besoin
les migrations
Pour le développeur:
--------------------
atom : lance l'IDE Atom dans le virtualenv
autopep8 : mets en page automatiquement selon la norme PEP8
doc_tar : fabrique un tar.bz2 de la doc en html
dump_tests : exporte les données pour le jeu de données des tests
freeze : affiche le 'pip freeze' dans le virtualenv
html : lance firefox sur la doc en html
load_tests : efface les données de la base et charge les données de
tests
migrations : les models.py ont été modifiés, on prépare la migration
run : run ./manage.py runserver dans le virtualenv
smtp : lance un faux serveur mail (SMTP sur port 1025)
update_js : mets à jour les bibliothèques JS/CSS
update_pip : mets à jour les dépendances PIP
Avant un 'git push', on devrait faire dans l'ordre:
pep8 : lance flake8 sur le code (objectif 0 ligne !)
doc : fabrique la doc en html
tests : lance les tests et la couverture
EOF
exit 1
}
function enter_venv {
if [ "$NOENV" != "yes" ]
then
must_succeed source venv/bin/activate 2>/dev/null
fi
}
function must_succeed {
# exec a command and return value
$*
if [ ! $? == 0 ]
then
echo "[erreur] $*"
exit 42
fi
}
function doc {
enter_venv
if [ -e doc/conf.py ]
then
pushd doc
make html
echo "Doc disponible ici: doc/_build/html/index.html"
popd
else
echo "Aucune configuration de Sphinx, création..."
sphinx-quickstart -p $PROJET -v 0.0.1 -r 0.0.1 -l fr --ext-autodoc --ext-coverage --ext-todo --makefile --suffix=.rst --master=index --epub --no-batchfile doc
fi
}
function update_js {
BOOTSTRAP="bootstrap-${BOOTSTRAP_VERSION}-dist.zip"
BOOTSTRAP_DIR=${BOOTSTRAP/.zip/}
DATATABLES="DataTables-${DATATABLES_VERSION}.zip"
DATATABLES_DIR=${DATATABLES/.zip/}
# mise a jour des frameworks JS
pushd $STATIC
if [ ! -e ${JQUERY} ]
then
echo "Download and install JQuery..."
must_succeed curl http://code.jquery.com/${JQUERY} -o ${JQUERY}
fi
if [ ! -e ${BOOTSTRAP} ]
then
echo "Download BootStrap..."
must_succeed curl https://github.com/twbs/bootstrap/releases/download/v${BOOTSTRAP_VERSION}/${BOOTSTRAP} -o ${BOOTSTRAP} --location
fi
if [ ! -e ${DATATABLES} ]
then
echo "Download DataTables..."
must_succeed wget http://datatables.net/releases/${DATATABLES} -O ${DATATABLES}
fi
if [ ! -e ${BOOTSTRAP_DIR} ]
then
echo "Unzip Bootstrap..."
must_succeed unzip ${BOOTSTRAP}
fi
if [ ! -e ${DATATABLES_DIR} ]
then
echo "Unzip DataTables..."
must_succeed unzip ${DATATABLES}
fi
for dir in fonts js css media
do
if [ ! -e $dir ]
then
must_succeed mkdir -v $dir
fi
done
if [ -e media/French.json ]
then
rm -f media/French.json
fi
must_succeed wget http://cdn.datatables.net/plug-ins/${DATATABLES_VERSION}/i18n/French.json -O media/French.json
must_succeed cp -f ${BOOTSTRAP_DIR}/fonts/* fonts/
must_succeed cp $JQUERY js/jquery.min.js
must_succeed cp ${BOOTSTRAP_DIR}/css/bootstrap.min.css css/
must_succeed cp ${BOOTSTRAP_DIR}/js/bootstrap.min.js js/
must_succeed cp ${DATATABLES_DIR}/media/js/jquery.dataTables.min.js js/
must_succeed cp ${DATATABLES_DIR}/media/js/dataTables.bootstrap.min.js js/
must_succeed cp ${DATATABLES_DIR}/media/css/dataTables.bootstrap.min.css css/
# nettoyage
rm -rf ${BOOTSTRAP_DIR}* $JQUERY ${DATATABLES_DIR}*
popd
enter_venv
must_succeed $PY ./manage.py collectstatic --noinput --no-post-process
echo "[TODO] remplacer 'Rechercher' par 'Filtrer' dans ${STATIC}media/French.json"
}
function update_pip {
create_venv
enter_venv
pip-compile --output-file requirements.txt requirements.in
pip-sync
}
function update {
create_venv
enter_venv
echo "Mise a jour des 'requirements'"
#if [ "$(pip --version|grep -c 'pip 1.4')" == "1" ]
#then
# # option inexistante en version 1.4 de pip
# ALLOW=""
#else
# ALLOW="--allow-external PIL --allow-unverified PIL"
#fi
#must_succeed pip install --upgrade --requirement requirements.txt $ALLOW
must_succeed pip install --upgrade --requirement requirements.txt
doc
if [ ! -e conf ]
then
echo "création du projet django"
django-admin startproject conf
mv conf/manage.py .
mv conf 2remove
mv 2remove/conf conf
rm -rf 2remove
# mv conf/settings.py conf/settings_common.py
echo "from .settings_common import *" > conf/settings.py
echo "DEBUG = True" >> conf/settings.py
echo "ALLOWED_HOSTS = ['*']" >> conf/settings.py
echo "SECRET_KEY = 'Une_clef_secrete!'" >> conf/settings.py
echo "STATIC_ROOT = os.path.join(BASE_DIR, 'static')" >> conf/settings_common.py
cp conf/settings.py conf/settings_template.py
echo "> la config générale doit restée dans conf/settings_common.py"
echo "> et la config particulière dans conf/settings.py"
fi
if [ ! -e conf/settings.py ]
then
if [ -e conf/settings_template.py ]
then
echo "conf/settings.py créé à partir de conf/settings_template.py"
cp conf/settings_template.py conf/settings.py
else
echo "le fichier conf/settings.py doit être présent"
echo "> conf/settings_template.py absent"
fi
fi
if [ ! -e $PROJET ]
then
echo "création du projet $PROJET"
$PY ./manage.py startapp $PROJET
mkdir -p $PROJET/templates/$PROJET/