forked from kompetenzinventar/ki-backend
Compare commits
9 Commits
a9390a35aa
...
d7f4acf251
Author | SHA1 | Date | |
---|---|---|---|
d7f4acf251 | |||
c65ef4a95c | |||
f3840f18b7 | |||
da46d01765 | |||
0f9f807256 | |||
66294cd52f | |||
|
d4a5c8f5eb | ||
|
5e4d6d464d | ||
|
6e77647eb9 |
@ -2,7 +2,7 @@
|
||||
#
|
||||
# SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
|
||||
FROM registry.wtf-eg.net/ki-backend-builder:1.0.0 as builder
|
||||
FROM registry.wtf-eg.net/ki-backend-builder:1.0.1 as builder
|
||||
|
||||
COPY Pipfile* ./
|
||||
|
||||
@ -10,7 +10,7 @@ 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.0 as ki-backend
|
||||
FROM registry.wtf-eg.net/ki-backend-base:1.0.1 as ki-backend
|
||||
|
||||
# Install six explicitly. Otherwise Python complains about it missing.
|
||||
RUN pip3 install six
|
||||
|
2
Pipfile
2
Pipfile
@ -14,7 +14,7 @@ flask-migrate = "~=3.0.1"
|
||||
flask-sqlalchemy = "~=2.5.1"
|
||||
sqlalchemy = "~=1.4.18"
|
||||
waitress = "~=2.0.0"
|
||||
pyyaml = "~=5.4.1"
|
||||
pyyaml = "~=6.0.1"
|
||||
flask-cors = "~=3.0.10"
|
||||
ldap3 = "~=2.9"
|
||||
pymysql = "~=1.0.2"
|
||||
|
860
Pipfile.lock
generated
860
Pipfile.lock
generated
File diff suppressed because it is too large
Load Diff
@ -59,6 +59,8 @@ def seed_user(nickname,
|
||||
|
||||
db.session.add(profile)
|
||||
|
||||
return profile
|
||||
|
||||
|
||||
def seed(dev: bool):
|
||||
seed_contacttypes()
|
||||
@ -145,7 +147,7 @@ def seed(dev: bool):
|
||||
for i in range(1, 20):
|
||||
seed_user(f"babsi{i}", visible=True)
|
||||
|
||||
seed_user("dirtydieter",
|
||||
dieter = seed_user("dirtydieter",
|
||||
visible=True,
|
||||
volunteerwork="Müll sammeln",
|
||||
availability_status=True,
|
||||
@ -154,6 +156,9 @@ def seed(dev: bool):
|
||||
freetext="1001010010111!!!",
|
||||
skills=[(Skill.skill_id_php, 5)])
|
||||
|
||||
dieters_address = Address(name="Friedrich Witzig", profile=dieter)
|
||||
db.session.add(dieters_address)
|
||||
|
||||
all_skills = Skill.query.all()
|
||||
all_profile_skills = []
|
||||
for skill in all_skills:
|
||||
|
@ -4,7 +4,7 @@
|
||||
|
||||
from flask import make_response, request
|
||||
|
||||
from ki.models import Profile, ProfileSkill, Skill, ProfileLanguage, Language
|
||||
from ki.models import Profile, ProfileSkill, Skill, ProfileLanguage, Language, Address
|
||||
|
||||
|
||||
def find_profiles():
|
||||
@ -25,13 +25,18 @@ def find_profiles():
|
||||
.order_by(Profile.nickname) \
|
||||
.filter(Profile.visible.is_(True)) \
|
||||
.join(Profile.skills, isouter=True).join(ProfileSkill.skill, isouter=True) \
|
||||
.join(Profile.languages, isouter=True).join(ProfileLanguage.language, isouter=True)
|
||||
.join(Profile.languages, isouter=True).join(ProfileLanguage.language, isouter=True) \
|
||||
.join(Address, isouter=True)
|
||||
|
||||
if "search" in request.args:
|
||||
terms = request.args["search"].split(" ")
|
||||
for term in terms:
|
||||
|
||||
query = query.filter(
|
||||
Profile.nickname.like(f"%{term}%") | Skill.name.like(f"%{term}%") | Language.name.like(f"%{term}%"))
|
||||
Profile.nickname.like(f"%{term}%") | # noqa: W504
|
||||
Skill.name.like(f"%{term}%") | # noqa: W504
|
||||
Language.name.like(f"%{term}%") | # noqa: W504
|
||||
Address.name.like(f"%{term}%"))
|
||||
|
||||
if "nickname" in request.args:
|
||||
nickname = request.args.get("nickname")
|
||||
|
@ -99,6 +99,14 @@ class TestFindProfilesEndpoint(ApiTest):
|
||||
self.assertDictContainsSubset({"nickname": "jutta"}, response.json["profiles"][0])
|
||||
self.assertDictContainsSubset({"nickname": "monique"}, response.json["profiles"][1])
|
||||
|
||||
def test_find_dieter_by_name(self):
|
||||
token = self.login("peter", "geheim")["token"]
|
||||
|
||||
response = self.client.get("/users/profiles?search=friedrich", headers={"Authorization": "Bearer " + token})
|
||||
self.assertEqual(response.status_code, 200)
|
||||
self.assertDictContainsSubset({"total": 1}, response.json)
|
||||
self.assertDictContainsSubset({"nickname": "dirtydieter"}, response.json["profiles"][0])
|
||||
|
||||
|
||||
if __name__ == "main":
|
||||
unittest.main()
|
||||
|
@ -11,4 +11,4 @@ with app.app_context():
|
||||
config = migrate.get_config()
|
||||
command.upgrade(config, "head")
|
||||
|
||||
serve(app, host="0.0.0.0", port=5000)
|
||||
serve(app, host="0.0.0.0", port=5000, threads=20)
|
||||
|
Loading…
Reference in New Issue
Block a user