Commit 7a33aca0 authored by hypsug0's avatar hypsug0
Browse files

fix: Some fixes

parent 242212f6
......@@ -2,3 +2,6 @@
*.pyc
.env
.env.sample
Dockerfile
*.yaml
.venv
......@@ -24,4 +24,132 @@ core/static/img/logo_site.png
.python-version
frontend
# Configs #
.env
/dbchiro/settings/configuration/config.py
secretkey.txt
secrets.json
# Static files #
/core/static/img/logo_site.png
core/static/img/logo_site.png
# Django #
*.log
*.pot
*.pyc
__pycache__
db.sqlite3
media
# Backup files #
*.bak
# If you are using PyCharm #
.idea/**/workspace.xml
.idea/**/tasks.xml
.idea/dictionaries
.idea/**/dataSources/
.idea/**/dataSources.ids
.idea/**/dataSources.xml
.idea/**/dataSources.local.xml
.idea/**/sqlDataSources.xml
.idea/**/dynamic.xml
.idea/**/uiDesigner.xml
.idea/**/gradle.xml
.idea/**/libraries
*.iws /out/
# Python #
*.py[cod]
*$py.class
# Distribution / packaging
.Python build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
*.egg-info/
.installed.cfg
*.egg
*.manifest
*.spec
# Installer logs
pip-log.txt
pip-delete-this-directory.txt
# Unit test / coverage reports
htmlcov/
.tox/
.coverage
.coverage.*
.cache
.pytest_cache/
nosetests.xml
coverage.xml
*.cover
.hypothesis/
# Jupyter Notebook
.ipynb_checkpoints
# pyenv
.python-version
# celery
celerybeat-schedule.*
# SageMath parsed files
*.sage.py
# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/
# mkdocs documentation
/site
/docs/build
# mypy
.mypy_cache/
# Sublime Text #
*.tmlanguage.cache
*.tmPreferences.cache
*.stTheme.cache
*.sublime-workspace
*.sublime-project
# sftp configuration file
sftp-config.json
# Package control specific files Package
Control.last-run
Control.ca-list
Control.ca-bundle
Control.system-ca-bundle
GitHub.sublime-settings
# Visual Studio Code #
.vscode/*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json
.history
{
// Utilisez IntelliSense pour en savoir plus sur les attributs possibles.
// Pointez pour afficher la description des attributs existants.
// Pour plus d'informations, visitez : https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
"name": "frontend - dev",
"runtimeVersion": "14.15.4",
"cwd": "${workspaceFolder}/frontend",
"runtimeExecutable": "npm",
"runtimeArgs": ["run", "dev", "--max-old-space-size=1024"],
"restart": true,
"console": "integratedTerminal",
"skipFiles": ["<node_internals>/**"]
},
{
"name": "backend - DevMode",
"type": "python",
"request": "launch",
"program": "${workspaceFolder}/manage.py",
"console": "integratedTerminal",
"args": [
"runserver",
"--settings=dbchiro.settings.dev"
],
"django": true
},
{
"name": "backend - ProdMode",
"type": "python",
"request": "launch",
"program": "${workspaceFolder}/manage.py",
"console": "integratedTerminal",
"args": [
"runserver",
"--noreload",
"--nothreading",
"--settings=dbchiro.settings.production"
],
"django": true
},
{
"name": "Python: Current File (External Terminal)",
"type": "python",
"request": "launch",
"program": "${file}",
"console": "externalTerminal"
},
{
"name": "Python: Current File (Integrated Terminal)",
"type": "python",
"request": "launch",
"program": "${file}",
"console": "integratedTerminal"
}
]
}
\ No newline at end of file
{
"files.associations": {
"**/*.html": "html",
"**/templates/**/*.html": "django-html",
"**/templates/**/*": "django-txt",
"**/requirements{/**,*}.{txt,in}": "pip-requirements"
},
"emmet.includeLanguages": {
"django-html": "html"
},
// RST Config
"restructuredtext.confPath": "${workspaceFolder}/docs/source",
"python.linting.enabled": true,
"python.autoComplete.extraPaths": ["${workspaceFolder}/backend"],
"python.formatting.provider": "black",
"python.formatting.blackArgs": ["--line-length", "99"],
"python.linting.pylintEnabled": false,
"python.linting.flake8Enabled": true,
"python.linting.flake8Args": ["--max-line-length=99"],
"[python]": {
"editor.rulers": [99],
"editor.codeActionsOnSave": {
"source.organizeImports": true
},
"editor.formatOnSave": true
},
"editor.formatOnSave": false,
"sqltools.connections": [
{
"database": "gnlpoaura?sslmode=require",
"driver": "PostgreSQL",
"isActive": false,
"isConnected": false,
"name": "gnLpoAuRA",
"password": "Roh7Aun#AP",
"port": 5432,
"server": "bdd.lpo-aura.org",
"username": "lpoaura_fcl"
}
],
"beautify.language": {
"html": ["htm", "html", "django-html"]
},
"files.watcherExclude": {
"**/.git/objects/**": true,
"**/.git/subtree-cache/**": true,
"**/node_modules/*/**": true,
"**/venv/**": true,
"**/.venv/**": true
},
"cSpell.language": "en,fr",
"cSpell.enableFiletypes": [
"django-html",
"django-txt"
],
}
FROM python:3.8-slim
ARG DEBIAN_FRONTEND=noninteractive
ARG USERDIR=/usr/src/dbchiro
ARG USERNAME=dbchiro
ARG DEBIAN_FRONTEND=noninteractive
ARG APPDIR=/usr/src/dbchiro
# ARG USERNAME=dbchiro
ARG DJANGO_ENV
ENV DJANGO_ENV=${DJANGO_ENV} \
# python:
PYTHONFAULTHANDLER=1 \
PYTHONUNBUFFERED=1 \
PYTHONHASHSEED=random \
# pip:
PIP_NO_CACHE_DIR=off \
PIP_DISABLE_PIP_VERSION_CHECK=on \
PIP_DEFAULT_TIMEOUT=100 \
# poetry:
POETRY_VIRTUALENVS_CREATE=false \
POETRY_CACHE_DIR='/var/cache/pypoetry'
ENV PYTHONFAULTHANDLER=1 \
PYTHONHASHSEED=random \
PYTHONUNBUFFERED=1
RUN apt-get update -y \
&& apt-get install -y \
postgresql-client nginx python3-pip \
binutils libproj-dev gdal-bin
&& apt-get install --no-install-recommends -y \
libpq-dev nginx \
binutils libproj-dev gdal-bin postgresql-client \
&& apt-get autoremove -y && apt-get clean -y && rm -rf /var/lib/apt/lists/* \
&& pip install --upgrade pip && pip install poetry && poetry --version
RUN python3 -m pip install --upgrade pip \
&& python3 -m pip install poetry
WORKDIR ${APPDIR}
RUN addgroup --system -gid 1001 $USERNAME && adduser --system --home $USERDIR --uid 1001 --group $USERNAME && chown -R $USERNAME:$USERNAME $USERDIR
COPY pyproject.toml poetry.lock ./
USER $USERNAME
RUN poetry install
# RUN addgroup --system -gid 1001 $USERNAME && \
# adduser --system --home $USERDIR --uid 1001 --group $USERNAME && \
# chown -R $USERNAME:$USERNAME $USERDIR && \
# mkdir /app && chown -R $USERNAME:$USERNAME /app && \
# mkdir -p ${POETRY_CACHE_DIR} && chown -R $USERNAME:$USERNAME ${POETRY_CACHE_DIR}
WORKDIR $USERDIR
COPY pyproject.toml poetry.lock $USERDIR/
RUN poetry install
COPY docker-entrypoint.sh /usr/bin/docker-entrypoint.sh
COPY . /usr/src/dbchiro/
COPY . ${APPDIR}
VOLUME ["/dbchiro"]
......
......@@ -1616,16 +1616,19 @@ const sigthingFormApp = (id_session, type_contact) => {
this.message.push({ type: 'error', message: err })
})
},
dupSpecies() {
const cleanArray = [... new Set(this.species)]
let duplicates = [...this.species]
cleanArray.forEach((item) => {
const i = duplicates.indexOf(item)
duplicates = duplicates
.slice(0, i)
.concat(duplicates.slice(i + 1, duplicates.length))
})
console.debug('<dupSpecies>',duplicates) //[ 1, 5 ]
this.messages.push({type:'error', message: `dup species ${duplicates}`})
},
},
// computed: {
// data: () => {
// Countsum = (a, c) => a + c.count
// console.log('TEST DATA', this.data);
// this.data.forEach(
// (e, i) => this.data[i].total_count = this.data[i].countdetails.reduce(Countsum, 0)
// )
// }
// },
computed: {
species() {
return this.data.map((e) => e.codesp)
......@@ -1637,6 +1640,8 @@ const sigthingFormApp = (id_session, type_contact) => {
this.data.forEach((e, i) => {
e.total_count = this.sumCountDetails(i)
})
this.dupSpecies
},
deep: true,
},
......
This diff is collapsed.
version: "3"
services:
dbchiro:
labels:
- "traefik.enable=true"
- "traefik.http.routers.dbchiro.rule=Host(`dbchiro.local.dev`)"
- "traefik.http.routers.dbchiro.entrypoints=websecure"
# - "traefik.http.routers.whoami.tls.certresolver=myresolver"
- "traefik.http.services.dbchiro.loadbalancer.server.port=8000"
#!/bin/sh
#!/bin/bash
echo ""
echo "dbChiro init_____________________________________________"
......@@ -22,13 +22,12 @@ echo " *** *** ***"
echo " ** * **"
echo ""
export DBHOST=${POSTGRES_HOST:-db}
export DBNAME=${POSTGRES_DB:-dbchiro}
export DBUSER=${POSTGRES_USER:-dbadmin}
export DBPWD=${POSTGRES_PASSWORD:-myDbPassword}
export DBPORT=${POSTGRES_PORT:-5432}
export SECRETKEY=${SECRETKEY:-$(< /dev/urandom tr -dc _A-Z-a-z-0-9 | head -c50)}
export SECRETKEY=${SECRETKEY:-$(tr </dev/urandom -dc _A-Z-a-z-0-9 | head -c50)}
export SRID=${SRID:-4326}
export X=${DEFAULT_X:-5}
export Y=${DEFAULT_Y:-45}
......@@ -52,16 +51,17 @@ mv /usr/src/dbchiro/* /app/
if [ ! -f /dbchiro/config.py ]; then
echo "generate new config file"
tree /app/dbchiro/
mv /app/dbchiro/settings/configuration/config.py.sample /dbchiro/config.py
sed -i "s/dbHost/${DBHOST}/g" /dbchiro/config.py
sed -i "s/dbName/${DBNAME}/g" /dbchiro/config.py
sed -i "s/dbUser/${DBUSER}/g" /dbchiro/config.py
sed -i "s/dbPassword/${DBPWD}/g" /dbchiro/config.py
sed -i "s/dbPort/${DBPORT}/g" /dbchiro/config.py
sed -i "s/secretKey/${SECRETKEY}/g" /dbchiro/config.py
sed -i "s/geoDefaultProj/${SRID}/g" /dbchiro/config.py
sed -i "s/geoDefaultX/${X}/g" /dbchiro/config.py
sed -i "s/geoDefaultY/${Y}/g" /dbchiro/config.py
sed -i "s/secretKey/${SECRETKEY}/g" /dbchiro/config.py
sed -i "s/geoDefaultProj/${SRID}/g" /dbchiro/config.py
sed -i "s/geoDefaultX/${X}/g" /dbchiro/config.py
sed -i "s/geoDefaultY/${Y}/g" /dbchiro/config.py
sed -i "s/emailSmtpHost/${EMAIL_SMTP}/g" /dbchiro/config.py
sed -i "s/emailSsl/${EMAIL_SSL}/g" /dbchiro/config.py
sed -i "s/emailPort/${EMAIL_PORT}/g" /dbchiro/config.py
......@@ -70,31 +70,30 @@ if [ ! -f /dbchiro/config.py ]; then
sed -i "s/emailDefaultFrom/${EMAIL_DEFAULT_FROM}/g" /dbchiro/config.py
sed -i "s/IGN_API_KEY = 'yourapikey'/IGN_API_KEY = '${IGN_API_KEY}'/g" /dbchiro/config.py
else
echo "config file already exists"
echo "config file already exists"
fi
rm -f /app/dbchiro/settings/configuration/config.py
ln -s /dbchiro/config.py /app/dbchiro/settings/configuration/config.py
djapps="accounts blog dicts geodata management sights"
_djapps="accounts blog dicts geodata management sights"
if [ ! -d /dbchiro/migrations ]; then
echo "Create symlink for migrations dirs"
mkdir /dbchiro/migrations
for a in $djapps; do
echo "create $a migrations symlink"
if [ ! -d /dbchiro/migrations/$a ]; then
mkdir /dbchiro/migrations/$a
else
"$a migration dir and symlink already exists"
fi
for _a in $_djapps; do
echo "create $a migrations symlink"
if [ ! -d /dbchiro/migrations/$_a ]; then
mkdir /dbchiro/migrations/$_a
else
"$a migration dir and symlink already exists"
fi
done
else
echo "Migrations dir already exists"
fi
for a in $djapps; do
rm -rf /app/$a/migrations
ln -s /dbchiro/migrations/$a /app/$a/migrations
for a in $_djapps; do
rm -rf /app/$_a/migrations
ln -s /dbchiro/migrations/$_a /app/$_a/migrations
done
if [ ! -d /dbchiro/media ]; then
......@@ -107,10 +106,9 @@ fi
rm -rf /app/media
ln -s /dbchiro/media /app/media
until pg_isready -h $DBHOST -p $DBPORT
do
echo "Awaiting Database container"
sleep 1
until pg_isready -h $DBHOST -p $DBPORT; do
echo "Awaiting Database container on ${DBHOST}:${DBPORT}"
sleep 1
done
sleep 2
......@@ -121,11 +119,10 @@ chown -R www-data:www-data /app
export DJANGO_SETTINGS_MODULE=dbchiro.settings.$SETTINGS
echo "************ Init database ****************"
python3 -m manage makemigrations accounts core blog dicts geodata management sights
python3 -m manage migrate
python3 -m manage collectstatic --noinput
# poetry shell
python3 -m manage makemigrations accounts core blog dicts geodata management sights
python3 -m manage migrate
python3 -m manage collectstatic --noinput
if [ ! -f /dbchiro/logo_site.png ]; then
echo "Create default site logo image"
......@@ -139,7 +136,7 @@ ln -s /dbchiro/logo_site.png /app/static/img/logo_site.png
echo "************** Create dbChiro SU ******************"
script="
from accounts.models import Profile;
from accounts.models import Profile;
username = '$SU_USERNAME';
password = '$SU_PWD';
......@@ -152,37 +149,33 @@ if Profile.objects.filter(is_superuser=True).count()==0:
print('Superuser',username,'created.');
else:
print('One or more Superuser already exists, creation skipped.')
"
"
printf "$script" | python3 manage.py shell
echo "************** Populate with initial data ***************"
export countdict=$(printf "from dicts.models import PlacePrecision; print(PlacePrecision.objects.count())" | python3 manage.py shell)
if [ $countdict -eq 0 ]
then
echo "load dicts data"
python3 -m manage loaddata datas/dicts.json
rm -f datas/dicts.json
echo "dicts data loaded"
else
echo "dicts data already exists"
if [ $countdict -eq 0 ]; then
echo "load dicts data"
python3 -m manage loaddata dicts/fixtures/dicts.xml
rm -f dicts/fixtures/dicts.xml
echo "dicts data loaded"
else
echo "dicts data already exists"
fi
export countterritory=$(printf "from geodata.models import Territory; print(Territory.objects.count())" | python3 manage.py shell)
if [ $countterritory -eq 0 ]
then
echo "load geo datas, this may take a while..."
python3 -m manage loaddata datas/geodata.json.gz
rm -f datas/geodata.json.gz
echo "geo datas loaded"
else
echo "geo datas already exists"
if [ $countterritory -eq 0 ]; then
echo "load geo datas, this may take a while..."
python3 -m manage loaddata geodata/fixtures/geodata.xml
rm -f geodata/fixtures/geodata.xml
echo "geo datas loaded"
else
echo "geo datas already exists"
fi
#nginx Conf
echo "************ Configure NGINX ***************"
rm -f /etc/nginx/conf.d/default.conf
......@@ -193,6 +186,6 @@ sed -i "s/pathToApp/app/g" /etc/nginx/conf.d/dbchiro.conf
nginx -g "daemon off;" &
echo "************ Start Gunicorn ***************"
gunicorn -b 127.0.0.1:8000 dbchiro.wsgi
cd /app
poetry shell
gunicorn -b 127.0.0.1:8000 dbchiro.wsgi
......@@ -45,8 +45,8 @@ Observations de la session {{object.name}}
<span @click="addNewSighting()" class="btn btn-info btn-sm"><i class="fa fa-plus"></i> <strong>Nouveau
taxon</strong></span>
<span @click="postData()" type="submit" class="btn btn-sm btn-success"
><i class="fa fa-plus"></i>
<strong>Enregistrer</strong></span>
><i class="fa fa-fw fa-save"></i>
<strong>Tout enregistrer</strong></span>
<!-- <span @click="postData()" type="submit" class="btn btn-xs" :class="{'btn-warning':invalid,'btn-success':valid}"
:disabled="invalid"><i class="fa fa-plus" :class="{'fa-': invalid}"></i>
<strong>[[invalid ? 'Formulaire non valide': 'Enregistrer']]</strong></span>-->
......@@ -70,6 +70,7 @@ Observations de la session {{object.name}}
<span class="text-success pull-right" v-if="getSpecieValue(s.codesp,'sp_true')"><i
class="fa fa-check"></i></span>
[[ s.codesp ? getSpecieValue(s.codesp,'common_name_fr'):'Choisissez une espèce']]
<i v-show="s.breed_colo" class="fas fa-baby fa-fw text-success"></i>
</h4>
<div class="">
<div class="btn-group btn-sm pull-right">
......@@ -174,14 +175,14 @@ Observations de la session {{object.name}}
<td><span class="text-muted"><small>[[icd]]</small></td>
<!-- <td><span class="text-danger pull-right" @click="delCountDetail(selectedItem,icd)" tooltip><i
class="fa fa-trash"></i></span></td>-->
<td v-if="form_fields.includes('time')">[[cd.time]]</td>
<td v-if="form_fields.includes('time')">[[cd.time ? cd.time :'-']]</td>
<td v-if="form_fields.includes('method')" v-html="selectedValueHtml(filteredDict(dicts.Method, typeContact), cd.method)"></td>
<td v-if="form_fields.includes('sex')" v-html="selectedValueHtml(dicts.Sex, cd.sex)"></td>
<td v-if="form_fields.includes('age')" v-html="selectedValueHtml(dicts.Age, cd.age)"></td>
<td v-if="form_fields.includes('precision')" v-html="selectedValueHtml(filteredDict(dicts.CountPrecision, typeContact), cd.precision)"></td>
<td v-if="form_fields.includes('ab')">[[cd.ab]]</td>
<td v-if="form_fields.includes('poids')">[[cd.poids]]</td>
<td v-if="form_fields.includes('count')">[[cd.count]] [[dicts.CountUnit.find((e) => e.id == cd.unit)?.code]]</td>
<td v-if="form_fields.includes('count')">[[cd.count || '-']] [[dicts.CountUnit.find((e) => e.id == cd.unit)?.code]]</td>
</tr>
<tr v-if="countDetailSelectedItem == icd" :class="(invalid ? 'warning' : 'success')">
<td id="countDetailEditLine" colspan="100">
......
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