Compare commits
57 Commits
drone-conf
...
implement_
Author | SHA1 | Date | |
---|---|---|---|
c4f5979d95 | |||
92f5393a4c | |||
383ef8b512 | |||
033dee7836 | |||
ca81e8bf70
|
|||
d507a20a93 | |||
3f2c23c386
|
|||
b46ac5e379 | |||
fa4429b6ef | |||
7a0f2434db | |||
8c3fe3fe7d | |||
56ade6de68 | |||
28cf714217 | |||
9ff56f6676 | |||
2412df4960
|
|||
469ef511d6 | |||
47d2c94b79
|
|||
384dd82454 | |||
b0dcfacd25
|
|||
86edb246bf | |||
9424e21edc | |||
f02efab07a | |||
08f1104942
|
|||
8dde142f38
|
|||
d1b1636aa2 | |||
3fcd1fa20e | |||
8394400e96 | |||
843050f923 | |||
812913ffe2 | |||
dee80c7e14 | |||
de60ec0d46 | |||
6c6fcea81c | |||
166e0d40c6 | |||
c9b5ab62ed | |||
c0005100b4 | |||
d614039cdd | |||
316236a7e5 | |||
c15faabd6d
|
|||
53eab74e60 | |||
82d908193c | |||
6620a6819a | |||
be6fec18ab
|
|||
9ebae03550 | |||
763a6efc9f | |||
6f04d23e6c
|
|||
155ddc556c
|
|||
a5a85e6032
|
|||
6a3458a596
|
|||
97be8f4667
|
|||
776803fc96 | |||
702f4968f6 | |||
c1285153ef
|
|||
fdc81844b5
|
|||
b804c22a93
|
|||
9a7a9379e2 | |||
5b707ad294 | |||
c05f040313
|
13
.dockerignore
Normal file
13
.dockerignore
Normal file
@ -0,0 +1,13 @@
|
||||
# SPDX-FileCopyrightText: WTF Kooperative eG <https://wtf-eg.de/>
|
||||
#
|
||||
# SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
|
||||
*
|
||||
!Pipfile
|
||||
!Pipfile.lock
|
||||
!data/
|
||||
!ki/
|
||||
!LICENSES/
|
||||
!migrations/
|
||||
!app.py
|
||||
!run_prod.py
|
34
.drone.yml
34
.drone.yml
@ -15,16 +15,18 @@ trigger:
|
||||
|
||||
steps:
|
||||
- name: install-lint-test
|
||||
image: registry.wtf-eg.net/ki-backend-builder:1.0.0
|
||||
image: python:3.8.19-alpine@sha256:3bd7ea88cb637e09d6c7de24c5394657163a85c2be82bfebe0305cf07f8de1ea
|
||||
env:
|
||||
PYROOT: '/pyroot'
|
||||
PYTHONUSERBASE: '/pyroot'
|
||||
commands:
|
||||
- apk add --no-cache gcc g++ musl-dev python3-dev
|
||||
- pip3 install pipenv
|
||||
- pipenv install --dev
|
||||
- pipenv run flake8
|
||||
- pipenv run reuse lint
|
||||
- pipenv run python -m unittest discover ki
|
||||
|
||||
image_pull_secrets:
|
||||
- dockerconfig
|
||||
|
||||
---
|
||||
kind: pipeline
|
||||
type: docker
|
||||
@ -41,10 +43,10 @@ depends_on:
|
||||
|
||||
steps:
|
||||
- name: docker-publish
|
||||
image: plugins/docker
|
||||
image: plugins/docker:20.18.4@sha256:a8d3d86853c721492213264815f1d00d3ed13f42f5c1855a02f47fa4d5f1e042
|
||||
settings:
|
||||
registry: registry.wtf-eg.net
|
||||
repo: registry.wtf-eg.net/ki-backend
|
||||
registry: git.wtf-eg.de
|
||||
repo: git.wtf-eg.de/kompetenzinventar/backend
|
||||
target: ki-backend
|
||||
auto_tag: true
|
||||
username:
|
||||
@ -68,7 +70,7 @@ depends_on:
|
||||
|
||||
steps:
|
||||
- name: deploy-dev
|
||||
image: appleboy/drone-ssh
|
||||
image: appleboy/drone-ssh:1.7.5@sha256:995677e073454912f26d4c0fdd2f9df2e1f5a30d6603d3f2ece667311b6babb3
|
||||
settings:
|
||||
host:
|
||||
- dev01.wtf-eg.net
|
||||
@ -91,23 +93,25 @@ trigger:
|
||||
|
||||
steps:
|
||||
- name: install-lint-test
|
||||
image: registry.wtf-eg.net/ki-backend-builder:1.0.0
|
||||
image: python:3.8.19-alpine@sha256:3bd7ea88cb637e09d6c7de24c5394657163a85c2be82bfebe0305cf07f8de1ea
|
||||
env:
|
||||
PYROOT: '/pyroot'
|
||||
PYTHONUSERBASE: '/pyroot'
|
||||
commands:
|
||||
- apk add --no-cache gcc g++ musl-dev python3-dev
|
||||
- pip3 install pipenv
|
||||
- pipenv install --dev
|
||||
- pipenv run flake8
|
||||
- pipenv run reuse lint
|
||||
- pipenv run python -m unittest discover ki
|
||||
- name: docker-publish
|
||||
image: plugins/docker
|
||||
image: plugins/docker:20.18.4@sha256:a8d3d86853c721492213264815f1d00d3ed13f42f5c1855a02f47fa4d5f1e042
|
||||
settings:
|
||||
registry: registry.wtf-eg.net
|
||||
repo: registry.wtf-eg.net/ki-backend
|
||||
registry: git.wtf-eg.de
|
||||
repo: git.wtf-eg.de/kompetenzinventar/backend
|
||||
target: ki-backend
|
||||
auto_tag: true
|
||||
username:
|
||||
from_secret: "docker_username"
|
||||
password:
|
||||
from_secret: "docker_password"
|
||||
|
||||
image_pull_secrets:
|
||||
- dockerconfig
|
||||
|
@ -27,5 +27,5 @@ repos:
|
||||
name: reuse
|
||||
entry: reuse lint
|
||||
language: system
|
||||
exclude: .*
|
||||
exclude: ^(venv).*$
|
||||
always_run: true
|
||||
|
1
.python-version
Normal file
1
.python-version
Normal file
@ -0,0 +1 @@
|
||||
3.8.19
|
@ -10,3 +10,7 @@ License: MIT
|
||||
Files: Pipfile.lock migrations/*
|
||||
Copyright: WTF Kooperative eG <https://wtf-eg.de/>
|
||||
License: AGPL-3.0-or-later
|
||||
|
||||
Files: renovate.json .python-version
|
||||
Copyright: WTF Kooperative eG <https://wtf-eg.de/>
|
||||
License: AGPL-3.0-or-later
|
||||
|
5
.yapfignore
Normal file
5
.yapfignore
Normal file
@ -0,0 +1,5 @@
|
||||
# SPDX-FileCopyrightText: WTF Kooperative eG <https://wtf-eg.de/>
|
||||
#
|
||||
# SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
|
||||
migrations/*.py
|
22
Dockerfile
22
Dockerfile
@ -2,7 +2,17 @@
|
||||
#
|
||||
# SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
|
||||
FROM registry.wtf-eg.net/ki-backend-builder:1.0.1 as builder
|
||||
FROM python:3.8.19-alpine@sha256:3bd7ea88cb637e09d6c7de24c5394657163a85c2be82bfebe0305cf07f8de1ea AS builder
|
||||
|
||||
ENV PYROOT=/pyroot
|
||||
ENV PYTHONUSERBASE=$PYROOT
|
||||
|
||||
RUN apk add --no-cache \
|
||||
gcc \
|
||||
g++ \
|
||||
musl-dev \
|
||||
python3-dev && \
|
||||
pip3 install pipenv
|
||||
|
||||
COPY Pipfile* ./
|
||||
|
||||
@ -10,7 +20,10 @@ RUN PIP_USER=1 PIP_IGNORE_INSTALLED=1 pipenv install --system --deploy --ignore-
|
||||
RUN pip3 uninstall --yes pipenv
|
||||
|
||||
|
||||
FROM registry.wtf-eg.net/ki-backend-base:1.0.1 as ki-backend
|
||||
FROM python:3.8.19-alpine@sha256:3bd7ea88cb637e09d6c7de24c5394657163a85c2be82bfebe0305cf07f8de1ea AS ki-backend
|
||||
|
||||
ENV PYROOT=/pyroot
|
||||
ENV PYTHONUSERBASE=$PYROOT
|
||||
|
||||
# Install six explicitly. Otherwise Python complains about it missing.
|
||||
RUN pip3 install six
|
||||
@ -22,4 +35,9 @@ WORKDIR /app
|
||||
|
||||
COPY . .
|
||||
|
||||
LABEL org.opencontainers.image.source=https://git.wtf-eg.de/kompetenzinventar/ki-backend.git
|
||||
LABEL org.opencontainers.image.url=https://git.wtf-eg.de/kompetenzinventar/ki-backend
|
||||
LABEL org.opencontainers.image.documentation=https://git.wtf-eg.de/kompetenzinventar/ki-backend#docker
|
||||
LABEL org.opencontainers.image.vendor="WTF Kooperative eG"
|
||||
|
||||
CMD ["python3", "run_prod.py"]
|
||||
|
29
Pipfile
29
Pipfile
@ -8,22 +8,23 @@ verify_ssl = true
|
||||
name = "pypi"
|
||||
|
||||
[packages]
|
||||
flask = "~=2.0.1"
|
||||
python-dotenv = "~=0.17.1"
|
||||
flask-migrate = "~=3.0.1"
|
||||
flask-sqlalchemy = "~=2.5.1"
|
||||
sqlalchemy = "~=1.4.18"
|
||||
waitress = "~=2.0.0"
|
||||
pyyaml = "~=6.0.1"
|
||||
flask-cors = "~=3.0.10"
|
||||
ldap3 = "~=2.9"
|
||||
pymysql = "~=1.0.2"
|
||||
flask = "==2.3.3"
|
||||
python-dotenv = "==0.21.1"
|
||||
flask-migrate = "==3.0.1"
|
||||
flask-sqlalchemy = "==2.5.1"
|
||||
sqlalchemy = "==1.4.53"
|
||||
waitress = "==2.1.2"
|
||||
pyyaml = "==6.0.2"
|
||||
flask-cors = "==3.0.10"
|
||||
ldap3 = "==2.9.1"
|
||||
pymysql = "==1.1.1"
|
||||
werkzeug = "==2.3.8"
|
||||
|
||||
[dev-packages]
|
||||
flake8 = "~=3.9.2"
|
||||
yapf = "~=0.31.0"
|
||||
pre-commit = "~=2.13.0"
|
||||
reuse = "~=0.13.0"
|
||||
flake8 = "==6.1.0"
|
||||
yapf = "==0.40.2"
|
||||
pre-commit = "==2.13.0"
|
||||
reuse = "==0.14.0"
|
||||
|
||||
[requires]
|
||||
python_version = "3.8"
|
||||
|
1060
Pipfile.lock
generated
1060
Pipfile.lock
generated
File diff suppressed because it is too large
Load Diff
19
README.md
19
README.md
@ -222,25 +222,6 @@ docker-compose up
|
||||
|
||||
Dann http://localhost:13337 aufrufen.
|
||||
|
||||
### Workaround, falls der Zugriff auf registry.wtf-eg.net nicht möglich ist
|
||||
|
||||
Voraussetzung:
|
||||
|
||||
[ki-backend-docker](https://git.wtf-eg.de/kompetenzinventar/ki-backend-docker) muss parallel zum `ki-backend` ausgecheckt sein.
|
||||
|
||||
```
|
||||
cd ki-backend-docker
|
||||
docker build . --target base -t ki-backend-base
|
||||
docker build . --target builder -t ki-backend-builder
|
||||
```
|
||||
|
||||
Ändern der 2 Einträge im `Dockerfile` des `ki-backend`:
|
||||
|
||||
- registry.wtf-eg.net/ki-backend-builder:1.0.0 -> ki-backend-builder
|
||||
- registry.wtf-eg.net/ki-backend-base:1.0.0 -> ki-backend-base
|
||||
|
||||
Danach sollte `docker-compose up` funktionieren.
|
||||
|
||||
## Lizenzen
|
||||
|
||||
Dieses Projekt erfüllt die [REUSE](https://reuse.software/) Spezifikation.
|
||||
|
5
app.py
5
app.py
@ -42,5 +42,8 @@ db = SQLAlchemy(app)
|
||||
migrate = Migrate(app, db, compare_type=True)
|
||||
|
||||
app.logger.info("Hello from KI")
|
||||
|
||||
from ki import module # noqa
|
||||
from ki import resume
|
||||
|
||||
|
||||
app.register_blueprint(resume.bp_resume, url_prefix='/resume')
|
||||
|
5
data/imgs/flags/ca.svg
Normal file
5
data/imgs/flags/ca.svg
Normal file
@ -0,0 +1,5 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="810" height="540">
|
||||
<rect width="810" height="540" fill="#FCDD09"/>
|
||||
<path stroke="#DA121A" stroke-width="60" d="M0,90H810m0,120H0m0,120H810m0,120H0"/>
|
||||
</svg>
|
After Width: | Height: | Size: 242 B |
@ -33,7 +33,7 @@ class Profile(db.Model):
|
||||
volunteerwork = Column(String(4000), default="")
|
||||
freetext = Column(String(4000), default="")
|
||||
|
||||
availability_status = Column(Boolean, default=False)
|
||||
availability_status = Column(Boolean, default=False, nullable=False)
|
||||
availability_text = Column(String(4000), default="")
|
||||
availability_hours_per_week = Column(Integer, default=0)
|
||||
|
||||
|
32
ki/resume.py
Normal file
32
ki/resume.py
Normal file
@ -0,0 +1,32 @@
|
||||
# SPDX-FileCopyrightText: WTF Kooperative eG <https://wtf-eg.de/>
|
||||
#
|
||||
# SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
|
||||
from flask import Blueprint
|
||||
from ki.token_auth import token_auth
|
||||
from ki.resume_models import Resume
|
||||
|
||||
bp_resume = Blueprint('resume', __name__,
|
||||
template_folder='templates')
|
||||
|
||||
|
||||
@bp_resume.route('/')
|
||||
@token_auth
|
||||
def show(page):
|
||||
"""
|
||||
return the list of resumes as object with data array inside
|
||||
"""
|
||||
pass
|
||||
|
||||
|
||||
@bp_resume.route("/<resume_id>")
|
||||
@token_auth
|
||||
def get_resume(resume_id):
|
||||
"""
|
||||
lookup for resume with resume_id, check if its from this user
|
||||
and provide its contents in the appropriate format
|
||||
shall support 'format' parameter with values of 'html', 'pdf'
|
||||
if no parameter is given, json is returned
|
||||
"""
|
||||
r = Resume()
|
||||
return r.to_dict()
|
28
ki/resume_models.py
Normal file
28
ki/resume_models.py
Normal file
@ -0,0 +1,28 @@
|
||||
# SPDX-FileCopyrightText: WTF Kooperative eG <https://wtf-eg.de/>
|
||||
#
|
||||
# SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
|
||||
|
||||
from sqlalchemy import Column, Integer, String, ForeignKey, JSON
|
||||
from sqlalchemy.orm import relationship
|
||||
from app import db
|
||||
|
||||
|
||||
class Resume(db.Model):
|
||||
__tablename__ = 'resume'
|
||||
|
||||
id = Column(Integer, primary_key=True)
|
||||
|
||||
user_id = Column(Integer, ForeignKey("user.id", ondelete='CASCADE'))
|
||||
label = Column("label", String(50), nullable=True)
|
||||
data = Column('data', JSON)
|
||||
|
||||
user = relationship("User", backref='user', passive_deletes=True)
|
||||
|
||||
def to_dict(self):
|
||||
return {
|
||||
"id": self.id,
|
||||
'user_id': self.user_id,
|
||||
"label": self.label,
|
||||
"data": self.data
|
||||
}
|
27
ki/routes.py
27
ki/routes.py
@ -4,41 +4,18 @@
|
||||
|
||||
import os
|
||||
from flask import g, make_response, request, send_file
|
||||
from functools import wraps
|
||||
|
||||
from ki.auth import auth
|
||||
from ki.handlers import find_profiles as find_profiles_handler
|
||||
from ki.handlers import update_profile as update_profile_handler
|
||||
from ki.models import ContactType, Language, Skill, Token, User
|
||||
from ki.models import ContactType, Language, Skill, User
|
||||
from app import app
|
||||
from ki.token_auth import token_auth
|
||||
|
||||
content_type_svg = "image/svg+xml"
|
||||
content_type_png = "image/png"
|
||||
|
||||
|
||||
def token_auth(func):
|
||||
@wraps(func)
|
||||
def _token_auth(*args, **kwargs):
|
||||
auth_header = request.headers.get("Authorization")
|
||||
|
||||
if (auth_header is None):
|
||||
return make_response({}, 401)
|
||||
|
||||
if not auth_header.startswith("Bearer"):
|
||||
return make_response({}, 401)
|
||||
|
||||
token = Token.query.filter(Token.token == auth_header[7:]).first()
|
||||
|
||||
if token is None:
|
||||
return make_response({}, 403)
|
||||
|
||||
g.user = token.user
|
||||
|
||||
return func(*args, **kwargs)
|
||||
|
||||
return _token_auth
|
||||
|
||||
|
||||
def models_to_list(models):
|
||||
models_list = []
|
||||
|
||||
|
@ -8,6 +8,7 @@ from ki.test.ApiTest import ApiTest
|
||||
|
||||
|
||||
class TestContactTypesEndpoint(ApiTest):
|
||||
|
||||
def test_skills_options(self):
|
||||
response = self.client.options("/contacttypes")
|
||||
self.assertEqual(response.status_code, 200)
|
||||
|
@ -8,6 +8,7 @@ from ki.test.ApiTest import ApiTest
|
||||
|
||||
|
||||
class TestFindProfilesEndpoint(ApiTest):
|
||||
|
||||
def test_find_profiles_options(self):
|
||||
response = self.client.options("/users/profiles")
|
||||
self.assertEqual(response.status_code, 200)
|
||||
|
@ -8,6 +8,7 @@ from ki.test.ApiTest import ApiTest
|
||||
|
||||
|
||||
class TestLanguagesEndpoint(ApiTest):
|
||||
|
||||
def test_skills_options(self):
|
||||
response = self.client.options("/languages")
|
||||
self.assertEqual(response.status_code, 200)
|
||||
|
@ -10,6 +10,7 @@ from ki.test.ApiTest import ApiTest
|
||||
|
||||
|
||||
class TestLoginEndpoint(ApiTest):
|
||||
|
||||
def test_login(self):
|
||||
response1_data = self.login("peter", "geheim")
|
||||
response2_data = self.login("peter", "geheim")
|
||||
|
@ -8,6 +8,7 @@ from ki.test.ApiTest import ApiTest
|
||||
|
||||
|
||||
class TestSkillsEndpoint(ApiTest):
|
||||
|
||||
def test_skills_options(self):
|
||||
response = self.client.options("/skills")
|
||||
self.assertEqual(response.status_code, 200)
|
||||
|
31
ki/token_auth.py
Normal file
31
ki/token_auth.py
Normal file
@ -0,0 +1,31 @@
|
||||
# SPDX-FileCopyrightText: WTF Kooperative eG <https://wtf-eg.de/>
|
||||
#
|
||||
# SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
|
||||
from flask import g, make_response, request
|
||||
from functools import wraps
|
||||
|
||||
from ki.models import Token
|
||||
|
||||
|
||||
def token_auth(func):
|
||||
@wraps(func)
|
||||
def _token_auth(*args, **kwargs):
|
||||
auth_header = request.headers.get("Authorization")
|
||||
|
||||
if (auth_header is None):
|
||||
return make_response({}, 401)
|
||||
|
||||
if not auth_header.startswith("Bearer"):
|
||||
return make_response({}, 401)
|
||||
|
||||
token = Token.query.filter(Token.token == auth_header[7:]).first()
|
||||
|
||||
if token is None:
|
||||
return make_response({}, 403)
|
||||
|
||||
g.user = token.user
|
||||
|
||||
return func(*args, **kwargs)
|
||||
|
||||
return _token_auth
|
35
migrations/versions/6be5073423b4_add_resume.py
Normal file
35
migrations/versions/6be5073423b4_add_resume.py
Normal file
@ -0,0 +1,35 @@
|
||||
"""add resume
|
||||
|
||||
Revision ID: 6be5073423b4
|
||||
Revises: b5023977cbda
|
||||
Create Date: 2024-08-30 18:18:14.555874
|
||||
|
||||
"""
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '6be5073423b4'
|
||||
down_revision = 'b5023977cbda'
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def upgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.create_table('resume',
|
||||
sa.Column('id', sa.Integer(), nullable=False),
|
||||
sa.Column('user_id', sa.Integer(), nullable=True),
|
||||
sa.Column('label', sa.String(length=50), nullable=True),
|
||||
sa.Column('data', sa.JSON(), nullable=True),
|
||||
sa.ForeignKeyConstraint(['user_id'], ['user.id'], ondelete='CASCADE'),
|
||||
sa.PrimaryKeyConstraint('id')
|
||||
)
|
||||
# ### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.drop_table('resume')
|
||||
# ### end Alembic commands ###
|
18
renovate.json
Normal file
18
renovate.json
Normal file
@ -0,0 +1,18 @@
|
||||
{
|
||||
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
|
||||
"extends": [
|
||||
"config:best-practices",
|
||||
":disableDependencyDashboard",
|
||||
":maintainLockFilesMonthly",
|
||||
":pinVersions",
|
||||
":separateMultipleMajorReleases"
|
||||
],
|
||||
"packageRules": [
|
||||
{
|
||||
"matchDepNames": ["python"],
|
||||
"groupName": "Python",
|
||||
"separateMinorPatch": true,
|
||||
"separateMultipleMinor": true
|
||||
}
|
||||
]
|
||||
}
|
Reference in New Issue
Block a user