-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
20 changed files
with
181 additions
and
119 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
version: 2 | ||
updates: | ||
- package-ecosystem: pip | ||
directory: custom | ||
schedule: | ||
interval: daily | ||
time: '04:00' | ||
ignore: | ||
- dependency-name: none |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
ignored: | ||
- DL3008 # pin version: https://github.com/hadolint/hadolint/wiki/DL3008 | ||
- DL3003 # use workdir: https://github.com/hadolint/hadolint/wiki/DL3003 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
*.min.js | ||
custom/Pipfile.lock |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
FROM osgeo/gdal:ubuntu-small-3.2.1 AS base | ||
LABEL maintainer Camptocamp "[email protected]" | ||
|
||
# Fail on error on pipe, see: https://github.com/hadolint/hadolint/wiki/DL4006. | ||
# Treat unset variables as an error when substituting. | ||
# Print commands and their arguments as they are executed. | ||
SHELL ["/bin/bash", "-o", "pipefail", "-cux"] | ||
|
||
ENV DEBIAN_FRONTEND=noninteractive \ | ||
SSL_CERT_FILE=/etc/ssl/certs/ca-certificates.crt | ||
|
||
# hadolint ignore=SC1091 | ||
RUN . /etc/os-release && \ | ||
apt-get update && \ | ||
apt-get install --assume-yes --no-install-recommends \ | ||
python3-pip python3-dev python3-wheel python3-pkgconfig \ | ||
libpq-dev binutils gcc && \ | ||
apt-get clean && \ | ||
rm --recursive --force /var/lib/apt/lists/* | ||
|
||
COPY requirements.txt /tmp/ | ||
RUN python3 -m pip install --disable-pip-version-check --no-cache-dir --requirement=/tmp/requirements.txt && \ | ||
rm --recursive --force /tmp/* | ||
|
||
COPY Pipfile Pipfile.lock /tmp/ | ||
|
||
RUN cd /tmp && PIP_NO_BINARY=fiona,rasterio,shapely PROJ_DIR=/usr/local/ pipenv sync --system --clear && \ | ||
rm --recursive --force /usr/local/lib/python3.*/dist-packages/tests/ /tmp/* /root/.cache/* && \ | ||
strip /usr/local/lib/python3.*/dist-packages/*/*.so && \ | ||
python3 -m compileall -q /usr/local/lib/python3.* -x '/(ptvsd|pipenv|.*pydev.*|networkx)/' | ||
|
||
# hadolint ignore=DL3059 | ||
RUN apt-get remove --autoremove --assume-yes gcc | ||
|
||
WORKDIR /app | ||
COPY . /app | ||
RUN python3 -m pip install --disable-pip-version-check --no-cache-dir --editable=/app/ && \ | ||
python3 -m compileall -q /app/custom | ||
# hadolint ignore=DL3059 | ||
RUN mkdir -p /etc/gunicorn/ && \ | ||
mv gunicorn_config.py /etc/gunicorn/config.py | ||
|
||
CMD [ "/usr/local/bin/gunicorn", "--paste", "production.ini" ] | ||
|
||
ARG GIT_HASH | ||
ENV GIT_HASH=${GIT_HASH} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import smtplib | ||
from email.message import EmailMessage | ||
from email.utils import formatdate | ||
|
||
|
||
def send_mail(mail_list, text, subject): | ||
msg = EmailMessage() | ||
msg["From"] = "[email protected]" | ||
msg["To"] = ", ".join(mail_list) | ||
msg["Date"] = formatdate(localtime=True) | ||
msg["Subject"] = subject | ||
msg.set_content(text) | ||
s = smtplib.SMTP("smtp.ne.ch") | ||
s.send_message(msg) | ||
s.quit() |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
import os | ||
|
||
import pyramid.request | ||
from cornice import Service | ||
from pyramid.httpexceptions import HTTPBadRequest | ||
from pyramid.view import view_config | ||
|
||
from c2cgeoportal_commons.models import DBSession | ||
|
||
from .. import models | ||
from ..models import Feedback | ||
from ..util.sendmail import send_mail | ||
|
||
feedback = Service( | ||
name="feedback", | ||
description="The feedback service", | ||
path="/feedback", | ||
cors_origins=(os.environ.get("VISIBLE_WEB_HOST", "*"),), | ||
) | ||
|
||
|
||
@feedback.post() | ||
def feedback_post(request: pyramid.request.Request) -> None: | ||
if ( | ||
"permalink" not in request.params | ||
or "ua" not in request.params | ||
or "email" not in request.params | ||
or "email_optional" not in request.params | ||
or "feedback" not in request.params | ||
): | ||
return HTTPBadRequest(detail="parameter missing") | ||
|
||
new_feedback = Feedback() | ||
new_feedback.ua = request.params["ua"] | ||
new_feedback.permalink = request.params["permalink"] | ||
new_feedback.email = request.params["email"] | ||
email_optional = request.params["email_optional"] | ||
new_feedback.text = request.params["feedback"] | ||
DBSession.add(new_feedback) | ||
DBSession.flush() | ||
|
||
if "admin_email" in request.registry.settings: | ||
mail_list = [request.registry.settings["admin_email"]] | ||
|
||
if email_optional is not None and email_optional != "": | ||
mail_list.append(email_optional) | ||
instance = request.params["permalink"].split("?")[0] | ||
text = "\n\n".join( | ||
[ | ||
"Ceci est un email automatique. Un nouveau feedback a été inséré dans la BD.", | ||
"Cela concerne l'instance : " + instance, | ||
"Son identifiant est le : " + str(new_feedback.id_feedback), | ||
"User agent : " + new_feedback.ua, | ||
"Permalink : " + new_feedback.permalink, | ||
"User email : " + new_feedback.email, | ||
"User text : " + new_feedback.text, | ||
] | ||
) | ||
subject = "Feedback - Guichet cartographique" | ||
|
||
if mail_list[0] != "[email protected]": | ||
send_mail(mail_list, text, subject) | ||
|
||
return {"success": True} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
accesslog = "-" | ||
access_log_format = '%(H)s %({Host}i)s %(m)s %(U)s?%(q)s "%(f)s" "%(a)s" %(s)s %(B)s %(D)s %(p)s' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
pipenv==2021.5.29 |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters