Commit 1822af50 authored by Hypsug0's avatar Hypsug0
Browse files

Merge branch 'develop' into 'develop'

v1.3.0

See merge request !56
parents f5643d7d 0ca36b89
.git
*.pyc
.env
.env.sample
**/__pycache__
**/.classpath
**/.dockerignore
**/.env
**/.git
**/.gitignore
**/.project
**/.settings
**/.toolstarget
**/.vs
**/.vscode
**/*.*proj.user
**/*.dbmdl
**/*.jfm
**/azds.yaml
**/bin
**/charts
**/docker-compose*
**/compose*
**/Dockerfile*
**/node_modules
**/npm-debug.log
**/obj
**/secrets.dev.yaml
**/values.dev.yaml
**/.venv
**/.pyc
README.md
# https://editorconfig.org/
root = true
[*]
indent_style = space
indent_size = 4
insert_final_newline = true
trim_trailing_whitespace = true
end_of_line = lf
charset = utf-8
# Docstrings and comments use max_line_length = 79
[*.py]
max_line_length = 99
# Use 2 spaces for the HTML files
[*.html]
indent_size = 2
# The JSON files contain newlines inconsistently
[*.json]
indent_size = 2
insert_final_newline = ignore
[**/admin/js/vendor/**]
indent_style = ignore
indent_size = ignore
# Minified JavaScript files shouldn't be changed
[**.min.js]
indent_style = ignore
insert_final_newline = ignore
# Makefiles always use tabs for indentation
[Makefile]
indent_style = tab
# Batch files use tabs for indentation
[*.bat]
indent_style = tab
[docs/**.txt]
max_line_length = 79
[*.yml]
indent_size = 2
[flake8]
ignore =
E121,
E126,
E127,
E128,
E203,
E225,
E226,
E231,
E241,
E251,
E261,
E265,
E302,
E303,
E305,
E402,
E501,
E741,
W291,
W292,
W293,
W391,
W503,
W504,
F403,
F405,
B007,
B950,
exclude =
.git,
.venv,
__pycache__,
docs/source/conf.py,
frontend,
node-modules,
build,
dist,
migrations
max-complexity = 10
\ No newline at end of file
......@@ -21,4 +21,135 @@ core/static/img/logo_site.png
/docs/build
/frontend/node_modules
.env
.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
repos:
- repo: https://github.com/ambv/black
rev: stable
hooks:
- id: black
language_version: python3.8
- repo: https://gitlab.com/pycqa/flake8
rev: 3.8.4
hooks:
- id: flake8
{
"trailingComma": "es5",
"tabWidth": 4,
"semi": false,
"singleQuote": true
}
\ No newline at end of file
{
// 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
},
"autoDocstring.docstringFormat": "sphinx",
"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"]
},
"[django-html]": {
"editor.formatOnSave": true,
"editor.defaultFormatter": "HookyQR.beautify"
},
"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:alpine
ENV PYTHONUNBUFFERED 1
ENV PYTHONDONTWRITEBYTECODE 1
WORKDIR /usr/src/dbchiro
COPY requirements.txt /usr/src/dbchiro
RUN apk add --no-cache \
--upgrade \
--repository http://dl-cdn.alpinelinux.org/alpine/edge/main \
postgresql-client \
libpq \
nginx \
binutils \
&& apk add --no-cache \
--upgrade \
--repository http://dl-cdn.alpinelinux.org/alpine/edge/main \
--virtual .build-deps \
postgresql-dev \
zlib-dev jpeg-dev \
alpine-sdk \
poppler \
&& apk add --no-cache \
--upgrade \
--repository http://dl-cdn.alpinelinux.org/alpine/edge/community \
geos \
proj \
gdal \
&& ln -s /usr/lib/libproj.so.15 /usr/lib/libproj.so \
&& ln -s /usr/lib/libgdal.so.20 /usr/lib/libgdal.so \
&& ln -s /usr/lib/libgeos_c.so.1 /usr/lib/libgeos_c.so \
&& mkdir /var/run/nginx
COPY requirements.txt /usr/src/dbchiro
RUN python3 -m pip install --upgrade pip --no-cache-dir \
&& python3 -m pip install -r requirements.txt --no-cache-dir \
&& python3 -m pip install gunicorn --no-cache-dir \
&& apk --purge del .build-deps
FROM python:3.8-slim
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'
RUN apt-get update -y \
&& 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
WORKDIR ${APPDIR}
COPY pyproject.toml poetry.lock ./
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}
COPY docker-entrypoint.sh /usr/bin/docker-entrypoint.sh
COPY . /usr/src/dbchiro
COPY . ${APPDIR}
VOLUME ["/dbchiro"]
......@@ -50,5 +51,4 @@ WORKDIR /app
EXPOSE 80
ENTRYPOINT ["/usr/bin/docker-entrypoint.sh"]
ENTRYPOINT ["bash", "/usr/bin/docker-entrypoint.sh"]
FROM makinacorpus/geodjango:bionic-3.7
ENV PYTHONUNBUFFERED 1
ENV PYTHONDONTWRITEBYTECODE 1
WORKDIR /usr/src/dbchiro
COPY requirements.txt /usr/src/dbchiro
RUN apt update -y \
&& apt-get install -y \
postgresql-client \
nginx \
python3-pip
COPY requirements.txt /usr/src/dbchiro
RUN python3 -m pip install --upgrade pip \
&& python3 -m pip install -r requirements.txt \
&& python3 -m pip install gunicorn
COPY docker-entrypoint-ubuntu.sh /usr/bin/docker-entrypoint.sh
COPY . /usr/src/dbchiro
VOLUME ["/dbchiro"]
WORKDIR /app
EXPOSE 80
ENTRYPOINT ["/usr/bin/docker-entrypoint.sh"]
1.2.1-dev
\ No newline at end of file
1.3.0-dev
from django.contrib import admin
from leaflet.admin import LeafletGeoAdminMixin, LeafletGeoAdmin
from django.contrib.auth.admin import UserAdmin
from leaflet.admin import LeafletGeoAdmin
from .models import Profile
class GeoUserAdmin(LeafletGeoAdmin):
list_display = ['id','username','email','first_name','last_name','is_superuser','is_staff','is_active','last_login']
search_fields = ['username','email','first_name','last_name']
list_filter = ('is_active','is_staff','is_superuser')
list_display = [
"id",
"username",
"email",
"first_name",
"last_name",
"is_superuser",
"is_staff",
"is_active",
"last_login",
]
search_fields = ["username", "email", "first_name", "last_name"]
list_filter = ("is_active", "is_staff", "is_superuser")
admin.site.register(Profile, GeoUserAdmin)
# import the logging library
import logging
from django.contrib.auth.mixins import LoginRequiredMixin
from django.db.models import Q
from django.db.models.query import QuerySet
from rest_framework import generics
from sights.models import Session
from .models import Profile
from .serializer import ProfileSearchSerializer
# Get an instance of a logger
logger = logging.getLogger(__name__)
def filterUser(qs: QuerySet, q: str) -> QuerySet:
return qs.filter(
Q(username__icontains=q)
| Q(first_name__icontains=q)
| Q(last_name__icontains=q)
| Q(email__icontains=q)
)
class ProfileAutocompleteSearch(
LoginRequiredMixin,
generics.ListAPIView,
):
pagination_class = None
serializer_class = ProfileSearchSerializer
def get_queryset(self):
qs = Profile.objects
q = self.request.query_params.get("q", None)
id = self.request.query_params.get("id", None)
session = self.request.query_params.get("session", None)
logger.debug(f"ProfileAutocompleteSearch API querystring {q} {id} {session}")
if id:
qs = qs.filter(id=int(id))
result = qs.all()
if q and not id:
if session:
mainobs = filterUser(Session.objects.get(pk=session).main_observer.all(), q)
otherobs = filterUser(Session.objects.get(pk=session).other_observer.all(), q)
result = set(mainobs + otherobs)
else:
qs = filterUser(qs, q)
result = qs.order_by("get_full_name").order_by("is_active").all()
logger.debug(f"ProfileAutocompleteSearch API result {result}")
return result
......@@ -2,5 +2,5 @@ from django.apps import AppConfig
class AccountsConfig(AppConfig):
name = 'accounts'
label = 'Gestion des comptes observateurs'
name = "accounts"
label = "Gestion des comptes observateurs"
import django_filters
from .models import Profile
from .forms import ProfileSearchFilterForm
from .models import Profile
class ProfileFilter(django_filters.FilterSet):
username = django_filters.CharFilter(label="Utilisateur", lookup_expr=